]>
git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/jaeger-client-cpp/src/jaegertracing/ThriftSender.h
2 * Copyright (c) 2017-2018 Uber Technologies, Inc.
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 #ifndef JAEGERTRACING_THRIFTSENDER_H
18 #define JAEGERTRACING_THRIFTSENDER_H
20 #include "jaegertracing/Compilers.h"
21 #include "jaegertracing/Span.h"
22 #include "jaegertracing/Sender.h"
23 #include "jaegertracing/thrift-gen/jaeger_types.h"
24 #include "jaegertracing/utils/Transport.h"
25 #include <thrift/transport/TBufferTransports.h>
27 namespace jaegertracing
{
29 class ThriftSender
: public Sender
{
31 ThriftSender(std::unique_ptr
<utils::Transport
>&& transporter
);
33 ~ThriftSender() { close(); }
35 int append(const Span
& span
) override
;
39 void close() override
{ _transporter
->close(); }
42 void setClient(std::unique_ptr
<utils::Transport
>&& client
)
44 _transporter
= std::move(client
);
51 _byteBufferSize
= _processByteSize
;
54 template <typename ThriftType
>
55 int calcSizeOfSerializedThrift(const ThriftType
& base
)
57 _thriftBuffer
->resetBuffer();
58 auto _protocol
= _protocolFactory
->getProtocol(_thriftBuffer
);
59 base
.write(_protocol
.get());
60 uint8_t* data
= nullptr;
62 _thriftBuffer
->getBuffer(&data
, &size
);
66 std::unique_ptr
<utils::Transport
> _transporter
;
69 std::vector
<thrift::Span
> _spanBuffer
;
70 thrift::Process _process
;
72 std::unique_ptr
<apache::thrift::protocol::TProtocolFactory
> _protocolFactory
;
73 // reuse buffer across serializations of different ThriftType for size
75 std::shared_ptr
<apache::thrift::transport::TMemoryBuffer
> _thriftBuffer
;
78 } // namespace jaegertracing
80 #endif //JAEGERTRACING_THRIFTSENDER_H