]>
git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/jaeger-client-cpp/src/jaegertracing/utils/HTTPTransporter.cpp
2 * Copyright (c) 2019, The Jaeger Authors
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "jaegertracing/utils/HTTPTransporter.h"
18 #include <thrift/protocol/TBinaryProtocol.h>
19 #include <thrift/protocol/TProtocol.h>
21 namespace jaegertracing
{
24 HTTPTransporter::HTTPTransporter(const net::URI
& endpoint
, int maxPacketSize
)
25 : Transport(maxPacketSize
== 0 ? kHttpPacketMaxLength
: maxPacketSize
)
26 , _buffer(new apache::thrift::transport::TMemoryBuffer(_maxPacketSize
))
27 , _serverAddr(net::IPAddress::v4(endpoint
._host
, endpoint
._port
))
28 , _httpClient(new ::apache::thrift::transport::THttpClient(
29 _buffer
, endpoint
._host
, endpoint
._path
+ "?format=jaeger.thrift"))
31 using TProtocolFactory
= apache::thrift::protocol::TProtocolFactory
;
32 using TBinaryProtocolFactory
=
33 apache::thrift::protocol::TBinaryProtocolFactory
;
35 _socket
.open(AF_INET
, SOCK_STREAM
);
36 _socket
.connect(_serverAddr
);
37 std::shared_ptr
<TProtocolFactory
> protocolFactory(
38 new TBinaryProtocolFactory());
39 _protocol
= protocolFactory
->getProtocol(_httpClient
);
43 } // namespace jaegertracing