diff --git a/CHANGELOG.md b/CHANGELOG.md index fdc2db1207..d1d4fc60ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ Increment the: ## [Unreleased] +* [EXPORTER] Add Jaeger exporter ([#534](https://github.com/open-telemetry/opentelemetry-cpp/pull/534)) * [SDK] Add instrumentation library and multiple tracer support ([#693](https://github.com/open-telemetry/opentelemetry-cpp/pull/693)) ## [0.5.0] 2021-04-26 diff --git a/CMakeLists.txt b/CMakeLists.txt index 83dbfacfbf..6c414bcbd4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,6 +82,8 @@ option(WITH_PROMETHEUS "Whether to include the Prometheus Client in the SDK" option(WITH_ELASTICSEARCH "Whether to include the Elasticsearch Client in the SDK" OFF) +option(WITH_JAEGER "Whether to include the Jaeger exporter" OFF) + option(BUILD_TESTING "Whether to enable tests" ON) if(WIN32) option(WITH_ETW "Whether to include the ETW Exporter in the SDK" ON) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 8aec6526a6..56dc51b2d6 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,6 +1,9 @@ if(WITH_OTLP) add_subdirectory(otlp) endif() +if(WITH_JAEGER) + add_subdirectory(jaeger) +endif() add_subdirectory(plugin) add_subdirectory(simple) add_subdirectory(batch) diff --git a/examples/jaeger/BUILD b/examples/jaeger/BUILD new file mode 100644 index 0000000000..5a2c204739 --- /dev/null +++ b/examples/jaeger/BUILD @@ -0,0 +1,26 @@ +cc_library( + name = "foo_library", + srcs = [ + "foo_library/foo_library.cc", + ], + hdrs = [ + "foo_library/foo_library.h", + ], + deps = [ + "//api", + ], +) + +# TODO: enable bazel build +# cc_binary( +# name = "example_jaeger", +# srcs = [ +# "main.cc", +# ], +# deps = [ +# ":foo_library", +# "//api", +# "//exporters/jaeger:jaeger_exporter", +# "//sdk/src/trace", +# ], +# ) diff --git a/examples/jaeger/CMakeLists.txt b/examples/jaeger/CMakeLists.txt new file mode 100644 index 0000000000..dabf45c463 --- /dev/null +++ b/examples/jaeger/CMakeLists.txt @@ -0,0 +1,10 @@ +include_directories(${CMAKE_SOURCE_DIR}/exporters/jaeger/include) + +add_library(jaeger_foo_library foo_library/foo_library.cc) +target_link_libraries(jaeger_foo_library ${CMAKE_THREAD_LIBS_INIT} + ${CORE_RUNTIME_LIBS} opentelemetry_api) + +add_executable(example_jaeger main.cc) +target_link_libraries( + example_jaeger ${CMAKE_THREAD_LIBS_INIT} jaeger_foo_library + opentelemetry_trace ${CORE_RUNTIME_LIBS} jaeger_trace_exporter) diff --git a/examples/jaeger/README.md b/examples/jaeger/README.md new file mode 100644 index 0000000000..42ac4e125a --- /dev/null +++ b/examples/jaeger/README.md @@ -0,0 +1,18 @@ +# Jaeger Exporter Example + +This is an example of how to use the Jaeger exporter. + +The application in `main.cc` initializes an `JaegerExporter` instance and uses it +to register a tracer provider from the [OpenTelemetry +SDK](https://github.com/open-telemetry/opentelemetry-cpp). The application then +calls a `foo_library` which has been instrumented using the [OpenTelemetry +API](https://github.com/open-telemetry/opentelemetry-cpp/tree/main/api). + +Resulting spans are exported to the Jaeger agent using the Jaeger exporter. + +Note that the Jaeger exporter connects to the agent at `localhost:6831` by +default. + +Once you have the Collector running, see +[CONTRIBUTING.md](../../CONTRIBUTING.md) for instructions on building and +running the example. diff --git a/examples/jaeger/foo_library/foo_library.cc b/examples/jaeger/foo_library/foo_library.cc new file mode 100644 index 0000000000..764e6653d4 --- /dev/null +++ b/examples/jaeger/foo_library/foo_library.cc @@ -0,0 +1,33 @@ +#include "opentelemetry/trace/provider.h" + +namespace trace = opentelemetry::trace; +namespace nostd = opentelemetry::nostd; + +namespace +{ +nostd::shared_ptr get_tracer() +{ + auto provider = trace::Provider::GetTracerProvider(); + return provider->GetTracer("foo_library"); +} + +void f1() +{ + auto scoped_span = trace::Scope(get_tracer()->StartSpan("f1")); +} + +void f2() +{ + auto scoped_span = trace::Scope(get_tracer()->StartSpan("f2")); + + f1(); + f1(); +} +} // namespace + +void foo_library() +{ + auto scoped_span = trace::Scope(get_tracer()->StartSpan("library")); + + f2(); +} diff --git a/examples/jaeger/foo_library/foo_library.h b/examples/jaeger/foo_library/foo_library.h new file mode 100644 index 0000000000..7ac75c0e50 --- /dev/null +++ b/examples/jaeger/foo_library/foo_library.h @@ -0,0 +1,3 @@ +#pragma once + +void foo_library(); diff --git a/examples/jaeger/main.cc b/examples/jaeger/main.cc new file mode 100644 index 0000000000..d614e1af36 --- /dev/null +++ b/examples/jaeger/main.cc @@ -0,0 +1,39 @@ +#include "opentelemetry/exporters/jaeger/jaeger_exporter.h" +#include "opentelemetry/sdk/trace/simple_processor.h" +#include "opentelemetry/sdk/trace/tracer_provider.h" +#include "opentelemetry/trace/provider.h" + +#include "foo_library/foo_library.h" + +namespace trace = opentelemetry::trace; +namespace nostd = opentelemetry::nostd; +namespace sdktrace = opentelemetry::sdk::trace; +namespace jaeger = opentelemetry::exporter::jaeger; + +namespace +{ +opentelemetry::exporter::jaeger::JaegerExporterOptions opts; +void InitTracer() +{ + // Create Jaeger exporter instance + auto exporter = std::unique_ptr(new jaeger::JaegerExporter(opts)); + auto processor = std::unique_ptr( + new sdktrace::SimpleSpanProcessor(std::move(exporter))); + auto provider = + nostd::shared_ptr(new sdktrace::TracerProvider(std::move(processor))); + // Set the global trace provider + trace::Provider::SetTracerProvider(provider); +} +} // namespace + +int main(int argc, char *argv[]) +{ + if (argc == 2) + { + opts.server_addr = argv[1]; + } + // Removing this line will leave the default noop TracerProvider in place. + InitTracer(); + + foo_library(); +} diff --git a/exporters/CMakeLists.txt b/exporters/CMakeLists.txt index 69cff59e89..4ab469b7c2 100644 --- a/exporters/CMakeLists.txt +++ b/exporters/CMakeLists.txt @@ -34,3 +34,7 @@ endif() if(WITH_ETW) add_subdirectory(etw) endif() + +if(WITH_JAEGER) + add_subdirectory(jaeger) +endif() diff --git a/exporters/jaeger/CMakeLists.txt b/exporters/jaeger/CMakeLists.txt new file mode 100644 index 0000000000..a5b8695fdc --- /dev/null +++ b/exporters/jaeger/CMakeLists.txt @@ -0,0 +1,38 @@ +include_directories(include) +include_directories(thrift-gen) + +find_package(Thrift REQUIRED) + +set(JAEGER_THRIFT_GENCPP_SOURCES + thrift-gen/Agent.cpp thrift-gen/jaeger_types.cpp thrift-gen/Collector.cpp + thrift-gen/zipkincore_types.cpp) + +set(JAEGER_EXPORTER_SOURCES + src/jaeger_exporter.cc src/thrift_sender.cc src/udp_transport.cc + src/recordable.cc src/TUDPTransport.cc) + +add_library(jaeger_trace_exporter ${JAEGER_EXPORTER_SOURCES} + ${JAEGER_THRIFT_GENCPP_SOURCES}) +target_link_libraries( + jaeger_trace_exporter + PUBLIC opentelemetry_resources + PRIVATE thrift::thrift) + +if(MSVC) + target_compile_definitions(jaeger_trace_exporter PUBLIC NOMINMAX) + if(NOT BUILD_SHARED_LIBS) + target_compile_definitions(jaeger_trace_exporter + PUBLIC THRIFT_STATIC_DEFINE) + endif() +endif() + +if(BUILD_TESTING) + add_executable(jaeger_recordable_test test/jaeger_recordable_test.cc) + target_link_libraries(jaeger_recordable_test ${GTEST_BOTH_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} jaeger_trace_exporter) + + gtest_add_tests( + TARGET jaeger_recordable_test + TEST_PREFIX exporter. + TEST_LIST jaeger_recordable_test) +endif() # BUILD_TESTING diff --git a/exporters/jaeger/README.md b/exporters/jaeger/README.md new file mode 100644 index 0000000000..1e80f87445 --- /dev/null +++ b/exporters/jaeger/README.md @@ -0,0 +1,56 @@ +# Jaeger Exporter for OpenTelemetry C++ + +## Prerequisite + +* [Get Jaeger](https://www.jaegertracing.io/docs/getting-started/) and run + Jaeger agent. + +## Installation + +## CMake Installation Instructions + +Refer to install instructions +[INSTALL.md](../../INSTALL.md#building-as-standalone-cmake-project). Modify step +2 to create `cmake` build configuration for compiling with Jaeger exporter as +below: + +```console + $ cmake -DWITH_JAEGER=ON .. + -- The C compiler identification is GNU 9.3.0 + -- The CXX compiler identification is GNU 9.3.0 + ... + -- Configuring done + -- Generating done + -- Build files have been written to: /home//source/opentelemetry-cpp/build + $ +``` + +### Bazel install Instructions + +TODO + +## Usage + +Install the exporter on your application and pass the options. + +```cpp +opentelemetry::exporter::jaeger::JaegerExporterOptions options; +options.server_addr = "localhost"; +options.server_port = 6831; +options.transport_format = TransportFormat::kThriftUdpCompact; + +auto exporter = std::unique_ptr( + new opentelemetry::exporter::jaeger::JaegerExporter(options)); +auto processor = std::shared_ptr( + new sdktrace::SimpleSpanProcessor(std::move(exporter))); +auto provider = nostd::shared_ptr( + new sdktrace::TracerProvider(processor)); + +// Set the global trace provider +opentelemetry::trace::Provider::SetTracerProvider(provider); + +``` + +## Viewing your traces + +Please visit the Jaeger UI endpoint . diff --git a/exporters/jaeger/include/opentelemetry/exporters/jaeger/jaeger_exporter.h b/exporters/jaeger/include/opentelemetry/exporters/jaeger/jaeger_exporter.h new file mode 100644 index 0000000000..48b9274695 --- /dev/null +++ b/exporters/jaeger/include/opentelemetry/exporters/jaeger/jaeger_exporter.h @@ -0,0 +1,96 @@ +// Copyright 2021, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace jaeger +{ +enum class TransportFormat +{ + kThriftUdp, + kThriftUdpCompact, + kThriftHttp, + kProtobufGrpc, +}; + +class ThriftSender; + +/** + * Struct to hold Jaeger exporter options. + */ +struct JaegerExporterOptions +{ + // The endpoint to export to. + std::string server_addr = "localhost"; + uint16_t server_port = 6831; + TransportFormat transport_format = TransportFormat::kThriftUdpCompact; +}; + +namespace trace_sdk = opentelemetry::sdk::trace; +namespace sdk_common = opentelemetry::sdk::common; + +class JaegerExporter final : public trace_sdk::SpanExporter +{ +public: + /** + * Create a JaegerExporter using all default options. + */ + JaegerExporter(); + + /** + * Create a JaegerExporter using the given options. + */ + explicit JaegerExporter(const JaegerExporterOptions &options); + + /** + * Create a span recordable. + * @return a new initialized Recordable object. + */ + std::unique_ptr MakeRecordable() noexcept override; + + /** + * Export a batch of spans. + * @param spans a span of unique pointers to span recordables. + */ + sdk_common::ExportResult Export( + const nostd::span> &spans) noexcept override; + + /** + * Shutdown the exporter. + * @param timeout an option timeout, default to max. + */ + bool Shutdown( + std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept override + { + return true; + } + +private: + void InitializeEndpoint(); + +private: + // The configuration options associated with this exporter. + bool is_shutdown_ = false; + JaegerExporterOptions options_; + std::unique_ptr sender_; +}; + +} // namespace jaeger +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/jaeger/include/opentelemetry/exporters/jaeger/recordable.h b/exporters/jaeger/include/opentelemetry/exporters/jaeger/recordable.h new file mode 100644 index 0000000000..27b7e3a7af --- /dev/null +++ b/exporters/jaeger/include/opentelemetry/exporters/jaeger/recordable.h @@ -0,0 +1,85 @@ +// Copyright 2020, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include +#include + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace jaeger +{ + +using namespace jaegertracing; + +class Recordable final : public sdk::trace::Recordable +{ +public: + Recordable(); + + thrift::Span *Span() noexcept { return span_.release(); } + std::vector Tags() noexcept { return std::move(tags_); } + const std::string &ServiceName() const noexcept { return service_name_; } + + void SetIdentity(const opentelemetry::trace::SpanContext &span_context, + opentelemetry::trace::SpanId parent_span_id) noexcept override; + + void SetAttribute(nostd::string_view key, + const opentelemetry::common::AttributeValue &value) noexcept override; + + void AddEvent(nostd::string_view key, + common::SystemTimestamp timestamp, + const common::KeyValueIterable &attributes) noexcept override; + + void AddLink(const opentelemetry::trace::SpanContext &span_context, + const common::KeyValueIterable &attributes) noexcept override; + + void SetStatus(trace::StatusCode code, nostd::string_view description) noexcept override; + + void SetName(nostd::string_view name) noexcept override; + + void SetStartTime(common::SystemTimestamp start_time) noexcept override; + + void SetSpanKind(opentelemetry::trace::SpanKind span_kind) noexcept override; + + void SetResource(const opentelemetry::sdk::resource::Resource &resource) noexcept override; + + void SetDuration(std::chrono::nanoseconds duration) noexcept override; + + void SetInstrumentationLibrary( + const opentelemetry::sdk::instrumentationlibrary::InstrumentationLibrary + &instrumentation_library) noexcept override; + +private: + void AddTag(const std::string &key, const std::string &value); + void AddTag(const std::string &key, const char *value); + void AddTag(const std::string &key, bool value); + void AddTag(const std::string &key, int64_t value); + void AddTag(const std::string &key, double value); + + void PopulateAttribute(nostd::string_view key, + const opentelemetry::common::AttributeValue &value); + +private: + std::unique_ptr span_; + std::vector tags_; + std::string service_name_; +}; + +} // namespace jaeger +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/jaeger/src/TUDPTransport.cc b/exporters/jaeger/src/TUDPTransport.cc new file mode 100644 index 0000000000..1be2207024 --- /dev/null +++ b/exporters/jaeger/src/TUDPTransport.cc @@ -0,0 +1,113 @@ +// Copyright 2021, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "TUDPTransport.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace jaeger +{ + +TUDPTransport::TUDPTransport(const std::string &host, int port) + : host_(host), port_(port), socket_(THRIFT_INVALID_SOCKET) +{} + +TUDPTransport::~TUDPTransport() +{ + if (server_addr_info_) + { + freeaddrinfo(server_addr_info_); + server_addr_info_ = nullptr; + sockaddr_len = 0; + } + close(); +} + +bool TUDPTransport::isOpen() const +{ + return (socket_ != THRIFT_INVALID_SOCKET); +} + +void TUDPTransport::open() +{ + if (isOpen()) + { + return; + } + + struct addrinfo hints; + int error; + char port[sizeof("65535") + 1]; + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_DGRAM; + hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG; + + sprintf(port, "%d", port_); + + error = getaddrinfo(host_.c_str(), port, &hints, &server_addr_info_); + + if (error) + { + // TODO: log error + return; + } + + socket_ = socket(server_addr_info_->ai_family, server_addr_info_->ai_socktype, + server_addr_info_->ai_protocol); + sockaddr_len = server_addr_info_->ai_addr->sa_family == AF_INET ? sizeof(struct sockaddr_in) + : sizeof(struct sockaddr_in6); +} + +void TUDPTransport::close() +{ + if (socket_ != THRIFT_INVALID_SOCKET) + { + ::THRIFT_CLOSESOCKET(socket_); + } + socket_ = THRIFT_INVALID_SOCKET; +} + +uint32_t TUDPTransport::read(uint8_t *buf, uint32_t len) +{ + uint32_t num_read = recvfrom(socket_, +#if defined(_WIN32) + reinterpret_cast(buf), len, 0, server_addr_info_->ai_addr, + reinterpret_cast(&sockaddr_len) +#else + buf, len, 0, server_addr_info_->ai_addr, &sockaddr_len +#endif + ); + + return num_read; +} + +void TUDPTransport::write(const uint8_t *buf, uint32_t len) +{ + sendto(socket_, +#if defined(_WIN32) + reinterpret_cast(buf), +#else + buf, +#endif + len, 0, server_addr_info_->ai_addr, sockaddr_len); +} + +void TUDPTransport::flush() {} + +} // namespace jaeger +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/jaeger/src/TUDPTransport.h b/exporters/jaeger/src/TUDPTransport.h new file mode 100644 index 0000000000..59d45fd1dc --- /dev/null +++ b/exporters/jaeger/src/TUDPTransport.h @@ -0,0 +1,64 @@ +// Copyright 2021, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#ifdef _WIN32 +# include +#else +# include +# include +# include +# include +#endif + +#include +#include +#include + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace jaeger +{ + +class TUDPTransport : public apache::thrift::transport::TVirtualTransport +{ +public: + TUDPTransport(const std::string &host, int port); + ~TUDPTransport() override; + + bool isOpen() const override; + + void open() override; + + void close() override; + + uint32_t read(uint8_t *buf, uint32_t len); + + void write(const uint8_t *buf, uint32_t len); + + void flush() override; + +private: + std::string host_; + int port_; + THRIFT_SOCKET socket_; + struct addrinfo *server_addr_info_ = nullptr; + uint32_t sockaddr_len = 0; +}; + +} // namespace jaeger +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/jaeger/src/jaeger_exporter.cc b/exporters/jaeger/src/jaeger_exporter.cc new file mode 100644 index 0000000000..8937e5d58d --- /dev/null +++ b/exporters/jaeger/src/jaeger_exporter.cc @@ -0,0 +1,89 @@ +// Copyright 2021, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include + +#include "thrift_sender.h" +#include "udp_transport.h" + +#include + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace jaeger +{ + +JaegerExporter::JaegerExporter(const JaegerExporterOptions &options) : options_(options) +{ + InitializeEndpoint(); +} + +JaegerExporter::JaegerExporter() : JaegerExporter(JaegerExporterOptions()) {} + +std::unique_ptr JaegerExporter::MakeRecordable() noexcept +{ + return std::unique_ptr(new Recordable); +} + +sdk_common::ExportResult JaegerExporter::Export( + const nostd::span> &spans) noexcept +{ + if (is_shutdown_) + { + return sdk_common::ExportResult::kFailure; + } + + std::size_t exported_size = 0; + + for (auto &recordable : spans) + { + auto rec = std::unique_ptr(static_cast(recordable.release())); + if (rec != nullptr) + { + exported_size += sender_->Append(std::move(rec)); + } + } + + exported_size += sender_->Flush(); + + if (exported_size == 0) + { + return sdk_common::ExportResult::kFailure; + } + + return sdk_common::ExportResult::kSuccess; +} + +void JaegerExporter::InitializeEndpoint() +{ + if (options_.transport_format == TransportFormat::kThriftUdpCompact) + { + // TODO: do we need support any authentication mechanism? + auto transport = std::unique_ptr( + static_cast(new UDPTransport(options_.server_addr, options_.server_port))); + sender_ = std::unique_ptr(new ThriftSender(std::move(transport))); + } + else + { + // The transport format is not implemented. + assert(false); + } +} + +} // namespace jaeger +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/jaeger/src/recordable.cc b/exporters/jaeger/src/recordable.cc new file mode 100644 index 0000000000..3a493e4ef1 --- /dev/null +++ b/exporters/jaeger/src/recordable.cc @@ -0,0 +1,212 @@ +// Copyright 2021, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace jaeger +{ + +Recordable::Recordable() : span_{new thrift::Span} {} + +void Recordable::PopulateAttribute(nostd::string_view key, const common::AttributeValue &value) +{ + if (nostd::holds_alternative(value)) + { + AddTag(std::string{key}, nostd::get(value)); + } + else if (nostd::holds_alternative(value)) + { + AddTag(std::string{key}, nostd::get(value)); + } + else if (nostd::holds_alternative(value)) + { + AddTag(std::string{key}, nostd::get(value)); + } + else if (nostd::holds_alternative(value)) + { + AddTag(std::string{key}, std::string{nostd::get(value)}); + } + // TODO: extend other AttributeType to the types supported by Jaeger. +} + +void Recordable::SetIdentity(const trace::SpanContext &span_context, + trace::SpanId parent_span_id) noexcept +{ + span_->__set_traceIdLow( + *(reinterpret_cast(span_context.trace_id().Id().data()))); + span_->__set_traceIdHigh( + *(reinterpret_cast(span_context.trace_id().Id().data()) + 1)); + span_->__set_spanId(*(reinterpret_cast(span_context.span_id().Id().data()))); + span_->__set_parentSpanId(*(reinterpret_cast(parent_span_id.Id().data()))); + + // TODO: set trace_state. +} + +void Recordable::SetAttribute(nostd::string_view key, const common::AttributeValue &value) noexcept +{ + PopulateAttribute(key, value); +} + +void Recordable::AddEvent(nostd::string_view name, + common::SystemTimestamp timestamp, + const common::KeyValueIterable &attributes) noexcept +{ + // TODO: convert event to Jaeger Log +} + +void Recordable::SetInstrumentationLibrary( + const opentelemetry::sdk::instrumentationlibrary::InstrumentationLibrary + &instrumentation_library) noexcept +{} + +void Recordable::AddLink(const trace::SpanContext &span_context, + const common::KeyValueIterable &attributes) noexcept +{ + // TODO: convert link to SpanRefernece +} + +void Recordable::SetStatus(trace::StatusCode code, nostd::string_view description) noexcept +{ + if (code == trace::StatusCode::kUnset) + { + return; + } + + if (code == trace::StatusCode::kOk) + { + AddTag("otel.status_code", "OK"); + } + else if (code == trace::StatusCode::kError) + { + AddTag("otel.status_code", "ERROR"); + AddTag("error", true); + } + + AddTag("otel.status_description", std::string{description}); +} + +void Recordable::SetName(nostd::string_view name) noexcept +{ + span_->__set_operationName(static_cast(name)); +} + +void Recordable::SetResource(const opentelemetry::sdk::resource::Resource &resource) noexcept +{ + // only service.name attribute is supported by specs as of now. + auto attributes = resource.GetAttributes(); + if (attributes.find("service.name") != attributes.end()) + { + service_name_ = nostd::get(attributes["service.name"]); + } +} + +void Recordable::SetStartTime(common::SystemTimestamp start_time) noexcept +{ + span_->__set_startTime( + std::chrono::duration_cast(start_time.time_since_epoch()).count()); +} + +void Recordable::SetDuration(std::chrono::nanoseconds duration) noexcept +{ + span_->__set_duration(std::chrono::duration_cast(duration).count()); +} + +void Recordable::SetSpanKind(trace::SpanKind span_kind) noexcept +{ + const char *span_kind_str = nullptr; + + // map SpanKind to Jaeger tag span.kind. + switch (span_kind) + { + case opentelemetry::trace::SpanKind::kClient: { + span_kind_str = "client"; + break; + } + case opentelemetry::trace::SpanKind::kServer: { + span_kind_str = "server"; + break; + } + case opentelemetry::trace::SpanKind::kConsumer: { + span_kind_str = "consumer"; + break; + } + case opentelemetry::trace::SpanKind::kProducer: { + span_kind_str = "producer"; + break; + } + default: + break; + } + + if (span_kind_str != nullptr) + { + AddTag("span.kind", span_kind_str); + } +} + +void Recordable::AddTag(const std::string &key, const std::string &value) +{ + thrift::Tag tag; + + tag.__set_key(key); + tag.__set_vType(thrift::TagType::STRING); + tag.__set_vStr(value); + + tags_.push_back(tag); +} + +void Recordable::AddTag(const std::string &key, const char *value) +{ + AddTag(key, std::string{value}); +} + +void Recordable::AddTag(const std::string &key, bool value) +{ + thrift::Tag tag; + + tag.__set_key(key); + tag.__set_vType(thrift::TagType::BOOL); + tag.__set_vBool(value); + + tags_.push_back(tag); +} + +void Recordable::AddTag(const std::string &key, int64_t value) +{ + thrift::Tag tag; + + tag.__set_key(key); + tag.__set_vType(thrift::TagType::LONG); + tag.__set_vLong(value); + + tags_.push_back(tag); +} + +void Recordable::AddTag(const std::string &key, double value) +{ + thrift::Tag tag; + + tag.__set_key(key); + tag.__set_vType(thrift::TagType::DOUBLE); + tag.__set_vDouble(value); + + tags_.push_back(tag); +} + +} // namespace jaeger +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/jaeger/src/sender.h b/exporters/jaeger/src/sender.h new file mode 100644 index 0000000000..1189f5cb30 --- /dev/null +++ b/exporters/jaeger/src/sender.h @@ -0,0 +1,42 @@ +// Copyright 2021, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace jaeger +{ + +using namespace jaegertracing; + +class Sender +{ +public: + Sender() = default; + virtual ~Sender() = default; + + virtual int Append(std::unique_ptr &&span) = 0; + + virtual int Flush() = 0; + + virtual void Close() = 0; +}; + +} // namespace jaeger +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/jaeger/src/thrift_sender.cc b/exporters/jaeger/src/thrift_sender.cc new file mode 100644 index 0000000000..4021cb4d76 --- /dev/null +++ b/exporters/jaeger/src/thrift_sender.cc @@ -0,0 +1,105 @@ +// Copyright 2021, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "thrift_sender.h" +#include "udp_transport.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace jaeger +{ + +using namespace jaegertracing; + +ThriftSender::ThriftSender(std::unique_ptr &&transport) + : transport_(std::move(transport)), + protocol_factory_(new apache::thrift::protocol::TCompactProtocolFactory()), + thrift_buffer_(new apache::thrift::transport::TMemoryBuffer()) +{} + +int ThriftSender::Append(std::unique_ptr &&span) noexcept +{ + if (span == nullptr) + { + return 0; + } + + uint32_t max_span_bytes = transport_->MaxPacketSize() - kEmitBatchOverhead; + if (process_.serviceName.empty()) + { + process_.serviceName = span->ServiceName(); + + process_bytes_size_ = CalcSizeOfSerializedThrift(process_); + max_span_bytes -= process_bytes_size_; + } + + thrift::Span &jaeger_span = *span->Span(); + jaeger_span.__set_tags(span->Tags()); + + const uint32_t span_size = CalcSizeOfSerializedThrift(jaeger_span); + if (span_size > max_span_bytes) + { + // TODO, log too large span error. + return 0; + } + + byte_buffer_size_ += span_size; + if (byte_buffer_size_ <= max_span_bytes) + { + span_buffer_.push_back(jaeger_span); + if (byte_buffer_size_ < max_span_bytes) + { + return 0; + } + else + { + // byte buffer is full so flush it before appending new span. + return Flush(); + } + } + + const auto flushed = Flush(); + span_buffer_.push_back(jaeger_span); + byte_buffer_size_ = span_size + process_bytes_size_; + + return flushed; +} + +int ThriftSender::Flush() +{ + if (span_buffer_.empty()) + { + return 0; + } + + thrift::Batch batch; + batch.__set_process(process_); + batch.__set_spans(span_buffer_); + + transport_->EmitBatch(batch); + + ResetBuffers(); + + return static_cast(batch.spans.size()); +} + +void ThriftSender::Close() +{ + Flush(); +} + +} // namespace jaeger +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/jaeger/src/thrift_sender.h b/exporters/jaeger/src/thrift_sender.h new file mode 100644 index 0000000000..4d503d66db --- /dev/null +++ b/exporters/jaeger/src/thrift_sender.h @@ -0,0 +1,86 @@ +// Copyright 2021, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "sender.h" +#include "transport.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace jaeger +{ + +using namespace jaegertracing; + +class ThriftSender : public Sender +{ +public: + static constexpr uint32_t kEmitBatchOverhead = 30; + + ThriftSender(std::unique_ptr &&transport); + ~ThriftSender() override { Close(); } + + int Append(std::unique_ptr &&span) noexcept override; + int Flush() override; + void Close() override; + +private: + void ResetBuffers() + { + span_buffer_.clear(); + byte_buffer_size_ = process_bytes_size_; + } + + template + uint32_t CalcSizeOfSerializedThrift(const ThriftType &base) + { + uint8_t *data = nullptr; + uint32_t size = 0; + + thrift_buffer_->resetBuffer(); + auto protocol = protocol_factory_->getProtocol(thrift_buffer_); + base.write(protocol.get()); + thrift_buffer_->getBuffer(&data, &size); + return size; + } + +private: + std::vector> spans_; + std::vector span_buffer_; + std::unique_ptr transport_; + std::unique_ptr protocol_factory_; + std::shared_ptr thrift_buffer_; + thrift::Process process_; + + // Size in bytes of the serialization buffer. + uint32_t byte_buffer_size_ = 0; + uint32_t process_bytes_size_ = 0; + uint32_t max_span_bytes_ = 0; +}; + +} // namespace jaeger +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/jaeger/src/transport.h b/exporters/jaeger/src/transport.h new file mode 100644 index 0000000000..377893ffb3 --- /dev/null +++ b/exporters/jaeger/src/transport.h @@ -0,0 +1,41 @@ +// Copyright 2020, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include + +#include + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace jaeger +{ + +using namespace jaegertracing; + +class Transport +{ +public: + Transport() = default; + virtual ~Transport() = default; + + virtual void EmitBatch(const thrift::Batch &batch) = 0; + virtual uint32_t MaxPacketSize() const = 0; +}; + +} // namespace jaeger +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/jaeger/src/udp_transport.cc b/exporters/jaeger/src/udp_transport.cc new file mode 100644 index 0000000000..14e2cc9e16 --- /dev/null +++ b/exporters/jaeger/src/udp_transport.cc @@ -0,0 +1,89 @@ +// Copyright 2020, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "udp_transport.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace jaeger +{ + +UDPTransport::UDPTransport(const std::string &addr, uint16_t port) + : max_packet_size_(kUDPPacketMaxLength) +{ + InitSocket(); + + endpoint_transport_ = std::shared_ptr(new TUDPTransport(addr, port)); + endpoint_transport_->open(); + transport_ = std::shared_ptr(new TBufferedTransport(endpoint_transport_)); + protocol_ = std::shared_ptr(new TCompactProtocol(transport_)); + agent_ = std::unique_ptr(new AgentClient(protocol_)); +} + +UDPTransport::~UDPTransport() +{ + CleanSocket(); +} + +void UDPTransport::InitSocket() +{ +#if defined(_WIN32) + /* Use the MAKEWORD(lowbyte, highbyte) macro declared in Windef.h */ + WORD wVersionRequested = MAKEWORD(2, 2); + + WSADATA wsaData; + int err = WSAStartup(wVersionRequested, &wsaData); + if (err != 0) + { + // TODO: handle error + return; + } + + /* Confirm that the WinSock DLL supports 2.2.*/ + /* Note that if the DLL supports versions greater */ + /* than 2.2 in addition to 2.2, it will still return */ + /* 2.2 in wVersion since that is the version we */ + /* requested. */ + + if (LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2) + { + // TODO: handle error that WinSock 2.2 is not supported. + WSACleanup(); + + return; + } +#endif +} + +void UDPTransport::CleanSocket() +{ +#if defined(_WIN32) + WSACleanup(); +#endif +} + +void UDPTransport::EmitBatch(const thrift::Batch &batch) +{ + try + { + agent_->emitBatch(batch); + } + catch (...) + {} +} + +} // namespace jaeger +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/jaeger/src/udp_transport.h b/exporters/jaeger/src/udp_transport.h new file mode 100644 index 0000000000..3b40f182e8 --- /dev/null +++ b/exporters/jaeger/src/udp_transport.h @@ -0,0 +1,69 @@ +// Copyright 2021, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include "TUDPTransport.h" +#include "transport.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace exporter +{ +namespace jaeger +{ + +using AgentClient = jaegertracing::agent::thrift::AgentClient; +using TBinaryProtocol = apache::thrift::protocol::TBinaryProtocol; +using TCompactProtocol = apache::thrift::protocol::TCompactProtocol; +using TBufferedTransport = apache::thrift::transport::TBufferedTransport; +using TProtocol = apache::thrift::protocol::TProtocol; +using TSocket = apache::thrift::transport::TSocket; +using TTransport = apache::thrift::transport::TTransport; + +class UDPTransport : public Transport +{ +public: + static constexpr auto kUDPPacketMaxLength = 65000; + + UDPTransport(const std::string &addr, uint16_t port); + virtual ~UDPTransport(); + + void EmitBatch(const thrift::Batch &batch) override; + + uint32_t MaxPacketSize() const override { return max_packet_size_; } + + void InitSocket(); + void CleanSocket(); + +private: + std::unique_ptr agent_; + std::shared_ptr endpoint_transport_; + std::shared_ptr transport_; + std::shared_ptr protocol_; + uint32_t max_packet_size_; +}; + +} // namespace jaeger +} // namespace exporter +OPENTELEMETRY_END_NAMESPACE diff --git a/exporters/jaeger/test/jaeger_recordable_test.cc b/exporters/jaeger/test/jaeger_recordable_test.cc new file mode 100644 index 0000000000..792a1bc3f5 --- /dev/null +++ b/exporters/jaeger/test/jaeger_recordable_test.cc @@ -0,0 +1,125 @@ +// Copyright 2021, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "opentelemetry/exporters/jaeger/recordable.h" +#include "opentelemetry/sdk/trace/simple_processor.h" +#include "opentelemetry/sdk/trace/span_data.h" +#include "opentelemetry/sdk/trace/tracer_provider.h" +#include "opentelemetry/trace/provider.h" + +#include + +namespace trace = opentelemetry::trace; +namespace nostd = opentelemetry::nostd; +namespace sdktrace = opentelemetry::sdk::trace; + +using namespace jaegertracing; + +TEST(JaegerSpanRecordable, SetIdentity) +{ + opentelemetry::exporter::jaeger::Recordable rec; + + int64_t trace_id_val[2] = {0x0000000000000000, 0x1000000000000000}; + int64_t span_id_val = 0x2000000000000000; + int64_t parent_span_id_val = 0x3000000000000000; + + const trace::TraceId trace_id{ + nostd::span(reinterpret_cast(trace_id_val), 16)}; + + const trace::SpanId span_id( + nostd::span(reinterpret_cast(&span_id_val), 8)); + + const trace::SpanId parent_span_id( + nostd::span(reinterpret_cast(&parent_span_id_val), 8)); + + const opentelemetry::trace::SpanContext span_context{ + trace_id, span_id, + opentelemetry::trace::TraceFlags{opentelemetry::trace::TraceFlags::kIsSampled}, true}; + rec.SetIdentity(span_context, parent_span_id); + + std::unique_ptr span{rec.Span()}; + + EXPECT_EQ(span->traceIdLow, trace_id_val[0]); + EXPECT_EQ(span->traceIdHigh, trace_id_val[1]); + EXPECT_EQ(span->spanId, span_id_val); + EXPECT_EQ(span->parentSpanId, parent_span_id_val); +} + +TEST(JaegerSpanRecordable, SetName) +{ + opentelemetry::exporter::jaeger::Recordable rec; + + nostd::string_view name = "Test Span"; + rec.SetName(name); + + std::unique_ptr span{rec.Span()}; + + EXPECT_EQ(span->operationName, name); +} + +TEST(JaegerSpanRecordable, SetStartTime) +{ + opentelemetry::exporter::jaeger::Recordable rec; + + std::chrono::system_clock::time_point start_time = std::chrono::system_clock::now(); + opentelemetry::common::SystemTimestamp start_timestamp(start_time); + uint64_t unix_start = + std::chrono::duration_cast(start_time.time_since_epoch()).count(); + rec.SetStartTime(start_timestamp); + + std::unique_ptr span{rec.Span()}; + + EXPECT_EQ(span->startTime, unix_start); +} + +TEST(JaegerSpanRecordable, SetDuration) +{ + opentelemetry::exporter::jaeger::Recordable rec; + + opentelemetry::common::SystemTimestamp start_timestamp; + + std::chrono::microseconds duration(10); + uint64_t unix_end = duration.count(); + + rec.SetStartTime(start_timestamp); + rec.SetDuration(duration); + + std::unique_ptr span{rec.Span()}; + + EXPECT_EQ(span->startTime, 0); + EXPECT_EQ(span->duration, unix_end); +} + +TEST(JaegerSpanRecordable, SetStatus) +{ + opentelemetry::exporter::jaeger::Recordable rec; + + const char *error_description = "Error test"; + rec.SetStatus(trace::StatusCode::kError, error_description); + + auto tags = rec.Tags(); + EXPECT_EQ(tags.size(), 3); + + EXPECT_EQ(tags[0].key, "otel.status_code"); + EXPECT_EQ(tags[0].vType, thrift::TagType::STRING); + EXPECT_EQ(tags[0].vStr, "ERROR"); + + EXPECT_EQ(tags[1].key, "error"); + EXPECT_EQ(tags[1].vType, thrift::TagType::BOOL); + EXPECT_EQ(tags[1].vBool, true); + + EXPECT_EQ(tags[2].key, "otel.status_description"); + EXPECT_EQ(tags[2].vType, thrift::TagType::STRING); + EXPECT_EQ(tags[2].vStr, error_description); +} diff --git a/exporters/jaeger/thrift-gen/Agent.cpp b/exporters/jaeger/thrift-gen/Agent.cpp new file mode 100644 index 0000000000..4ff0236501 --- /dev/null +++ b/exporters/jaeger/thrift-gen/Agent.cpp @@ -0,0 +1,380 @@ +/** + * Autogenerated by Thrift Compiler (0.14.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +#include "Agent.h" + +namespace jaegertracing { namespace agent { namespace thrift { + + +Agent_emitZipkinBatch_args::~Agent_emitZipkinBatch_args() noexcept { +} + + +uint32_t Agent_emitZipkinBatch_args::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + this->spans.clear(); + uint32_t _size0; + ::apache::thrift::protocol::TType _etype3; + xfer += iprot->readListBegin(_etype3, _size0); + this->spans.resize(_size0); + uint32_t _i4; + for (_i4 = 0; _i4 < _size0; ++_i4) + { + xfer += this->spans[_i4].read(iprot); + } + xfer += iprot->readListEnd(); + } + this->__isset.spans = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t Agent_emitZipkinBatch_args::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("Agent_emitZipkinBatch_args"); + + xfer += oprot->writeFieldBegin("spans", ::apache::thrift::protocol::T_LIST, 1); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->spans.size())); + std::vector< ::twitter::zipkin::thrift::Span> ::const_iterator _iter5; + for (_iter5 = this->spans.begin(); _iter5 != this->spans.end(); ++_iter5) + { + xfer += (*_iter5).write(oprot); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +Agent_emitZipkinBatch_pargs::~Agent_emitZipkinBatch_pargs() noexcept { +} + + +uint32_t Agent_emitZipkinBatch_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("Agent_emitZipkinBatch_pargs"); + + xfer += oprot->writeFieldBegin("spans", ::apache::thrift::protocol::T_LIST, 1); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast((*(this->spans)).size())); + std::vector< ::twitter::zipkin::thrift::Span> ::const_iterator _iter6; + for (_iter6 = (*(this->spans)).begin(); _iter6 != (*(this->spans)).end(); ++_iter6) + { + xfer += (*_iter6).write(oprot); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +Agent_emitBatch_args::~Agent_emitBatch_args() noexcept { +} + + +uint32_t Agent_emitBatch_args::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->batch.read(iprot); + this->__isset.batch = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t Agent_emitBatch_args::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("Agent_emitBatch_args"); + + xfer += oprot->writeFieldBegin("batch", ::apache::thrift::protocol::T_STRUCT, 1); + xfer += this->batch.write(oprot); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +Agent_emitBatch_pargs::~Agent_emitBatch_pargs() noexcept { +} + + +uint32_t Agent_emitBatch_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("Agent_emitBatch_pargs"); + + xfer += oprot->writeFieldBegin("batch", ::apache::thrift::protocol::T_STRUCT, 1); + xfer += (*(this->batch)).write(oprot); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +void AgentClient::emitZipkinBatch(const std::vector< ::twitter::zipkin::thrift::Span> & spans) +{ + send_emitZipkinBatch(spans); +} + +void AgentClient::send_emitZipkinBatch(const std::vector< ::twitter::zipkin::thrift::Span> & spans) +{ + int32_t cseqid = 0; + oprot_->writeMessageBegin("emitZipkinBatch", ::apache::thrift::protocol::T_ONEWAY, cseqid); + + Agent_emitZipkinBatch_pargs args; + args.spans = &spans; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); +} + +void AgentClient::emitBatch(const ::jaegertracing::thrift::Batch& batch) +{ + send_emitBatch(batch); +} + +void AgentClient::send_emitBatch(const ::jaegertracing::thrift::Batch& batch) +{ + int32_t cseqid = 0; + oprot_->writeMessageBegin("emitBatch", ::apache::thrift::protocol::T_ONEWAY, cseqid); + + Agent_emitBatch_pargs args; + args.batch = &batch; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); +} + +bool AgentProcessor::dispatchCall(::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, const std::string& fname, int32_t seqid, void* callContext) { + ProcessMap::iterator pfn; + pfn = processMap_.find(fname); + if (pfn == processMap_.end()) { + iprot->skip(::apache::thrift::protocol::T_STRUCT); + iprot->readMessageEnd(); + iprot->getTransport()->readEnd(); + ::apache::thrift::TApplicationException x(::apache::thrift::TApplicationException::UNKNOWN_METHOD, "Invalid method name: '"+fname+"'"); + oprot->writeMessageBegin(fname, ::apache::thrift::protocol::T_EXCEPTION, seqid); + x.write(oprot); + oprot->writeMessageEnd(); + oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + return true; + } + (this->*(pfn->second))(seqid, iprot, oprot, callContext); + return true; +} + +void AgentProcessor::process_emitZipkinBatch(int32_t, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol*, void* callContext) +{ + void* ctx = nullptr; + if (this->eventHandler_.get() != nullptr) { + ctx = this->eventHandler_->getContext("Agent.emitZipkinBatch", callContext); + } + ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "Agent.emitZipkinBatch"); + + if (this->eventHandler_.get() != nullptr) { + this->eventHandler_->preRead(ctx, "Agent.emitZipkinBatch"); + } + + Agent_emitZipkinBatch_args args; + args.read(iprot); + iprot->readMessageEnd(); + uint32_t bytes = iprot->getTransport()->readEnd(); + + if (this->eventHandler_.get() != nullptr) { + this->eventHandler_->postRead(ctx, "Agent.emitZipkinBatch", bytes); + } + + try { + iface_->emitZipkinBatch(args.spans); + } catch (const std::exception&) { + if (this->eventHandler_.get() != nullptr) { + this->eventHandler_->handlerError(ctx, "Agent.emitZipkinBatch"); + } + return; + } + + if (this->eventHandler_.get() != nullptr) { + this->eventHandler_->asyncComplete(ctx, "Agent.emitZipkinBatch"); + } + + return; +} + +void AgentProcessor::process_emitBatch(int32_t, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol*, void* callContext) +{ + void* ctx = nullptr; + if (this->eventHandler_.get() != nullptr) { + ctx = this->eventHandler_->getContext("Agent.emitBatch", callContext); + } + ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "Agent.emitBatch"); + + if (this->eventHandler_.get() != nullptr) { + this->eventHandler_->preRead(ctx, "Agent.emitBatch"); + } + + Agent_emitBatch_args args; + args.read(iprot); + iprot->readMessageEnd(); + uint32_t bytes = iprot->getTransport()->readEnd(); + + if (this->eventHandler_.get() != nullptr) { + this->eventHandler_->postRead(ctx, "Agent.emitBatch", bytes); + } + + try { + iface_->emitBatch(args.batch); + } catch (const std::exception&) { + if (this->eventHandler_.get() != nullptr) { + this->eventHandler_->handlerError(ctx, "Agent.emitBatch"); + } + return; + } + + if (this->eventHandler_.get() != nullptr) { + this->eventHandler_->asyncComplete(ctx, "Agent.emitBatch"); + } + + return; +} + +::std::shared_ptr< ::apache::thrift::TProcessor > AgentProcessorFactory::getProcessor(const ::apache::thrift::TConnectionInfo& connInfo) { + ::apache::thrift::ReleaseHandler< AgentIfFactory > cleanup(handlerFactory_); + ::std::shared_ptr< AgentIf > handler(handlerFactory_->getHandler(connInfo), cleanup); + ::std::shared_ptr< ::apache::thrift::TProcessor > processor(new AgentProcessor(handler)); + return processor; +} + +void AgentConcurrentClient::emitZipkinBatch(const std::vector< ::twitter::zipkin::thrift::Span> & spans) +{ + send_emitZipkinBatch(spans); +} + +void AgentConcurrentClient::send_emitZipkinBatch(const std::vector< ::twitter::zipkin::thrift::Span> & spans) +{ + int32_t cseqid = 0; + ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get()); + oprot_->writeMessageBegin("emitZipkinBatch", ::apache::thrift::protocol::T_ONEWAY, cseqid); + + Agent_emitZipkinBatch_pargs args; + args.spans = &spans; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); + + sentry.commit(); +} + +void AgentConcurrentClient::emitBatch(const ::jaegertracing::thrift::Batch& batch) +{ + send_emitBatch(batch); +} + +void AgentConcurrentClient::send_emitBatch(const ::jaegertracing::thrift::Batch& batch) +{ + int32_t cseqid = 0; + ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get()); + oprot_->writeMessageBegin("emitBatch", ::apache::thrift::protocol::T_ONEWAY, cseqid); + + Agent_emitBatch_pargs args; + args.batch = &batch; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); + + sentry.commit(); +} + +}}} // namespace + diff --git a/exporters/jaeger/thrift-gen/Agent.h b/exporters/jaeger/thrift-gen/Agent.h new file mode 100644 index 0000000000..49abaf54a9 --- /dev/null +++ b/exporters/jaeger/thrift-gen/Agent.h @@ -0,0 +1,309 @@ +/** + * Autogenerated by Thrift Compiler (0.14.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +#ifndef Agent_H +#define Agent_H + +#include +#include +#include +#include "agent_types.h" + +namespace jaegertracing { namespace agent { namespace thrift { + +#ifdef _MSC_VER + #pragma warning( push ) + #pragma warning (disable : 4250 ) //inheriting methods via dominance +#endif + +class AgentIf { + public: + virtual ~AgentIf() {} + virtual void emitZipkinBatch(const std::vector< ::twitter::zipkin::thrift::Span> & spans) = 0; + virtual void emitBatch(const ::jaegertracing::thrift::Batch& batch) = 0; +}; + +class AgentIfFactory { + public: + typedef AgentIf Handler; + + virtual ~AgentIfFactory() {} + + virtual AgentIf* getHandler(const ::apache::thrift::TConnectionInfo& connInfo) = 0; + virtual void releaseHandler(AgentIf* /* handler */) = 0; +}; + +class AgentIfSingletonFactory : virtual public AgentIfFactory { + public: + AgentIfSingletonFactory(const ::std::shared_ptr& iface) : iface_(iface) {} + virtual ~AgentIfSingletonFactory() {} + + virtual AgentIf* getHandler(const ::apache::thrift::TConnectionInfo&) { + return iface_.get(); + } + virtual void releaseHandler(AgentIf* /* handler */) {} + + protected: + ::std::shared_ptr iface_; +}; + +class AgentNull : virtual public AgentIf { + public: + virtual ~AgentNull() {} + void emitZipkinBatch(const std::vector< ::twitter::zipkin::thrift::Span> & /* spans */) { + return; + } + void emitBatch(const ::jaegertracing::thrift::Batch& /* batch */) { + return; + } +}; + +typedef struct _Agent_emitZipkinBatch_args__isset { + _Agent_emitZipkinBatch_args__isset() : spans(false) {} + bool spans :1; +} _Agent_emitZipkinBatch_args__isset; + +class Agent_emitZipkinBatch_args { + public: + + Agent_emitZipkinBatch_args(const Agent_emitZipkinBatch_args&); + Agent_emitZipkinBatch_args& operator=(const Agent_emitZipkinBatch_args&); + Agent_emitZipkinBatch_args() { + } + + virtual ~Agent_emitZipkinBatch_args() noexcept; + std::vector< ::twitter::zipkin::thrift::Span> spans; + + _Agent_emitZipkinBatch_args__isset __isset; + + void __set_spans(const std::vector< ::twitter::zipkin::thrift::Span> & val); + + bool operator == (const Agent_emitZipkinBatch_args & rhs) const + { + if (!(spans == rhs.spans)) + return false; + return true; + } + bool operator != (const Agent_emitZipkinBatch_args &rhs) const { + return !(*this == rhs); + } + + bool operator < (const Agent_emitZipkinBatch_args & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + + +class Agent_emitZipkinBatch_pargs { + public: + + + virtual ~Agent_emitZipkinBatch_pargs() noexcept; + const std::vector< ::twitter::zipkin::thrift::Span> * spans; + + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _Agent_emitBatch_args__isset { + _Agent_emitBatch_args__isset() : batch(false) {} + bool batch :1; +} _Agent_emitBatch_args__isset; + +class Agent_emitBatch_args { + public: + + Agent_emitBatch_args(const Agent_emitBatch_args&); + Agent_emitBatch_args& operator=(const Agent_emitBatch_args&); + Agent_emitBatch_args() { + } + + virtual ~Agent_emitBatch_args() noexcept; + ::jaegertracing::thrift::Batch batch; + + _Agent_emitBatch_args__isset __isset; + + void __set_batch(const ::jaegertracing::thrift::Batch& val); + + bool operator == (const Agent_emitBatch_args & rhs) const + { + if (!(batch == rhs.batch)) + return false; + return true; + } + bool operator != (const Agent_emitBatch_args &rhs) const { + return !(*this == rhs); + } + + bool operator < (const Agent_emitBatch_args & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + + +class Agent_emitBatch_pargs { + public: + + + virtual ~Agent_emitBatch_pargs() noexcept; + const ::jaegertracing::thrift::Batch* batch; + + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +class AgentClient : virtual public AgentIf { + public: + AgentClient(std::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) { + setProtocol(prot); + } + AgentClient(std::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, std::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) { + setProtocol(iprot,oprot); + } + private: + void setProtocol(std::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) { + setProtocol(prot,prot); + } + void setProtocol(std::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, std::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) { + piprot_=iprot; + poprot_=oprot; + iprot_ = iprot.get(); + oprot_ = oprot.get(); + } + public: + std::shared_ptr< ::apache::thrift::protocol::TProtocol> getInputProtocol() { + return piprot_; + } + std::shared_ptr< ::apache::thrift::protocol::TProtocol> getOutputProtocol() { + return poprot_; + } + void emitZipkinBatch(const std::vector< ::twitter::zipkin::thrift::Span> & spans); + void send_emitZipkinBatch(const std::vector< ::twitter::zipkin::thrift::Span> & spans); + void emitBatch(const ::jaegertracing::thrift::Batch& batch); + void send_emitBatch(const ::jaegertracing::thrift::Batch& batch); + protected: + std::shared_ptr< ::apache::thrift::protocol::TProtocol> piprot_; + std::shared_ptr< ::apache::thrift::protocol::TProtocol> poprot_; + ::apache::thrift::protocol::TProtocol* iprot_; + ::apache::thrift::protocol::TProtocol* oprot_; +}; + +class AgentProcessor : public ::apache::thrift::TDispatchProcessor { + protected: + ::std::shared_ptr iface_; + virtual bool dispatchCall(::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, const std::string& fname, int32_t seqid, void* callContext); + private: + typedef void (AgentProcessor::*ProcessFunction)(int32_t, ::apache::thrift::protocol::TProtocol*, ::apache::thrift::protocol::TProtocol*, void*); + typedef std::map ProcessMap; + ProcessMap processMap_; + void process_emitZipkinBatch(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); + void process_emitBatch(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); + public: + AgentProcessor(::std::shared_ptr iface) : + iface_(iface) { + processMap_["emitZipkinBatch"] = &AgentProcessor::process_emitZipkinBatch; + processMap_["emitBatch"] = &AgentProcessor::process_emitBatch; + } + + virtual ~AgentProcessor() {} +}; + +class AgentProcessorFactory : public ::apache::thrift::TProcessorFactory { + public: + AgentProcessorFactory(const ::std::shared_ptr< AgentIfFactory >& handlerFactory) : + handlerFactory_(handlerFactory) {} + + ::std::shared_ptr< ::apache::thrift::TProcessor > getProcessor(const ::apache::thrift::TConnectionInfo& connInfo); + + protected: + ::std::shared_ptr< AgentIfFactory > handlerFactory_; +}; + +class AgentMultiface : virtual public AgentIf { + public: + AgentMultiface(std::vector >& ifaces) : ifaces_(ifaces) { + } + virtual ~AgentMultiface() {} + protected: + std::vector > ifaces_; + AgentMultiface() {} + void add(::std::shared_ptr iface) { + ifaces_.push_back(iface); + } + public: + void emitZipkinBatch(const std::vector< ::twitter::zipkin::thrift::Span> & spans) { + size_t sz = ifaces_.size(); + size_t i = 0; + for (; i < (sz - 1); ++i) { + ifaces_[i]->emitZipkinBatch(spans); + } + ifaces_[i]->emitZipkinBatch(spans); + } + + void emitBatch(const ::jaegertracing::thrift::Batch& batch) { + size_t sz = ifaces_.size(); + size_t i = 0; + for (; i < (sz - 1); ++i) { + ifaces_[i]->emitBatch(batch); + } + ifaces_[i]->emitBatch(batch); + } + +}; + +// The 'concurrent' client is a thread safe client that correctly handles +// out of order responses. It is slower than the regular client, so should +// only be used when you need to share a connection among multiple threads +class AgentConcurrentClient : virtual public AgentIf { + public: + AgentConcurrentClient(std::shared_ptr< ::apache::thrift::protocol::TProtocol> prot, std::shared_ptr<::apache::thrift::async::TConcurrentClientSyncInfo> sync) : sync_(sync) +{ + setProtocol(prot); + } + AgentConcurrentClient(std::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, std::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot, std::shared_ptr<::apache::thrift::async::TConcurrentClientSyncInfo> sync) : sync_(sync) +{ + setProtocol(iprot,oprot); + } + private: + void setProtocol(std::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) { + setProtocol(prot,prot); + } + void setProtocol(std::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, std::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) { + piprot_=iprot; + poprot_=oprot; + iprot_ = iprot.get(); + oprot_ = oprot.get(); + } + public: + std::shared_ptr< ::apache::thrift::protocol::TProtocol> getInputProtocol() { + return piprot_; + } + std::shared_ptr< ::apache::thrift::protocol::TProtocol> getOutputProtocol() { + return poprot_; + } + void emitZipkinBatch(const std::vector< ::twitter::zipkin::thrift::Span> & spans); + void send_emitZipkinBatch(const std::vector< ::twitter::zipkin::thrift::Span> & spans); + void emitBatch(const ::jaegertracing::thrift::Batch& batch); + void send_emitBatch(const ::jaegertracing::thrift::Batch& batch); + protected: + std::shared_ptr< ::apache::thrift::protocol::TProtocol> piprot_; + std::shared_ptr< ::apache::thrift::protocol::TProtocol> poprot_; + ::apache::thrift::protocol::TProtocol* iprot_; + ::apache::thrift::protocol::TProtocol* oprot_; + std::shared_ptr<::apache::thrift::async::TConcurrentClientSyncInfo> sync_; +}; + +#ifdef _MSC_VER + #pragma warning( pop ) +#endif + +}}} // namespace + +#endif diff --git a/exporters/jaeger/thrift-gen/Agent_server.skeleton.cpp b/exporters/jaeger/thrift-gen/Agent_server.skeleton.cpp new file mode 100644 index 0000000000..60fdd94360 --- /dev/null +++ b/exporters/jaeger/thrift-gen/Agent_server.skeleton.cpp @@ -0,0 +1,47 @@ +// This autogenerated skeleton file illustrates how to build a server. +// You should copy it to another filename to avoid overwriting it. + +#include "Agent.h" +#include +#include +#include +#include + +using namespace ::apache::thrift; +using namespace ::apache::thrift::protocol; +using namespace ::apache::thrift::transport; +using namespace ::apache::thrift::server; + +using namespace ::jaegertracing::agent::thrift; + +class AgentHandler : virtual public AgentIf { + public: + AgentHandler() { + // Your initialization goes here + } + + void emitZipkinBatch(const std::vector< ::twitter::zipkin::thrift::Span> & spans) { + // Your implementation goes here + printf("emitZipkinBatch\n"); + } + + void emitBatch(const ::jaegertracing::thrift::Batch& batch) { + // Your implementation goes here + printf("emitBatch\n"); + } + +}; + +int main(int argc, char **argv) { + int port = 9090; + ::std::shared_ptr handler(new AgentHandler()); + ::std::shared_ptr processor(new AgentProcessor(handler)); + ::std::shared_ptr serverTransport(new TServerSocket(port)); + ::std::shared_ptr transportFactory(new TBufferedTransportFactory()); + ::std::shared_ptr protocolFactory(new TBinaryProtocolFactory()); + + TSimpleServer server(processor, serverTransport, transportFactory, protocolFactory); + server.serve(); + return 0; +} + diff --git a/exporters/jaeger/thrift-gen/Collector.cpp b/exporters/jaeger/thrift-gen/Collector.cpp new file mode 100644 index 0000000000..f96b40f20a --- /dev/null +++ b/exporters/jaeger/thrift-gen/Collector.cpp @@ -0,0 +1,481 @@ +/** + * Autogenerated by Thrift Compiler (0.14.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +#include "Collector.h" + +namespace jaegertracing { namespace thrift { + + +Collector_submitBatches_args::~Collector_submitBatches_args() noexcept { +} + + +uint32_t Collector_submitBatches_args::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + this->batches.clear(); + uint32_t _size52; + ::apache::thrift::protocol::TType _etype55; + xfer += iprot->readListBegin(_etype55, _size52); + this->batches.resize(_size52); + uint32_t _i56; + for (_i56 = 0; _i56 < _size52; ++_i56) + { + xfer += this->batches[_i56].read(iprot); + } + xfer += iprot->readListEnd(); + } + this->__isset.batches = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t Collector_submitBatches_args::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("Collector_submitBatches_args"); + + xfer += oprot->writeFieldBegin("batches", ::apache::thrift::protocol::T_LIST, 1); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->batches.size())); + std::vector ::const_iterator _iter57; + for (_iter57 = this->batches.begin(); _iter57 != this->batches.end(); ++_iter57) + { + xfer += (*_iter57).write(oprot); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +Collector_submitBatches_pargs::~Collector_submitBatches_pargs() noexcept { +} + + +uint32_t Collector_submitBatches_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("Collector_submitBatches_pargs"); + + xfer += oprot->writeFieldBegin("batches", ::apache::thrift::protocol::T_LIST, 1); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast((*(this->batches)).size())); + std::vector ::const_iterator _iter58; + for (_iter58 = (*(this->batches)).begin(); _iter58 != (*(this->batches)).end(); ++_iter58) + { + xfer += (*_iter58).write(oprot); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +Collector_submitBatches_result::~Collector_submitBatches_result() noexcept { +} + + +uint32_t Collector_submitBatches_result::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 0: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + this->success.clear(); + uint32_t _size59; + ::apache::thrift::protocol::TType _etype62; + xfer += iprot->readListBegin(_etype62, _size59); + this->success.resize(_size59); + uint32_t _i63; + for (_i63 = 0; _i63 < _size59; ++_i63) + { + xfer += this->success[_i63].read(iprot); + } + xfer += iprot->readListEnd(); + } + this->__isset.success = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t Collector_submitBatches_result::write(::apache::thrift::protocol::TProtocol* oprot) const { + + uint32_t xfer = 0; + + xfer += oprot->writeStructBegin("Collector_submitBatches_result"); + + if (this->__isset.success) { + xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->success.size())); + std::vector ::const_iterator _iter64; + for (_iter64 = this->success.begin(); _iter64 != this->success.end(); ++_iter64) + { + xfer += (*_iter64).write(oprot); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + } + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +Collector_submitBatches_presult::~Collector_submitBatches_presult() noexcept { +} + + +uint32_t Collector_submitBatches_presult::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 0: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + (*(this->success)).clear(); + uint32_t _size65; + ::apache::thrift::protocol::TType _etype68; + xfer += iprot->readListBegin(_etype68, _size65); + (*(this->success)).resize(_size65); + uint32_t _i69; + for (_i69 = 0; _i69 < _size65; ++_i69) + { + xfer += (*(this->success))[_i69].read(iprot); + } + xfer += iprot->readListEnd(); + } + this->__isset.success = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +void CollectorClient::submitBatches(std::vector & _return, const std::vector & batches) +{ + send_submitBatches(batches); + recv_submitBatches(_return); +} + +void CollectorClient::send_submitBatches(const std::vector & batches) +{ + int32_t cseqid = 0; + oprot_->writeMessageBegin("submitBatches", ::apache::thrift::protocol::T_CALL, cseqid); + + Collector_submitBatches_pargs args; + args.batches = &batches; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); +} + +void CollectorClient::recv_submitBatches(std::vector & _return) +{ + + int32_t rseqid = 0; + std::string fname; + ::apache::thrift::protocol::TMessageType mtype; + + iprot_->readMessageBegin(fname, mtype, rseqid); + if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { + ::apache::thrift::TApplicationException x; + x.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + throw x; + } + if (mtype != ::apache::thrift::protocol::T_REPLY) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + if (fname.compare("submitBatches") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + Collector_submitBatches_presult result; + result.success = &_return; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.success) { + // _return pointer has now been filled + return; + } + throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "submitBatches failed: unknown result"); +} + +bool CollectorProcessor::dispatchCall(::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, const std::string& fname, int32_t seqid, void* callContext) { + ProcessMap::iterator pfn; + pfn = processMap_.find(fname); + if (pfn == processMap_.end()) { + iprot->skip(::apache::thrift::protocol::T_STRUCT); + iprot->readMessageEnd(); + iprot->getTransport()->readEnd(); + ::apache::thrift::TApplicationException x(::apache::thrift::TApplicationException::UNKNOWN_METHOD, "Invalid method name: '"+fname+"'"); + oprot->writeMessageBegin(fname, ::apache::thrift::protocol::T_EXCEPTION, seqid); + x.write(oprot); + oprot->writeMessageEnd(); + oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + return true; + } + (this->*(pfn->second))(seqid, iprot, oprot, callContext); + return true; +} + +void CollectorProcessor::process_submitBatches(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) +{ + void* ctx = nullptr; + if (this->eventHandler_.get() != nullptr) { + ctx = this->eventHandler_->getContext("Collector.submitBatches", callContext); + } + ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "Collector.submitBatches"); + + if (this->eventHandler_.get() != nullptr) { + this->eventHandler_->preRead(ctx, "Collector.submitBatches"); + } + + Collector_submitBatches_args args; + args.read(iprot); + iprot->readMessageEnd(); + uint32_t bytes = iprot->getTransport()->readEnd(); + + if (this->eventHandler_.get() != nullptr) { + this->eventHandler_->postRead(ctx, "Collector.submitBatches", bytes); + } + + Collector_submitBatches_result result; + try { + iface_->submitBatches(result.success, args.batches); + result.__isset.success = true; + } catch (const std::exception& e) { + if (this->eventHandler_.get() != nullptr) { + this->eventHandler_->handlerError(ctx, "Collector.submitBatches"); + } + + ::apache::thrift::TApplicationException x(e.what()); + oprot->writeMessageBegin("submitBatches", ::apache::thrift::protocol::T_EXCEPTION, seqid); + x.write(oprot); + oprot->writeMessageEnd(); + oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + return; + } + + if (this->eventHandler_.get() != nullptr) { + this->eventHandler_->preWrite(ctx, "Collector.submitBatches"); + } + + oprot->writeMessageBegin("submitBatches", ::apache::thrift::protocol::T_REPLY, seqid); + result.write(oprot); + oprot->writeMessageEnd(); + bytes = oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + + if (this->eventHandler_.get() != nullptr) { + this->eventHandler_->postWrite(ctx, "Collector.submitBatches", bytes); + } +} + +::std::shared_ptr< ::apache::thrift::TProcessor > CollectorProcessorFactory::getProcessor(const ::apache::thrift::TConnectionInfo& connInfo) { + ::apache::thrift::ReleaseHandler< CollectorIfFactory > cleanup(handlerFactory_); + ::std::shared_ptr< CollectorIf > handler(handlerFactory_->getHandler(connInfo), cleanup); + ::std::shared_ptr< ::apache::thrift::TProcessor > processor(new CollectorProcessor(handler)); + return processor; +} + +void CollectorConcurrentClient::submitBatches(std::vector & _return, const std::vector & batches) +{ + int32_t seqid = send_submitBatches(batches); + recv_submitBatches(_return, seqid); +} + +int32_t CollectorConcurrentClient::send_submitBatches(const std::vector & batches) +{ + int32_t cseqid = this->sync_->generateSeqId(); + ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get()); + oprot_->writeMessageBegin("submitBatches", ::apache::thrift::protocol::T_CALL, cseqid); + + Collector_submitBatches_pargs args; + args.batches = &batches; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); + + sentry.commit(); + return cseqid; +} + +void CollectorConcurrentClient::recv_submitBatches(std::vector & _return, const int32_t seqid) +{ + + int32_t rseqid = 0; + std::string fname; + ::apache::thrift::protocol::TMessageType mtype; + + // the read mutex gets dropped and reacquired as part of waitForWork() + // The destructor of this sentry wakes up other clients + ::apache::thrift::async::TConcurrentRecvSentry sentry(this->sync_.get(), seqid); + + while(true) { + if(!this->sync_->getPending(fname, mtype, rseqid)) { + iprot_->readMessageBegin(fname, mtype, rseqid); + } + if(seqid == rseqid) { + if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { + ::apache::thrift::TApplicationException x; + x.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + sentry.commit(); + throw x; + } + if (mtype != ::apache::thrift::protocol::T_REPLY) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + if (fname.compare("submitBatches") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + // in a bad state, don't commit + using ::apache::thrift::protocol::TProtocolException; + throw TProtocolException(TProtocolException::INVALID_DATA); + } + Collector_submitBatches_presult result; + result.success = &_return; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.success) { + // _return pointer has now been filled + sentry.commit(); + return; + } + // in a bad state, don't commit + throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "submitBatches failed: unknown result"); + } + // seqid != rseqid + this->sync_->updatePending(fname, mtype, rseqid); + + // this will temporarily unlock the readMutex, and let other clients get work done + this->sync_->waitForWork(seqid); + } // end while(true) +} + +}} // namespace + diff --git a/exporters/jaeger/thrift-gen/Collector.h b/exporters/jaeger/thrift-gen/Collector.h new file mode 100644 index 0000000000..75daa69a75 --- /dev/null +++ b/exporters/jaeger/thrift-gen/Collector.h @@ -0,0 +1,299 @@ +/** + * Autogenerated by Thrift Compiler (0.14.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +#ifndef Collector_H +#define Collector_H + +#include +#include +#include +#include "jaeger_types.h" + +namespace jaegertracing { namespace thrift { + +#ifdef _MSC_VER + #pragma warning( push ) + #pragma warning (disable : 4250 ) //inheriting methods via dominance +#endif + +class CollectorIf { + public: + virtual ~CollectorIf() {} + virtual void submitBatches(std::vector & _return, const std::vector & batches) = 0; +}; + +class CollectorIfFactory { + public: + typedef CollectorIf Handler; + + virtual ~CollectorIfFactory() {} + + virtual CollectorIf* getHandler(const ::apache::thrift::TConnectionInfo& connInfo) = 0; + virtual void releaseHandler(CollectorIf* /* handler */) = 0; +}; + +class CollectorIfSingletonFactory : virtual public CollectorIfFactory { + public: + CollectorIfSingletonFactory(const ::std::shared_ptr& iface) : iface_(iface) {} + virtual ~CollectorIfSingletonFactory() {} + + virtual CollectorIf* getHandler(const ::apache::thrift::TConnectionInfo&) { + return iface_.get(); + } + virtual void releaseHandler(CollectorIf* /* handler */) {} + + protected: + ::std::shared_ptr iface_; +}; + +class CollectorNull : virtual public CollectorIf { + public: + virtual ~CollectorNull() {} + void submitBatches(std::vector & /* _return */, const std::vector & /* batches */) { + return; + } +}; + +typedef struct _Collector_submitBatches_args__isset { + _Collector_submitBatches_args__isset() : batches(false) {} + bool batches :1; +} _Collector_submitBatches_args__isset; + +class Collector_submitBatches_args { + public: + + Collector_submitBatches_args(const Collector_submitBatches_args&); + Collector_submitBatches_args& operator=(const Collector_submitBatches_args&); + Collector_submitBatches_args() { + } + + virtual ~Collector_submitBatches_args() noexcept; + std::vector batches; + + _Collector_submitBatches_args__isset __isset; + + void __set_batches(const std::vector & val); + + bool operator == (const Collector_submitBatches_args & rhs) const + { + if (!(batches == rhs.batches)) + return false; + return true; + } + bool operator != (const Collector_submitBatches_args &rhs) const { + return !(*this == rhs); + } + + bool operator < (const Collector_submitBatches_args & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + + +class Collector_submitBatches_pargs { + public: + + + virtual ~Collector_submitBatches_pargs() noexcept; + const std::vector * batches; + + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _Collector_submitBatches_result__isset { + _Collector_submitBatches_result__isset() : success(false) {} + bool success :1; +} _Collector_submitBatches_result__isset; + +class Collector_submitBatches_result { + public: + + Collector_submitBatches_result(const Collector_submitBatches_result&); + Collector_submitBatches_result& operator=(const Collector_submitBatches_result&); + Collector_submitBatches_result() { + } + + virtual ~Collector_submitBatches_result() noexcept; + std::vector success; + + _Collector_submitBatches_result__isset __isset; + + void __set_success(const std::vector & val); + + bool operator == (const Collector_submitBatches_result & rhs) const + { + if (!(success == rhs.success)) + return false; + return true; + } + bool operator != (const Collector_submitBatches_result &rhs) const { + return !(*this == rhs); + } + + bool operator < (const Collector_submitBatches_result & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _Collector_submitBatches_presult__isset { + _Collector_submitBatches_presult__isset() : success(false) {} + bool success :1; +} _Collector_submitBatches_presult__isset; + +class Collector_submitBatches_presult { + public: + + + virtual ~Collector_submitBatches_presult() noexcept; + std::vector * success; + + _Collector_submitBatches_presult__isset __isset; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + +}; + +class CollectorClient : virtual public CollectorIf { + public: + CollectorClient(std::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) { + setProtocol(prot); + } + CollectorClient(std::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, std::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) { + setProtocol(iprot,oprot); + } + private: + void setProtocol(std::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) { + setProtocol(prot,prot); + } + void setProtocol(std::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, std::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) { + piprot_=iprot; + poprot_=oprot; + iprot_ = iprot.get(); + oprot_ = oprot.get(); + } + public: + std::shared_ptr< ::apache::thrift::protocol::TProtocol> getInputProtocol() { + return piprot_; + } + std::shared_ptr< ::apache::thrift::protocol::TProtocol> getOutputProtocol() { + return poprot_; + } + void submitBatches(std::vector & _return, const std::vector & batches); + void send_submitBatches(const std::vector & batches); + void recv_submitBatches(std::vector & _return); + protected: + std::shared_ptr< ::apache::thrift::protocol::TProtocol> piprot_; + std::shared_ptr< ::apache::thrift::protocol::TProtocol> poprot_; + ::apache::thrift::protocol::TProtocol* iprot_; + ::apache::thrift::protocol::TProtocol* oprot_; +}; + +class CollectorProcessor : public ::apache::thrift::TDispatchProcessor { + protected: + ::std::shared_ptr iface_; + virtual bool dispatchCall(::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, const std::string& fname, int32_t seqid, void* callContext); + private: + typedef void (CollectorProcessor::*ProcessFunction)(int32_t, ::apache::thrift::protocol::TProtocol*, ::apache::thrift::protocol::TProtocol*, void*); + typedef std::map ProcessMap; + ProcessMap processMap_; + void process_submitBatches(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); + public: + CollectorProcessor(::std::shared_ptr iface) : + iface_(iface) { + processMap_["submitBatches"] = &CollectorProcessor::process_submitBatches; + } + + virtual ~CollectorProcessor() {} +}; + +class CollectorProcessorFactory : public ::apache::thrift::TProcessorFactory { + public: + CollectorProcessorFactory(const ::std::shared_ptr< CollectorIfFactory >& handlerFactory) : + handlerFactory_(handlerFactory) {} + + ::std::shared_ptr< ::apache::thrift::TProcessor > getProcessor(const ::apache::thrift::TConnectionInfo& connInfo); + + protected: + ::std::shared_ptr< CollectorIfFactory > handlerFactory_; +}; + +class CollectorMultiface : virtual public CollectorIf { + public: + CollectorMultiface(std::vector >& ifaces) : ifaces_(ifaces) { + } + virtual ~CollectorMultiface() {} + protected: + std::vector > ifaces_; + CollectorMultiface() {} + void add(::std::shared_ptr iface) { + ifaces_.push_back(iface); + } + public: + void submitBatches(std::vector & _return, const std::vector & batches) { + size_t sz = ifaces_.size(); + size_t i = 0; + for (; i < (sz - 1); ++i) { + ifaces_[i]->submitBatches(_return, batches); + } + ifaces_[i]->submitBatches(_return, batches); + return; + } + +}; + +// The 'concurrent' client is a thread safe client that correctly handles +// out of order responses. It is slower than the regular client, so should +// only be used when you need to share a connection among multiple threads +class CollectorConcurrentClient : virtual public CollectorIf { + public: + CollectorConcurrentClient(std::shared_ptr< ::apache::thrift::protocol::TProtocol> prot, std::shared_ptr<::apache::thrift::async::TConcurrentClientSyncInfo> sync) : sync_(sync) +{ + setProtocol(prot); + } + CollectorConcurrentClient(std::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, std::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot, std::shared_ptr<::apache::thrift::async::TConcurrentClientSyncInfo> sync) : sync_(sync) +{ + setProtocol(iprot,oprot); + } + private: + void setProtocol(std::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) { + setProtocol(prot,prot); + } + void setProtocol(std::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, std::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) { + piprot_=iprot; + poprot_=oprot; + iprot_ = iprot.get(); + oprot_ = oprot.get(); + } + public: + std::shared_ptr< ::apache::thrift::protocol::TProtocol> getInputProtocol() { + return piprot_; + } + std::shared_ptr< ::apache::thrift::protocol::TProtocol> getOutputProtocol() { + return poprot_; + } + void submitBatches(std::vector & _return, const std::vector & batches); + int32_t send_submitBatches(const std::vector & batches); + void recv_submitBatches(std::vector & _return, const int32_t seqid); + protected: + std::shared_ptr< ::apache::thrift::protocol::TProtocol> piprot_; + std::shared_ptr< ::apache::thrift::protocol::TProtocol> poprot_; + ::apache::thrift::protocol::TProtocol* iprot_; + ::apache::thrift::protocol::TProtocol* oprot_; + std::shared_ptr<::apache::thrift::async::TConcurrentClientSyncInfo> sync_; +}; + +#ifdef _MSC_VER + #pragma warning( pop ) +#endif + +}} // namespace + +#endif diff --git a/exporters/jaeger/thrift-gen/Collector_server.skeleton.cpp b/exporters/jaeger/thrift-gen/Collector_server.skeleton.cpp new file mode 100644 index 0000000000..c59c8aa49a --- /dev/null +++ b/exporters/jaeger/thrift-gen/Collector_server.skeleton.cpp @@ -0,0 +1,42 @@ +// This autogenerated skeleton file illustrates how to build a server. +// You should copy it to another filename to avoid overwriting it. + +#include "Collector.h" +#include +#include +#include +#include + +using namespace ::apache::thrift; +using namespace ::apache::thrift::protocol; +using namespace ::apache::thrift::transport; +using namespace ::apache::thrift::server; + +using namespace ::jaegertracing::thrift; + +class CollectorHandler : virtual public CollectorIf { + public: + CollectorHandler() { + // Your initialization goes here + } + + void submitBatches(std::vector & _return, const std::vector & batches) { + // Your implementation goes here + printf("submitBatches\n"); + } + +}; + +int main(int argc, char **argv) { + int port = 9090; + ::std::shared_ptr handler(new CollectorHandler()); + ::std::shared_ptr processor(new CollectorProcessor(handler)); + ::std::shared_ptr serverTransport(new TServerSocket(port)); + ::std::shared_ptr transportFactory(new TBufferedTransportFactory()); + ::std::shared_ptr protocolFactory(new TBinaryProtocolFactory()); + + TSimpleServer server(processor, serverTransport, transportFactory, protocolFactory); + server.serve(); + return 0; +} + diff --git a/exporters/jaeger/thrift-gen/ZipkinCollector.cpp b/exporters/jaeger/thrift-gen/ZipkinCollector.cpp new file mode 100644 index 0000000000..42d813dfd4 --- /dev/null +++ b/exporters/jaeger/thrift-gen/ZipkinCollector.cpp @@ -0,0 +1,481 @@ +/** + * Autogenerated by Thrift Compiler (0.14.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +#include "ZipkinCollector.h" + +namespace twitter { namespace zipkin { namespace thrift { + + +ZipkinCollector_submitZipkinBatch_args::~ZipkinCollector_submitZipkinBatch_args() noexcept { +} + + +uint32_t ZipkinCollector_submitZipkinBatch_args::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + this->spans.clear(); + uint32_t _size23; + ::apache::thrift::protocol::TType _etype26; + xfer += iprot->readListBegin(_etype26, _size23); + this->spans.resize(_size23); + uint32_t _i27; + for (_i27 = 0; _i27 < _size23; ++_i27) + { + xfer += this->spans[_i27].read(iprot); + } + xfer += iprot->readListEnd(); + } + this->__isset.spans = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t ZipkinCollector_submitZipkinBatch_args::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("ZipkinCollector_submitZipkinBatch_args"); + + xfer += oprot->writeFieldBegin("spans", ::apache::thrift::protocol::T_LIST, 1); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->spans.size())); + std::vector ::const_iterator _iter28; + for (_iter28 = this->spans.begin(); _iter28 != this->spans.end(); ++_iter28) + { + xfer += (*_iter28).write(oprot); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +ZipkinCollector_submitZipkinBatch_pargs::~ZipkinCollector_submitZipkinBatch_pargs() noexcept { +} + + +uint32_t ZipkinCollector_submitZipkinBatch_pargs::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("ZipkinCollector_submitZipkinBatch_pargs"); + + xfer += oprot->writeFieldBegin("spans", ::apache::thrift::protocol::T_LIST, 1); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast((*(this->spans)).size())); + std::vector ::const_iterator _iter29; + for (_iter29 = (*(this->spans)).begin(); _iter29 != (*(this->spans)).end(); ++_iter29) + { + xfer += (*_iter29).write(oprot); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +ZipkinCollector_submitZipkinBatch_result::~ZipkinCollector_submitZipkinBatch_result() noexcept { +} + + +uint32_t ZipkinCollector_submitZipkinBatch_result::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 0: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + this->success.clear(); + uint32_t _size30; + ::apache::thrift::protocol::TType _etype33; + xfer += iprot->readListBegin(_etype33, _size30); + this->success.resize(_size30); + uint32_t _i34; + for (_i34 = 0; _i34 < _size30; ++_i34) + { + xfer += this->success[_i34].read(iprot); + } + xfer += iprot->readListEnd(); + } + this->__isset.success = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t ZipkinCollector_submitZipkinBatch_result::write(::apache::thrift::protocol::TProtocol* oprot) const { + + uint32_t xfer = 0; + + xfer += oprot->writeStructBegin("ZipkinCollector_submitZipkinBatch_result"); + + if (this->__isset.success) { + xfer += oprot->writeFieldBegin("success", ::apache::thrift::protocol::T_LIST, 0); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->success.size())); + std::vector ::const_iterator _iter35; + for (_iter35 = this->success.begin(); _iter35 != this->success.end(); ++_iter35) + { + xfer += (*_iter35).write(oprot); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + } + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + + +ZipkinCollector_submitZipkinBatch_presult::~ZipkinCollector_submitZipkinBatch_presult() noexcept { +} + + +uint32_t ZipkinCollector_submitZipkinBatch_presult::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 0: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + (*(this->success)).clear(); + uint32_t _size36; + ::apache::thrift::protocol::TType _etype39; + xfer += iprot->readListBegin(_etype39, _size36); + (*(this->success)).resize(_size36); + uint32_t _i40; + for (_i40 = 0; _i40 < _size36; ++_i40) + { + xfer += (*(this->success))[_i40].read(iprot); + } + xfer += iprot->readListEnd(); + } + this->__isset.success = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +void ZipkinCollectorClient::submitZipkinBatch(std::vector & _return, const std::vector & spans) +{ + send_submitZipkinBatch(spans); + recv_submitZipkinBatch(_return); +} + +void ZipkinCollectorClient::send_submitZipkinBatch(const std::vector & spans) +{ + int32_t cseqid = 0; + oprot_->writeMessageBegin("submitZipkinBatch", ::apache::thrift::protocol::T_CALL, cseqid); + + ZipkinCollector_submitZipkinBatch_pargs args; + args.spans = &spans; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); +} + +void ZipkinCollectorClient::recv_submitZipkinBatch(std::vector & _return) +{ + + int32_t rseqid = 0; + std::string fname; + ::apache::thrift::protocol::TMessageType mtype; + + iprot_->readMessageBegin(fname, mtype, rseqid); + if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { + ::apache::thrift::TApplicationException x; + x.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + throw x; + } + if (mtype != ::apache::thrift::protocol::T_REPLY) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + if (fname.compare("submitZipkinBatch") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + ZipkinCollector_submitZipkinBatch_presult result; + result.success = &_return; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.success) { + // _return pointer has now been filled + return; + } + throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "submitZipkinBatch failed: unknown result"); +} + +bool ZipkinCollectorProcessor::dispatchCall(::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, const std::string& fname, int32_t seqid, void* callContext) { + ProcessMap::iterator pfn; + pfn = processMap_.find(fname); + if (pfn == processMap_.end()) { + iprot->skip(::apache::thrift::protocol::T_STRUCT); + iprot->readMessageEnd(); + iprot->getTransport()->readEnd(); + ::apache::thrift::TApplicationException x(::apache::thrift::TApplicationException::UNKNOWN_METHOD, "Invalid method name: '"+fname+"'"); + oprot->writeMessageBegin(fname, ::apache::thrift::protocol::T_EXCEPTION, seqid); + x.write(oprot); + oprot->writeMessageEnd(); + oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + return true; + } + (this->*(pfn->second))(seqid, iprot, oprot, callContext); + return true; +} + +void ZipkinCollectorProcessor::process_submitZipkinBatch(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext) +{ + void* ctx = nullptr; + if (this->eventHandler_.get() != nullptr) { + ctx = this->eventHandler_->getContext("ZipkinCollector.submitZipkinBatch", callContext); + } + ::apache::thrift::TProcessorContextFreer freer(this->eventHandler_.get(), ctx, "ZipkinCollector.submitZipkinBatch"); + + if (this->eventHandler_.get() != nullptr) { + this->eventHandler_->preRead(ctx, "ZipkinCollector.submitZipkinBatch"); + } + + ZipkinCollector_submitZipkinBatch_args args; + args.read(iprot); + iprot->readMessageEnd(); + uint32_t bytes = iprot->getTransport()->readEnd(); + + if (this->eventHandler_.get() != nullptr) { + this->eventHandler_->postRead(ctx, "ZipkinCollector.submitZipkinBatch", bytes); + } + + ZipkinCollector_submitZipkinBatch_result result; + try { + iface_->submitZipkinBatch(result.success, args.spans); + result.__isset.success = true; + } catch (const std::exception& e) { + if (this->eventHandler_.get() != nullptr) { + this->eventHandler_->handlerError(ctx, "ZipkinCollector.submitZipkinBatch"); + } + + ::apache::thrift::TApplicationException x(e.what()); + oprot->writeMessageBegin("submitZipkinBatch", ::apache::thrift::protocol::T_EXCEPTION, seqid); + x.write(oprot); + oprot->writeMessageEnd(); + oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + return; + } + + if (this->eventHandler_.get() != nullptr) { + this->eventHandler_->preWrite(ctx, "ZipkinCollector.submitZipkinBatch"); + } + + oprot->writeMessageBegin("submitZipkinBatch", ::apache::thrift::protocol::T_REPLY, seqid); + result.write(oprot); + oprot->writeMessageEnd(); + bytes = oprot->getTransport()->writeEnd(); + oprot->getTransport()->flush(); + + if (this->eventHandler_.get() != nullptr) { + this->eventHandler_->postWrite(ctx, "ZipkinCollector.submitZipkinBatch", bytes); + } +} + +::std::shared_ptr< ::apache::thrift::TProcessor > ZipkinCollectorProcessorFactory::getProcessor(const ::apache::thrift::TConnectionInfo& connInfo) { + ::apache::thrift::ReleaseHandler< ZipkinCollectorIfFactory > cleanup(handlerFactory_); + ::std::shared_ptr< ZipkinCollectorIf > handler(handlerFactory_->getHandler(connInfo), cleanup); + ::std::shared_ptr< ::apache::thrift::TProcessor > processor(new ZipkinCollectorProcessor(handler)); + return processor; +} + +void ZipkinCollectorConcurrentClient::submitZipkinBatch(std::vector & _return, const std::vector & spans) +{ + int32_t seqid = send_submitZipkinBatch(spans); + recv_submitZipkinBatch(_return, seqid); +} + +int32_t ZipkinCollectorConcurrentClient::send_submitZipkinBatch(const std::vector & spans) +{ + int32_t cseqid = this->sync_->generateSeqId(); + ::apache::thrift::async::TConcurrentSendSentry sentry(this->sync_.get()); + oprot_->writeMessageBegin("submitZipkinBatch", ::apache::thrift::protocol::T_CALL, cseqid); + + ZipkinCollector_submitZipkinBatch_pargs args; + args.spans = &spans; + args.write(oprot_); + + oprot_->writeMessageEnd(); + oprot_->getTransport()->writeEnd(); + oprot_->getTransport()->flush(); + + sentry.commit(); + return cseqid; +} + +void ZipkinCollectorConcurrentClient::recv_submitZipkinBatch(std::vector & _return, const int32_t seqid) +{ + + int32_t rseqid = 0; + std::string fname; + ::apache::thrift::protocol::TMessageType mtype; + + // the read mutex gets dropped and reacquired as part of waitForWork() + // The destructor of this sentry wakes up other clients + ::apache::thrift::async::TConcurrentRecvSentry sentry(this->sync_.get(), seqid); + + while(true) { + if(!this->sync_->getPending(fname, mtype, rseqid)) { + iprot_->readMessageBegin(fname, mtype, rseqid); + } + if(seqid == rseqid) { + if (mtype == ::apache::thrift::protocol::T_EXCEPTION) { + ::apache::thrift::TApplicationException x; + x.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + sentry.commit(); + throw x; + } + if (mtype != ::apache::thrift::protocol::T_REPLY) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + } + if (fname.compare("submitZipkinBatch") != 0) { + iprot_->skip(::apache::thrift::protocol::T_STRUCT); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + // in a bad state, don't commit + using ::apache::thrift::protocol::TProtocolException; + throw TProtocolException(TProtocolException::INVALID_DATA); + } + ZipkinCollector_submitZipkinBatch_presult result; + result.success = &_return; + result.read(iprot_); + iprot_->readMessageEnd(); + iprot_->getTransport()->readEnd(); + + if (result.__isset.success) { + // _return pointer has now been filled + sentry.commit(); + return; + } + // in a bad state, don't commit + throw ::apache::thrift::TApplicationException(::apache::thrift::TApplicationException::MISSING_RESULT, "submitZipkinBatch failed: unknown result"); + } + // seqid != rseqid + this->sync_->updatePending(fname, mtype, rseqid); + + // this will temporarily unlock the readMutex, and let other clients get work done + this->sync_->waitForWork(seqid); + } // end while(true) +} + +}}} // namespace + diff --git a/exporters/jaeger/thrift-gen/ZipkinCollector.h b/exporters/jaeger/thrift-gen/ZipkinCollector.h new file mode 100644 index 0000000000..97e111d249 --- /dev/null +++ b/exporters/jaeger/thrift-gen/ZipkinCollector.h @@ -0,0 +1,299 @@ +/** + * Autogenerated by Thrift Compiler (0.14.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +#ifndef ZipkinCollector_H +#define ZipkinCollector_H + +#include +#include +#include +#include "zipkincore_types.h" + +namespace twitter { namespace zipkin { namespace thrift { + +#ifdef _MSC_VER + #pragma warning( push ) + #pragma warning (disable : 4250 ) //inheriting methods via dominance +#endif + +class ZipkinCollectorIf { + public: + virtual ~ZipkinCollectorIf() {} + virtual void submitZipkinBatch(std::vector & _return, const std::vector & spans) = 0; +}; + +class ZipkinCollectorIfFactory { + public: + typedef ZipkinCollectorIf Handler; + + virtual ~ZipkinCollectorIfFactory() {} + + virtual ZipkinCollectorIf* getHandler(const ::apache::thrift::TConnectionInfo& connInfo) = 0; + virtual void releaseHandler(ZipkinCollectorIf* /* handler */) = 0; +}; + +class ZipkinCollectorIfSingletonFactory : virtual public ZipkinCollectorIfFactory { + public: + ZipkinCollectorIfSingletonFactory(const ::std::shared_ptr& iface) : iface_(iface) {} + virtual ~ZipkinCollectorIfSingletonFactory() {} + + virtual ZipkinCollectorIf* getHandler(const ::apache::thrift::TConnectionInfo&) { + return iface_.get(); + } + virtual void releaseHandler(ZipkinCollectorIf* /* handler */) {} + + protected: + ::std::shared_ptr iface_; +}; + +class ZipkinCollectorNull : virtual public ZipkinCollectorIf { + public: + virtual ~ZipkinCollectorNull() {} + void submitZipkinBatch(std::vector & /* _return */, const std::vector & /* spans */) { + return; + } +}; + +typedef struct _ZipkinCollector_submitZipkinBatch_args__isset { + _ZipkinCollector_submitZipkinBatch_args__isset() : spans(false) {} + bool spans :1; +} _ZipkinCollector_submitZipkinBatch_args__isset; + +class ZipkinCollector_submitZipkinBatch_args { + public: + + ZipkinCollector_submitZipkinBatch_args(const ZipkinCollector_submitZipkinBatch_args&); + ZipkinCollector_submitZipkinBatch_args& operator=(const ZipkinCollector_submitZipkinBatch_args&); + ZipkinCollector_submitZipkinBatch_args() { + } + + virtual ~ZipkinCollector_submitZipkinBatch_args() noexcept; + std::vector spans; + + _ZipkinCollector_submitZipkinBatch_args__isset __isset; + + void __set_spans(const std::vector & val); + + bool operator == (const ZipkinCollector_submitZipkinBatch_args & rhs) const + { + if (!(spans == rhs.spans)) + return false; + return true; + } + bool operator != (const ZipkinCollector_submitZipkinBatch_args &rhs) const { + return !(*this == rhs); + } + + bool operator < (const ZipkinCollector_submitZipkinBatch_args & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + + +class ZipkinCollector_submitZipkinBatch_pargs { + public: + + + virtual ~ZipkinCollector_submitZipkinBatch_pargs() noexcept; + const std::vector * spans; + + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _ZipkinCollector_submitZipkinBatch_result__isset { + _ZipkinCollector_submitZipkinBatch_result__isset() : success(false) {} + bool success :1; +} _ZipkinCollector_submitZipkinBatch_result__isset; + +class ZipkinCollector_submitZipkinBatch_result { + public: + + ZipkinCollector_submitZipkinBatch_result(const ZipkinCollector_submitZipkinBatch_result&); + ZipkinCollector_submitZipkinBatch_result& operator=(const ZipkinCollector_submitZipkinBatch_result&); + ZipkinCollector_submitZipkinBatch_result() { + } + + virtual ~ZipkinCollector_submitZipkinBatch_result() noexcept; + std::vector success; + + _ZipkinCollector_submitZipkinBatch_result__isset __isset; + + void __set_success(const std::vector & val); + + bool operator == (const ZipkinCollector_submitZipkinBatch_result & rhs) const + { + if (!(success == rhs.success)) + return false; + return true; + } + bool operator != (const ZipkinCollector_submitZipkinBatch_result &rhs) const { + return !(*this == rhs); + } + + bool operator < (const ZipkinCollector_submitZipkinBatch_result & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + +}; + +typedef struct _ZipkinCollector_submitZipkinBatch_presult__isset { + _ZipkinCollector_submitZipkinBatch_presult__isset() : success(false) {} + bool success :1; +} _ZipkinCollector_submitZipkinBatch_presult__isset; + +class ZipkinCollector_submitZipkinBatch_presult { + public: + + + virtual ~ZipkinCollector_submitZipkinBatch_presult() noexcept; + std::vector * success; + + _ZipkinCollector_submitZipkinBatch_presult__isset __isset; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + +}; + +class ZipkinCollectorClient : virtual public ZipkinCollectorIf { + public: + ZipkinCollectorClient(std::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) { + setProtocol(prot); + } + ZipkinCollectorClient(std::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, std::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) { + setProtocol(iprot,oprot); + } + private: + void setProtocol(std::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) { + setProtocol(prot,prot); + } + void setProtocol(std::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, std::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) { + piprot_=iprot; + poprot_=oprot; + iprot_ = iprot.get(); + oprot_ = oprot.get(); + } + public: + std::shared_ptr< ::apache::thrift::protocol::TProtocol> getInputProtocol() { + return piprot_; + } + std::shared_ptr< ::apache::thrift::protocol::TProtocol> getOutputProtocol() { + return poprot_; + } + void submitZipkinBatch(std::vector & _return, const std::vector & spans); + void send_submitZipkinBatch(const std::vector & spans); + void recv_submitZipkinBatch(std::vector & _return); + protected: + std::shared_ptr< ::apache::thrift::protocol::TProtocol> piprot_; + std::shared_ptr< ::apache::thrift::protocol::TProtocol> poprot_; + ::apache::thrift::protocol::TProtocol* iprot_; + ::apache::thrift::protocol::TProtocol* oprot_; +}; + +class ZipkinCollectorProcessor : public ::apache::thrift::TDispatchProcessor { + protected: + ::std::shared_ptr iface_; + virtual bool dispatchCall(::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, const std::string& fname, int32_t seqid, void* callContext); + private: + typedef void (ZipkinCollectorProcessor::*ProcessFunction)(int32_t, ::apache::thrift::protocol::TProtocol*, ::apache::thrift::protocol::TProtocol*, void*); + typedef std::map ProcessMap; + ProcessMap processMap_; + void process_submitZipkinBatch(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext); + public: + ZipkinCollectorProcessor(::std::shared_ptr iface) : + iface_(iface) { + processMap_["submitZipkinBatch"] = &ZipkinCollectorProcessor::process_submitZipkinBatch; + } + + virtual ~ZipkinCollectorProcessor() {} +}; + +class ZipkinCollectorProcessorFactory : public ::apache::thrift::TProcessorFactory { + public: + ZipkinCollectorProcessorFactory(const ::std::shared_ptr< ZipkinCollectorIfFactory >& handlerFactory) : + handlerFactory_(handlerFactory) {} + + ::std::shared_ptr< ::apache::thrift::TProcessor > getProcessor(const ::apache::thrift::TConnectionInfo& connInfo); + + protected: + ::std::shared_ptr< ZipkinCollectorIfFactory > handlerFactory_; +}; + +class ZipkinCollectorMultiface : virtual public ZipkinCollectorIf { + public: + ZipkinCollectorMultiface(std::vector >& ifaces) : ifaces_(ifaces) { + } + virtual ~ZipkinCollectorMultiface() {} + protected: + std::vector > ifaces_; + ZipkinCollectorMultiface() {} + void add(::std::shared_ptr iface) { + ifaces_.push_back(iface); + } + public: + void submitZipkinBatch(std::vector & _return, const std::vector & spans) { + size_t sz = ifaces_.size(); + size_t i = 0; + for (; i < (sz - 1); ++i) { + ifaces_[i]->submitZipkinBatch(_return, spans); + } + ifaces_[i]->submitZipkinBatch(_return, spans); + return; + } + +}; + +// The 'concurrent' client is a thread safe client that correctly handles +// out of order responses. It is slower than the regular client, so should +// only be used when you need to share a connection among multiple threads +class ZipkinCollectorConcurrentClient : virtual public ZipkinCollectorIf { + public: + ZipkinCollectorConcurrentClient(std::shared_ptr< ::apache::thrift::protocol::TProtocol> prot, std::shared_ptr<::apache::thrift::async::TConcurrentClientSyncInfo> sync) : sync_(sync) +{ + setProtocol(prot); + } + ZipkinCollectorConcurrentClient(std::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, std::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot, std::shared_ptr<::apache::thrift::async::TConcurrentClientSyncInfo> sync) : sync_(sync) +{ + setProtocol(iprot,oprot); + } + private: + void setProtocol(std::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) { + setProtocol(prot,prot); + } + void setProtocol(std::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, std::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) { + piprot_=iprot; + poprot_=oprot; + iprot_ = iprot.get(); + oprot_ = oprot.get(); + } + public: + std::shared_ptr< ::apache::thrift::protocol::TProtocol> getInputProtocol() { + return piprot_; + } + std::shared_ptr< ::apache::thrift::protocol::TProtocol> getOutputProtocol() { + return poprot_; + } + void submitZipkinBatch(std::vector & _return, const std::vector & spans); + int32_t send_submitZipkinBatch(const std::vector & spans); + void recv_submitZipkinBatch(std::vector & _return, const int32_t seqid); + protected: + std::shared_ptr< ::apache::thrift::protocol::TProtocol> piprot_; + std::shared_ptr< ::apache::thrift::protocol::TProtocol> poprot_; + ::apache::thrift::protocol::TProtocol* iprot_; + ::apache::thrift::protocol::TProtocol* oprot_; + std::shared_ptr<::apache::thrift::async::TConcurrentClientSyncInfo> sync_; +}; + +#ifdef _MSC_VER + #pragma warning( pop ) +#endif + +}}} // namespace + +#endif diff --git a/exporters/jaeger/thrift-gen/ZipkinCollector_server.skeleton.cpp b/exporters/jaeger/thrift-gen/ZipkinCollector_server.skeleton.cpp new file mode 100644 index 0000000000..cca6ef752f --- /dev/null +++ b/exporters/jaeger/thrift-gen/ZipkinCollector_server.skeleton.cpp @@ -0,0 +1,42 @@ +// This autogenerated skeleton file illustrates how to build a server. +// You should copy it to another filename to avoid overwriting it. + +#include "ZipkinCollector.h" +#include +#include +#include +#include + +using namespace ::apache::thrift; +using namespace ::apache::thrift::protocol; +using namespace ::apache::thrift::transport; +using namespace ::apache::thrift::server; + +using namespace ::twitter::zipkin::thrift; + +class ZipkinCollectorHandler : virtual public ZipkinCollectorIf { + public: + ZipkinCollectorHandler() { + // Your initialization goes here + } + + void submitZipkinBatch(std::vector & _return, const std::vector & spans) { + // Your implementation goes here + printf("submitZipkinBatch\n"); + } + +}; + +int main(int argc, char **argv) { + int port = 9090; + ::std::shared_ptr handler(new ZipkinCollectorHandler()); + ::std::shared_ptr processor(new ZipkinCollectorProcessor(handler)); + ::std::shared_ptr serverTransport(new TServerSocket(port)); + ::std::shared_ptr transportFactory(new TBufferedTransportFactory()); + ::std::shared_ptr protocolFactory(new TBinaryProtocolFactory()); + + TSimpleServer server(processor, serverTransport, transportFactory, protocolFactory); + server.serve(); + return 0; +} + diff --git a/exporters/jaeger/thrift-gen/agent_types.h b/exporters/jaeger/thrift-gen/agent_types.h new file mode 100644 index 0000000000..0b576e34f5 --- /dev/null +++ b/exporters/jaeger/thrift-gen/agent_types.h @@ -0,0 +1,28 @@ +/** + * Autogenerated by Thrift Compiler (0.14.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +#ifndef agent_TYPES_H +#define agent_TYPES_H + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include "jaeger_types.h" +#include "zipkincore_types.h" + + +namespace jaegertracing { namespace agent { namespace thrift { + +}}} // namespace + +#endif diff --git a/exporters/jaeger/thrift-gen/jaeger_types.cpp b/exporters/jaeger/thrift-gen/jaeger_types.cpp new file mode 100644 index 0000000000..5e4140cc96 --- /dev/null +++ b/exporters/jaeger/thrift-gen/jaeger_types.cpp @@ -0,0 +1,1354 @@ +/** + * Autogenerated by Thrift Compiler (0.14.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +#include "jaeger_types.h" + +#include +#include + +#include + +namespace jaegertracing { namespace thrift { + +int _kTagTypeValues[] = { + TagType::STRING, + TagType::DOUBLE, + TagType::BOOL, + TagType::LONG, + TagType::BINARY +}; +const char* _kTagTypeNames[] = { + "STRING", + "DOUBLE", + "BOOL", + "LONG", + "BINARY" +}; +const std::map _TagType_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(5, _kTagTypeValues, _kTagTypeNames), ::apache::thrift::TEnumIterator(-1, nullptr, nullptr)); + +std::ostream& operator<<(std::ostream& out, const TagType::type& val) { + std::map::const_iterator it = _TagType_VALUES_TO_NAMES.find(val); + if (it != _TagType_VALUES_TO_NAMES.end()) { + out << it->second; + } else { + out << static_cast(val); + } + return out; +} + +std::string to_string(const TagType::type& val) { + std::map::const_iterator it = _TagType_VALUES_TO_NAMES.find(val); + if (it != _TagType_VALUES_TO_NAMES.end()) { + return std::string(it->second); + } else { + return std::to_string(static_cast(val)); + } +} + +int _kSpanRefTypeValues[] = { + SpanRefType::CHILD_OF, + SpanRefType::FOLLOWS_FROM +}; +const char* _kSpanRefTypeNames[] = { + "CHILD_OF", + "FOLLOWS_FROM" +}; +const std::map _SpanRefType_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(2, _kSpanRefTypeValues, _kSpanRefTypeNames), ::apache::thrift::TEnumIterator(-1, nullptr, nullptr)); + +std::ostream& operator<<(std::ostream& out, const SpanRefType::type& val) { + std::map::const_iterator it = _SpanRefType_VALUES_TO_NAMES.find(val); + if (it != _SpanRefType_VALUES_TO_NAMES.end()) { + out << it->second; + } else { + out << static_cast(val); + } + return out; +} + +std::string to_string(const SpanRefType::type& val) { + std::map::const_iterator it = _SpanRefType_VALUES_TO_NAMES.find(val); + if (it != _SpanRefType_VALUES_TO_NAMES.end()) { + return std::string(it->second); + } else { + return std::to_string(static_cast(val)); + } +} + + +Tag::~Tag() noexcept { +} + + +void Tag::__set_key(const std::string& val) { + this->key = val; +} + +void Tag::__set_vType(const TagType::type val) { + this->vType = val; +} + +void Tag::__set_vStr(const std::string& val) { + this->vStr = val; +__isset.vStr = true; +} + +void Tag::__set_vDouble(const double val) { + this->vDouble = val; +__isset.vDouble = true; +} + +void Tag::__set_vBool(const bool val) { + this->vBool = val; +__isset.vBool = true; +} + +void Tag::__set_vLong(const int64_t val) { + this->vLong = val; +__isset.vLong = true; +} + +void Tag::__set_vBinary(const std::string& val) { + this->vBinary = val; +__isset.vBinary = true; +} +std::ostream& operator<<(std::ostream& out, const Tag& obj) +{ + obj.printTo(out); + return out; +} + + +uint32_t Tag::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + bool isset_key = false; + bool isset_vType = false; + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_STRING) { + xfer += iprot->readString(this->key); + isset_key = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 2: + if (ftype == ::apache::thrift::protocol::T_I32) { + int32_t ecast0; + xfer += iprot->readI32(ecast0); + this->vType = (TagType::type)ecast0; + isset_vType = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 3: + if (ftype == ::apache::thrift::protocol::T_STRING) { + xfer += iprot->readString(this->vStr); + this->__isset.vStr = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 4: + if (ftype == ::apache::thrift::protocol::T_DOUBLE) { + xfer += iprot->readDouble(this->vDouble); + this->__isset.vDouble = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 5: + if (ftype == ::apache::thrift::protocol::T_BOOL) { + xfer += iprot->readBool(this->vBool); + this->__isset.vBool = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 6: + if (ftype == ::apache::thrift::protocol::T_I64) { + xfer += iprot->readI64(this->vLong); + this->__isset.vLong = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 7: + if (ftype == ::apache::thrift::protocol::T_STRING) { + xfer += iprot->readBinary(this->vBinary); + this->__isset.vBinary = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + if (!isset_key) + throw TProtocolException(TProtocolException::INVALID_DATA); + if (!isset_vType) + throw TProtocolException(TProtocolException::INVALID_DATA); + return xfer; +} + +uint32_t Tag::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("Tag"); + + xfer += oprot->writeFieldBegin("key", ::apache::thrift::protocol::T_STRING, 1); + xfer += oprot->writeString(this->key); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("vType", ::apache::thrift::protocol::T_I32, 2); + xfer += oprot->writeI32((int32_t)this->vType); + xfer += oprot->writeFieldEnd(); + + if (this->__isset.vStr) { + xfer += oprot->writeFieldBegin("vStr", ::apache::thrift::protocol::T_STRING, 3); + xfer += oprot->writeString(this->vStr); + xfer += oprot->writeFieldEnd(); + } + if (this->__isset.vDouble) { + xfer += oprot->writeFieldBegin("vDouble", ::apache::thrift::protocol::T_DOUBLE, 4); + xfer += oprot->writeDouble(this->vDouble); + xfer += oprot->writeFieldEnd(); + } + if (this->__isset.vBool) { + xfer += oprot->writeFieldBegin("vBool", ::apache::thrift::protocol::T_BOOL, 5); + xfer += oprot->writeBool(this->vBool); + xfer += oprot->writeFieldEnd(); + } + if (this->__isset.vLong) { + xfer += oprot->writeFieldBegin("vLong", ::apache::thrift::protocol::T_I64, 6); + xfer += oprot->writeI64(this->vLong); + xfer += oprot->writeFieldEnd(); + } + if (this->__isset.vBinary) { + xfer += oprot->writeFieldBegin("vBinary", ::apache::thrift::protocol::T_STRING, 7); + xfer += oprot->writeBinary(this->vBinary); + xfer += oprot->writeFieldEnd(); + } + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +void swap(Tag &a, Tag &b) { + using ::std::swap; + swap(a.key, b.key); + swap(a.vType, b.vType); + swap(a.vStr, b.vStr); + swap(a.vDouble, b.vDouble); + swap(a.vBool, b.vBool); + swap(a.vLong, b.vLong); + swap(a.vBinary, b.vBinary); + swap(a.__isset, b.__isset); +} + +Tag::Tag(const Tag& other1) { + key = other1.key; + vType = other1.vType; + vStr = other1.vStr; + vDouble = other1.vDouble; + vBool = other1.vBool; + vLong = other1.vLong; + vBinary = other1.vBinary; + __isset = other1.__isset; +} +Tag& Tag::operator=(const Tag& other2) { + key = other2.key; + vType = other2.vType; + vStr = other2.vStr; + vDouble = other2.vDouble; + vBool = other2.vBool; + vLong = other2.vLong; + vBinary = other2.vBinary; + __isset = other2.__isset; + return *this; +} +void Tag::printTo(std::ostream& out) const { + using ::apache::thrift::to_string; + out << "Tag("; + out << "key=" << to_string(key); + out << ", " << "vType=" << to_string(vType); + out << ", " << "vStr="; (__isset.vStr ? (out << to_string(vStr)) : (out << "")); + out << ", " << "vDouble="; (__isset.vDouble ? (out << to_string(vDouble)) : (out << "")); + out << ", " << "vBool="; (__isset.vBool ? (out << to_string(vBool)) : (out << "")); + out << ", " << "vLong="; (__isset.vLong ? (out << to_string(vLong)) : (out << "")); + out << ", " << "vBinary="; (__isset.vBinary ? (out << to_string(vBinary)) : (out << "")); + out << ")"; +} + + +Log::~Log() noexcept { +} + + +void Log::__set_timestamp(const int64_t val) { + this->timestamp = val; +} + +void Log::__set_fields(const std::vector & val) { + this->fields = val; +} +std::ostream& operator<<(std::ostream& out, const Log& obj) +{ + obj.printTo(out); + return out; +} + + +uint32_t Log::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + bool isset_timestamp = false; + bool isset_fields = false; + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_I64) { + xfer += iprot->readI64(this->timestamp); + isset_timestamp = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 2: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + this->fields.clear(); + uint32_t _size3; + ::apache::thrift::protocol::TType _etype6; + xfer += iprot->readListBegin(_etype6, _size3); + this->fields.resize(_size3); + uint32_t _i7; + for (_i7 = 0; _i7 < _size3; ++_i7) + { + xfer += this->fields[_i7].read(iprot); + } + xfer += iprot->readListEnd(); + } + isset_fields = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + if (!isset_timestamp) + throw TProtocolException(TProtocolException::INVALID_DATA); + if (!isset_fields) + throw TProtocolException(TProtocolException::INVALID_DATA); + return xfer; +} + +uint32_t Log::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("Log"); + + xfer += oprot->writeFieldBegin("timestamp", ::apache::thrift::protocol::T_I64, 1); + xfer += oprot->writeI64(this->timestamp); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("fields", ::apache::thrift::protocol::T_LIST, 2); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->fields.size())); + std::vector ::const_iterator _iter8; + for (_iter8 = this->fields.begin(); _iter8 != this->fields.end(); ++_iter8) + { + xfer += (*_iter8).write(oprot); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +void swap(Log &a, Log &b) { + using ::std::swap; + swap(a.timestamp, b.timestamp); + swap(a.fields, b.fields); +} + +Log::Log(const Log& other9) { + timestamp = other9.timestamp; + fields = other9.fields; +} +Log& Log::operator=(const Log& other10) { + timestamp = other10.timestamp; + fields = other10.fields; + return *this; +} +void Log::printTo(std::ostream& out) const { + using ::apache::thrift::to_string; + out << "Log("; + out << "timestamp=" << to_string(timestamp); + out << ", " << "fields=" << to_string(fields); + out << ")"; +} + + +SpanRef::~SpanRef() noexcept { +} + + +void SpanRef::__set_refType(const SpanRefType::type val) { + this->refType = val; +} + +void SpanRef::__set_traceIdLow(const int64_t val) { + this->traceIdLow = val; +} + +void SpanRef::__set_traceIdHigh(const int64_t val) { + this->traceIdHigh = val; +} + +void SpanRef::__set_spanId(const int64_t val) { + this->spanId = val; +} +std::ostream& operator<<(std::ostream& out, const SpanRef& obj) +{ + obj.printTo(out); + return out; +} + + +uint32_t SpanRef::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + bool isset_refType = false; + bool isset_traceIdLow = false; + bool isset_traceIdHigh = false; + bool isset_spanId = false; + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_I32) { + int32_t ecast11; + xfer += iprot->readI32(ecast11); + this->refType = (SpanRefType::type)ecast11; + isset_refType = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 2: + if (ftype == ::apache::thrift::protocol::T_I64) { + xfer += iprot->readI64(this->traceIdLow); + isset_traceIdLow = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 3: + if (ftype == ::apache::thrift::protocol::T_I64) { + xfer += iprot->readI64(this->traceIdHigh); + isset_traceIdHigh = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 4: + if (ftype == ::apache::thrift::protocol::T_I64) { + xfer += iprot->readI64(this->spanId); + isset_spanId = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + if (!isset_refType) + throw TProtocolException(TProtocolException::INVALID_DATA); + if (!isset_traceIdLow) + throw TProtocolException(TProtocolException::INVALID_DATA); + if (!isset_traceIdHigh) + throw TProtocolException(TProtocolException::INVALID_DATA); + if (!isset_spanId) + throw TProtocolException(TProtocolException::INVALID_DATA); + return xfer; +} + +uint32_t SpanRef::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("SpanRef"); + + xfer += oprot->writeFieldBegin("refType", ::apache::thrift::protocol::T_I32, 1); + xfer += oprot->writeI32((int32_t)this->refType); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("traceIdLow", ::apache::thrift::protocol::T_I64, 2); + xfer += oprot->writeI64(this->traceIdLow); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("traceIdHigh", ::apache::thrift::protocol::T_I64, 3); + xfer += oprot->writeI64(this->traceIdHigh); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("spanId", ::apache::thrift::protocol::T_I64, 4); + xfer += oprot->writeI64(this->spanId); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +void swap(SpanRef &a, SpanRef &b) { + using ::std::swap; + swap(a.refType, b.refType); + swap(a.traceIdLow, b.traceIdLow); + swap(a.traceIdHigh, b.traceIdHigh); + swap(a.spanId, b.spanId); +} + +SpanRef::SpanRef(const SpanRef& other12) { + refType = other12.refType; + traceIdLow = other12.traceIdLow; + traceIdHigh = other12.traceIdHigh; + spanId = other12.spanId; +} +SpanRef& SpanRef::operator=(const SpanRef& other13) { + refType = other13.refType; + traceIdLow = other13.traceIdLow; + traceIdHigh = other13.traceIdHigh; + spanId = other13.spanId; + return *this; +} +void SpanRef::printTo(std::ostream& out) const { + using ::apache::thrift::to_string; + out << "SpanRef("; + out << "refType=" << to_string(refType); + out << ", " << "traceIdLow=" << to_string(traceIdLow); + out << ", " << "traceIdHigh=" << to_string(traceIdHigh); + out << ", " << "spanId=" << to_string(spanId); + out << ")"; +} + + +Span::~Span() noexcept { +} + + +void Span::__set_traceIdLow(const int64_t val) { + this->traceIdLow = val; +} + +void Span::__set_traceIdHigh(const int64_t val) { + this->traceIdHigh = val; +} + +void Span::__set_spanId(const int64_t val) { + this->spanId = val; +} + +void Span::__set_parentSpanId(const int64_t val) { + this->parentSpanId = val; +} + +void Span::__set_operationName(const std::string& val) { + this->operationName = val; +} + +void Span::__set_references(const std::vector & val) { + this->references = val; +__isset.references = true; +} + +void Span::__set_flags(const int32_t val) { + this->flags = val; +} + +void Span::__set_startTime(const int64_t val) { + this->startTime = val; +} + +void Span::__set_duration(const int64_t val) { + this->duration = val; +} + +void Span::__set_tags(const std::vector & val) { + this->tags = val; +__isset.tags = true; +} + +void Span::__set_logs(const std::vector & val) { + this->logs = val; +__isset.logs = true; +} +std::ostream& operator<<(std::ostream& out, const Span& obj) +{ + obj.printTo(out); + return out; +} + + +uint32_t Span::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + bool isset_traceIdLow = false; + bool isset_traceIdHigh = false; + bool isset_spanId = false; + bool isset_parentSpanId = false; + bool isset_operationName = false; + bool isset_flags = false; + bool isset_startTime = false; + bool isset_duration = false; + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_I64) { + xfer += iprot->readI64(this->traceIdLow); + isset_traceIdLow = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 2: + if (ftype == ::apache::thrift::protocol::T_I64) { + xfer += iprot->readI64(this->traceIdHigh); + isset_traceIdHigh = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 3: + if (ftype == ::apache::thrift::protocol::T_I64) { + xfer += iprot->readI64(this->spanId); + isset_spanId = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 4: + if (ftype == ::apache::thrift::protocol::T_I64) { + xfer += iprot->readI64(this->parentSpanId); + isset_parentSpanId = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 5: + if (ftype == ::apache::thrift::protocol::T_STRING) { + xfer += iprot->readString(this->operationName); + isset_operationName = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 6: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + this->references.clear(); + uint32_t _size14; + ::apache::thrift::protocol::TType _etype17; + xfer += iprot->readListBegin(_etype17, _size14); + this->references.resize(_size14); + uint32_t _i18; + for (_i18 = 0; _i18 < _size14; ++_i18) + { + xfer += this->references[_i18].read(iprot); + } + xfer += iprot->readListEnd(); + } + this->__isset.references = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 7: + if (ftype == ::apache::thrift::protocol::T_I32) { + xfer += iprot->readI32(this->flags); + isset_flags = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 8: + if (ftype == ::apache::thrift::protocol::T_I64) { + xfer += iprot->readI64(this->startTime); + isset_startTime = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 9: + if (ftype == ::apache::thrift::protocol::T_I64) { + xfer += iprot->readI64(this->duration); + isset_duration = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 10: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + this->tags.clear(); + uint32_t _size19; + ::apache::thrift::protocol::TType _etype22; + xfer += iprot->readListBegin(_etype22, _size19); + this->tags.resize(_size19); + uint32_t _i23; + for (_i23 = 0; _i23 < _size19; ++_i23) + { + xfer += this->tags[_i23].read(iprot); + } + xfer += iprot->readListEnd(); + } + this->__isset.tags = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 11: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + this->logs.clear(); + uint32_t _size24; + ::apache::thrift::protocol::TType _etype27; + xfer += iprot->readListBegin(_etype27, _size24); + this->logs.resize(_size24); + uint32_t _i28; + for (_i28 = 0; _i28 < _size24; ++_i28) + { + xfer += this->logs[_i28].read(iprot); + } + xfer += iprot->readListEnd(); + } + this->__isset.logs = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + if (!isset_traceIdLow) + throw TProtocolException(TProtocolException::INVALID_DATA); + if (!isset_traceIdHigh) + throw TProtocolException(TProtocolException::INVALID_DATA); + if (!isset_spanId) + throw TProtocolException(TProtocolException::INVALID_DATA); + if (!isset_parentSpanId) + throw TProtocolException(TProtocolException::INVALID_DATA); + if (!isset_operationName) + throw TProtocolException(TProtocolException::INVALID_DATA); + if (!isset_flags) + throw TProtocolException(TProtocolException::INVALID_DATA); + if (!isset_startTime) + throw TProtocolException(TProtocolException::INVALID_DATA); + if (!isset_duration) + throw TProtocolException(TProtocolException::INVALID_DATA); + return xfer; +} + +uint32_t Span::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("Span"); + + xfer += oprot->writeFieldBegin("traceIdLow", ::apache::thrift::protocol::T_I64, 1); + xfer += oprot->writeI64(this->traceIdLow); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("traceIdHigh", ::apache::thrift::protocol::T_I64, 2); + xfer += oprot->writeI64(this->traceIdHigh); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("spanId", ::apache::thrift::protocol::T_I64, 3); + xfer += oprot->writeI64(this->spanId); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("parentSpanId", ::apache::thrift::protocol::T_I64, 4); + xfer += oprot->writeI64(this->parentSpanId); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("operationName", ::apache::thrift::protocol::T_STRING, 5); + xfer += oprot->writeString(this->operationName); + xfer += oprot->writeFieldEnd(); + + if (this->__isset.references) { + xfer += oprot->writeFieldBegin("references", ::apache::thrift::protocol::T_LIST, 6); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->references.size())); + std::vector ::const_iterator _iter29; + for (_iter29 = this->references.begin(); _iter29 != this->references.end(); ++_iter29) + { + xfer += (*_iter29).write(oprot); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + } + xfer += oprot->writeFieldBegin("flags", ::apache::thrift::protocol::T_I32, 7); + xfer += oprot->writeI32(this->flags); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("startTime", ::apache::thrift::protocol::T_I64, 8); + xfer += oprot->writeI64(this->startTime); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("duration", ::apache::thrift::protocol::T_I64, 9); + xfer += oprot->writeI64(this->duration); + xfer += oprot->writeFieldEnd(); + + if (this->__isset.tags) { + xfer += oprot->writeFieldBegin("tags", ::apache::thrift::protocol::T_LIST, 10); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->tags.size())); + std::vector ::const_iterator _iter30; + for (_iter30 = this->tags.begin(); _iter30 != this->tags.end(); ++_iter30) + { + xfer += (*_iter30).write(oprot); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + } + if (this->__isset.logs) { + xfer += oprot->writeFieldBegin("logs", ::apache::thrift::protocol::T_LIST, 11); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->logs.size())); + std::vector ::const_iterator _iter31; + for (_iter31 = this->logs.begin(); _iter31 != this->logs.end(); ++_iter31) + { + xfer += (*_iter31).write(oprot); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + } + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +void swap(Span &a, Span &b) { + using ::std::swap; + swap(a.traceIdLow, b.traceIdLow); + swap(a.traceIdHigh, b.traceIdHigh); + swap(a.spanId, b.spanId); + swap(a.parentSpanId, b.parentSpanId); + swap(a.operationName, b.operationName); + swap(a.references, b.references); + swap(a.flags, b.flags); + swap(a.startTime, b.startTime); + swap(a.duration, b.duration); + swap(a.tags, b.tags); + swap(a.logs, b.logs); + swap(a.__isset, b.__isset); +} + +Span::Span(const Span& other32) { + traceIdLow = other32.traceIdLow; + traceIdHigh = other32.traceIdHigh; + spanId = other32.spanId; + parentSpanId = other32.parentSpanId; + operationName = other32.operationName; + references = other32.references; + flags = other32.flags; + startTime = other32.startTime; + duration = other32.duration; + tags = other32.tags; + logs = other32.logs; + __isset = other32.__isset; +} +Span& Span::operator=(const Span& other33) { + traceIdLow = other33.traceIdLow; + traceIdHigh = other33.traceIdHigh; + spanId = other33.spanId; + parentSpanId = other33.parentSpanId; + operationName = other33.operationName; + references = other33.references; + flags = other33.flags; + startTime = other33.startTime; + duration = other33.duration; + tags = other33.tags; + logs = other33.logs; + __isset = other33.__isset; + return *this; +} +void Span::printTo(std::ostream& out) const { + using ::apache::thrift::to_string; + out << "Span("; + out << "traceIdLow=" << to_string(traceIdLow); + out << ", " << "traceIdHigh=" << to_string(traceIdHigh); + out << ", " << "spanId=" << to_string(spanId); + out << ", " << "parentSpanId=" << to_string(parentSpanId); + out << ", " << "operationName=" << to_string(operationName); + out << ", " << "references="; (__isset.references ? (out << to_string(references)) : (out << "")); + out << ", " << "flags=" << to_string(flags); + out << ", " << "startTime=" << to_string(startTime); + out << ", " << "duration=" << to_string(duration); + out << ", " << "tags="; (__isset.tags ? (out << to_string(tags)) : (out << "")); + out << ", " << "logs="; (__isset.logs ? (out << to_string(logs)) : (out << "")); + out << ")"; +} + + +Process::~Process() noexcept { +} + + +void Process::__set_serviceName(const std::string& val) { + this->serviceName = val; +} + +void Process::__set_tags(const std::vector & val) { + this->tags = val; +__isset.tags = true; +} +std::ostream& operator<<(std::ostream& out, const Process& obj) +{ + obj.printTo(out); + return out; +} + + +uint32_t Process::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + bool isset_serviceName = false; + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_STRING) { + xfer += iprot->readString(this->serviceName); + isset_serviceName = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 2: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + this->tags.clear(); + uint32_t _size34; + ::apache::thrift::protocol::TType _etype37; + xfer += iprot->readListBegin(_etype37, _size34); + this->tags.resize(_size34); + uint32_t _i38; + for (_i38 = 0; _i38 < _size34; ++_i38) + { + xfer += this->tags[_i38].read(iprot); + } + xfer += iprot->readListEnd(); + } + this->__isset.tags = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + if (!isset_serviceName) + throw TProtocolException(TProtocolException::INVALID_DATA); + return xfer; +} + +uint32_t Process::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("Process"); + + xfer += oprot->writeFieldBegin("serviceName", ::apache::thrift::protocol::T_STRING, 1); + xfer += oprot->writeString(this->serviceName); + xfer += oprot->writeFieldEnd(); + + if (this->__isset.tags) { + xfer += oprot->writeFieldBegin("tags", ::apache::thrift::protocol::T_LIST, 2); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->tags.size())); + std::vector ::const_iterator _iter39; + for (_iter39 = this->tags.begin(); _iter39 != this->tags.end(); ++_iter39) + { + xfer += (*_iter39).write(oprot); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + } + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +void swap(Process &a, Process &b) { + using ::std::swap; + swap(a.serviceName, b.serviceName); + swap(a.tags, b.tags); + swap(a.__isset, b.__isset); +} + +Process::Process(const Process& other40) { + serviceName = other40.serviceName; + tags = other40.tags; + __isset = other40.__isset; +} +Process& Process::operator=(const Process& other41) { + serviceName = other41.serviceName; + tags = other41.tags; + __isset = other41.__isset; + return *this; +} +void Process::printTo(std::ostream& out) const { + using ::apache::thrift::to_string; + out << "Process("; + out << "serviceName=" << to_string(serviceName); + out << ", " << "tags="; (__isset.tags ? (out << to_string(tags)) : (out << "")); + out << ")"; +} + + +Batch::~Batch() noexcept { +} + + +void Batch::__set_process(const Process& val) { + this->process = val; +} + +void Batch::__set_spans(const std::vector & val) { + this->spans = val; +} +std::ostream& operator<<(std::ostream& out, const Batch& obj) +{ + obj.printTo(out); + return out; +} + + +uint32_t Batch::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + bool isset_process = false; + bool isset_spans = false; + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->process.read(iprot); + isset_process = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 2: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + this->spans.clear(); + uint32_t _size42; + ::apache::thrift::protocol::TType _etype45; + xfer += iprot->readListBegin(_etype45, _size42); + this->spans.resize(_size42); + uint32_t _i46; + for (_i46 = 0; _i46 < _size42; ++_i46) + { + xfer += this->spans[_i46].read(iprot); + } + xfer += iprot->readListEnd(); + } + isset_spans = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + if (!isset_process) + throw TProtocolException(TProtocolException::INVALID_DATA); + if (!isset_spans) + throw TProtocolException(TProtocolException::INVALID_DATA); + return xfer; +} + +uint32_t Batch::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("Batch"); + + xfer += oprot->writeFieldBegin("process", ::apache::thrift::protocol::T_STRUCT, 1); + xfer += this->process.write(oprot); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("spans", ::apache::thrift::protocol::T_LIST, 2); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->spans.size())); + std::vector ::const_iterator _iter47; + for (_iter47 = this->spans.begin(); _iter47 != this->spans.end(); ++_iter47) + { + xfer += (*_iter47).write(oprot); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +void swap(Batch &a, Batch &b) { + using ::std::swap; + swap(a.process, b.process); + swap(a.spans, b.spans); +} + +Batch::Batch(const Batch& other48) { + process = other48.process; + spans = other48.spans; +} +Batch& Batch::operator=(const Batch& other49) { + process = other49.process; + spans = other49.spans; + return *this; +} +void Batch::printTo(std::ostream& out) const { + using ::apache::thrift::to_string; + out << "Batch("; + out << "process=" << to_string(process); + out << ", " << "spans=" << to_string(spans); + out << ")"; +} + + +BatchSubmitResponse::~BatchSubmitResponse() noexcept { +} + + +void BatchSubmitResponse::__set_ok(const bool val) { + this->ok = val; +} +std::ostream& operator<<(std::ostream& out, const BatchSubmitResponse& obj) +{ + obj.printTo(out); + return out; +} + + +uint32_t BatchSubmitResponse::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + bool isset_ok = false; + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_BOOL) { + xfer += iprot->readBool(this->ok); + isset_ok = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + if (!isset_ok) + throw TProtocolException(TProtocolException::INVALID_DATA); + return xfer; +} + +uint32_t BatchSubmitResponse::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("BatchSubmitResponse"); + + xfer += oprot->writeFieldBegin("ok", ::apache::thrift::protocol::T_BOOL, 1); + xfer += oprot->writeBool(this->ok); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +void swap(BatchSubmitResponse &a, BatchSubmitResponse &b) { + using ::std::swap; + swap(a.ok, b.ok); +} + +BatchSubmitResponse::BatchSubmitResponse(const BatchSubmitResponse& other50) { + ok = other50.ok; +} +BatchSubmitResponse& BatchSubmitResponse::operator=(const BatchSubmitResponse& other51) { + ok = other51.ok; + return *this; +} +void BatchSubmitResponse::printTo(std::ostream& out) const { + using ::apache::thrift::to_string; + out << "BatchSubmitResponse("; + out << "ok=" << to_string(ok); + out << ")"; +} + +}} // namespace diff --git a/exporters/jaeger/thrift-gen/jaeger_types.h b/exporters/jaeger/thrift-gen/jaeger_types.h new file mode 100644 index 0000000000..b30a3740b3 --- /dev/null +++ b/exporters/jaeger/thrift-gen/jaeger_types.h @@ -0,0 +1,481 @@ +/** + * Autogenerated by Thrift Compiler (0.14.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +#ifndef jaeger_TYPES_H +#define jaeger_TYPES_H + +#include + +#include +#include +#include +#include +#include + +#include +#include + + +namespace jaegertracing { namespace thrift { + +struct TagType { + enum type { + STRING = 0, + DOUBLE = 1, + BOOL = 2, + LONG = 3, + BINARY = 4 + }; +}; + +extern const std::map _TagType_VALUES_TO_NAMES; + +std::ostream& operator<<(std::ostream& out, const TagType::type& val); + +std::string to_string(const TagType::type& val); + +struct SpanRefType { + enum type { + CHILD_OF = 0, + FOLLOWS_FROM = 1 + }; +}; + +extern const std::map _SpanRefType_VALUES_TO_NAMES; + +std::ostream& operator<<(std::ostream& out, const SpanRefType::type& val); + +std::string to_string(const SpanRefType::type& val); + +class Tag; + +class Log; + +class SpanRef; + +class Span; + +class Process; + +class Batch; + +class BatchSubmitResponse; + +typedef struct _Tag__isset { + _Tag__isset() : vStr(false), vDouble(false), vBool(false), vLong(false), vBinary(false) {} + bool vStr :1; + bool vDouble :1; + bool vBool :1; + bool vLong :1; + bool vBinary :1; +} _Tag__isset; + +class Tag : public virtual ::apache::thrift::TBase { + public: + + Tag(const Tag&); + Tag& operator=(const Tag&); + Tag() : key(), vType((TagType::type)0), vStr(), vDouble(0), vBool(0), vLong(0), vBinary() { + } + + virtual ~Tag() noexcept; + std::string key; + /** + * + * @see TagType + */ + TagType::type vType; + std::string vStr; + double vDouble; + bool vBool; + int64_t vLong; + std::string vBinary; + + _Tag__isset __isset; + + void __set_key(const std::string& val); + + void __set_vType(const TagType::type val); + + void __set_vStr(const std::string& val); + + void __set_vDouble(const double val); + + void __set_vBool(const bool val); + + void __set_vLong(const int64_t val); + + void __set_vBinary(const std::string& val); + + bool operator == (const Tag & rhs) const + { + if (!(key == rhs.key)) + return false; + if (!(vType == rhs.vType)) + return false; + if (__isset.vStr != rhs.__isset.vStr) + return false; + else if (__isset.vStr && !(vStr == rhs.vStr)) + return false; + if (__isset.vDouble != rhs.__isset.vDouble) + return false; + else if (__isset.vDouble && !(vDouble == rhs.vDouble)) + return false; + if (__isset.vBool != rhs.__isset.vBool) + return false; + else if (__isset.vBool && !(vBool == rhs.vBool)) + return false; + if (__isset.vLong != rhs.__isset.vLong) + return false; + else if (__isset.vLong && !(vLong == rhs.vLong)) + return false; + if (__isset.vBinary != rhs.__isset.vBinary) + return false; + else if (__isset.vBinary && !(vBinary == rhs.vBinary)) + return false; + return true; + } + bool operator != (const Tag &rhs) const { + return !(*this == rhs); + } + + bool operator < (const Tag & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + + virtual void printTo(std::ostream& out) const; +}; + +void swap(Tag &a, Tag &b); + +std::ostream& operator<<(std::ostream& out, const Tag& obj); + + +class Log : public virtual ::apache::thrift::TBase { + public: + + Log(const Log&); + Log& operator=(const Log&); + Log() : timestamp(0) { + } + + virtual ~Log() noexcept; + int64_t timestamp; + std::vector fields; + + void __set_timestamp(const int64_t val); + + void __set_fields(const std::vector & val); + + bool operator == (const Log & rhs) const + { + if (!(timestamp == rhs.timestamp)) + return false; + if (!(fields == rhs.fields)) + return false; + return true; + } + bool operator != (const Log &rhs) const { + return !(*this == rhs); + } + + bool operator < (const Log & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + + virtual void printTo(std::ostream& out) const; +}; + +void swap(Log &a, Log &b); + +std::ostream& operator<<(std::ostream& out, const Log& obj); + + +class SpanRef : public virtual ::apache::thrift::TBase { + public: + + SpanRef(const SpanRef&); + SpanRef& operator=(const SpanRef&); + SpanRef() : refType((SpanRefType::type)0), traceIdLow(0), traceIdHigh(0), spanId(0) { + } + + virtual ~SpanRef() noexcept; + /** + * + * @see SpanRefType + */ + SpanRefType::type refType; + int64_t traceIdLow; + int64_t traceIdHigh; + int64_t spanId; + + void __set_refType(const SpanRefType::type val); + + void __set_traceIdLow(const int64_t val); + + void __set_traceIdHigh(const int64_t val); + + void __set_spanId(const int64_t val); + + bool operator == (const SpanRef & rhs) const + { + if (!(refType == rhs.refType)) + return false; + if (!(traceIdLow == rhs.traceIdLow)) + return false; + if (!(traceIdHigh == rhs.traceIdHigh)) + return false; + if (!(spanId == rhs.spanId)) + return false; + return true; + } + bool operator != (const SpanRef &rhs) const { + return !(*this == rhs); + } + + bool operator < (const SpanRef & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + + virtual void printTo(std::ostream& out) const; +}; + +void swap(SpanRef &a, SpanRef &b); + +std::ostream& operator<<(std::ostream& out, const SpanRef& obj); + +typedef struct _Span__isset { + _Span__isset() : references(false), tags(false), logs(false) {} + bool references :1; + bool tags :1; + bool logs :1; +} _Span__isset; + +class Span : public virtual ::apache::thrift::TBase { + public: + + Span(const Span&); + Span& operator=(const Span&); + Span() : traceIdLow(0), traceIdHigh(0), spanId(0), parentSpanId(0), operationName(), flags(0), startTime(0), duration(0) { + } + + virtual ~Span() noexcept; + int64_t traceIdLow; + int64_t traceIdHigh; + int64_t spanId; + int64_t parentSpanId; + std::string operationName; + std::vector references; + int32_t flags; + int64_t startTime; + int64_t duration; + std::vector tags; + std::vector logs; + + _Span__isset __isset; + + void __set_traceIdLow(const int64_t val); + + void __set_traceIdHigh(const int64_t val); + + void __set_spanId(const int64_t val); + + void __set_parentSpanId(const int64_t val); + + void __set_operationName(const std::string& val); + + void __set_references(const std::vector & val); + + void __set_flags(const int32_t val); + + void __set_startTime(const int64_t val); + + void __set_duration(const int64_t val); + + void __set_tags(const std::vector & val); + + void __set_logs(const std::vector & val); + + bool operator == (const Span & rhs) const + { + if (!(traceIdLow == rhs.traceIdLow)) + return false; + if (!(traceIdHigh == rhs.traceIdHigh)) + return false; + if (!(spanId == rhs.spanId)) + return false; + if (!(parentSpanId == rhs.parentSpanId)) + return false; + if (!(operationName == rhs.operationName)) + return false; + if (__isset.references != rhs.__isset.references) + return false; + else if (__isset.references && !(references == rhs.references)) + return false; + if (!(flags == rhs.flags)) + return false; + if (!(startTime == rhs.startTime)) + return false; + if (!(duration == rhs.duration)) + return false; + if (__isset.tags != rhs.__isset.tags) + return false; + else if (__isset.tags && !(tags == rhs.tags)) + return false; + if (__isset.logs != rhs.__isset.logs) + return false; + else if (__isset.logs && !(logs == rhs.logs)) + return false; + return true; + } + bool operator != (const Span &rhs) const { + return !(*this == rhs); + } + + bool operator < (const Span & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + + virtual void printTo(std::ostream& out) const; +}; + +void swap(Span &a, Span &b); + +std::ostream& operator<<(std::ostream& out, const Span& obj); + +typedef struct _Process__isset { + _Process__isset() : tags(false) {} + bool tags :1; +} _Process__isset; + +class Process : public virtual ::apache::thrift::TBase { + public: + + Process(const Process&); + Process& operator=(const Process&); + Process() : serviceName() { + } + + virtual ~Process() noexcept; + std::string serviceName; + std::vector tags; + + _Process__isset __isset; + + void __set_serviceName(const std::string& val); + + void __set_tags(const std::vector & val); + + bool operator == (const Process & rhs) const + { + if (!(serviceName == rhs.serviceName)) + return false; + if (__isset.tags != rhs.__isset.tags) + return false; + else if (__isset.tags && !(tags == rhs.tags)) + return false; + return true; + } + bool operator != (const Process &rhs) const { + return !(*this == rhs); + } + + bool operator < (const Process & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + + virtual void printTo(std::ostream& out) const; +}; + +void swap(Process &a, Process &b); + +std::ostream& operator<<(std::ostream& out, const Process& obj); + + +class Batch : public virtual ::apache::thrift::TBase { + public: + + Batch(const Batch&); + Batch& operator=(const Batch&); + Batch() { + } + + virtual ~Batch() noexcept; + Process process; + std::vector spans; + + void __set_process(const Process& val); + + void __set_spans(const std::vector & val); + + bool operator == (const Batch & rhs) const + { + if (!(process == rhs.process)) + return false; + if (!(spans == rhs.spans)) + return false; + return true; + } + bool operator != (const Batch &rhs) const { + return !(*this == rhs); + } + + bool operator < (const Batch & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + + virtual void printTo(std::ostream& out) const; +}; + +void swap(Batch &a, Batch &b); + +std::ostream& operator<<(std::ostream& out, const Batch& obj); + + +class BatchSubmitResponse : public virtual ::apache::thrift::TBase { + public: + + BatchSubmitResponse(const BatchSubmitResponse&); + BatchSubmitResponse& operator=(const BatchSubmitResponse&); + BatchSubmitResponse() : ok(0) { + } + + virtual ~BatchSubmitResponse() noexcept; + bool ok; + + void __set_ok(const bool val); + + bool operator == (const BatchSubmitResponse & rhs) const + { + if (!(ok == rhs.ok)) + return false; + return true; + } + bool operator != (const BatchSubmitResponse &rhs) const { + return !(*this == rhs); + } + + bool operator < (const BatchSubmitResponse & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + + virtual void printTo(std::ostream& out) const; +}; + +void swap(BatchSubmitResponse &a, BatchSubmitResponse &b); + +std::ostream& operator<<(std::ostream& out, const BatchSubmitResponse& obj); + +}} // namespace + +#endif diff --git a/exporters/jaeger/thrift-gen/zipkincore_constants.cpp b/exporters/jaeger/thrift-gen/zipkincore_constants.cpp new file mode 100644 index 0000000000..8dd451e483 --- /dev/null +++ b/exporters/jaeger/thrift-gen/zipkincore_constants.cpp @@ -0,0 +1,49 @@ +/** + * Autogenerated by Thrift Compiler (0.14.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +#include "zipkincore_constants.h" + +namespace twitter { namespace zipkin { namespace thrift { + +const zipkincoreConstants g_zipkincore_constants; + +zipkincoreConstants::zipkincoreConstants() { + CLIENT_SEND = "cs"; + + CLIENT_RECV = "cr"; + + SERVER_SEND = "ss"; + + SERVER_RECV = "sr"; + + MESSAGE_SEND = "ms"; + + MESSAGE_RECV = "mr"; + + WIRE_SEND = "ws"; + + WIRE_RECV = "wr"; + + CLIENT_SEND_FRAGMENT = "csf"; + + CLIENT_RECV_FRAGMENT = "crf"; + + SERVER_SEND_FRAGMENT = "ssf"; + + SERVER_RECV_FRAGMENT = "srf"; + + LOCAL_COMPONENT = "lc"; + + CLIENT_ADDR = "ca"; + + SERVER_ADDR = "sa"; + + MESSAGE_ADDR = "ma"; + +} + +}}} // namespace + diff --git a/exporters/jaeger/thrift-gen/zipkincore_constants.h b/exporters/jaeger/thrift-gen/zipkincore_constants.h new file mode 100644 index 0000000000..22b4b3b67c --- /dev/null +++ b/exporters/jaeger/thrift-gen/zipkincore_constants.h @@ -0,0 +1,40 @@ +/** + * Autogenerated by Thrift Compiler (0.14.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +#ifndef zipkincore_CONSTANTS_H +#define zipkincore_CONSTANTS_H + +#include "zipkincore_types.h" + +namespace twitter { namespace zipkin { namespace thrift { + +class zipkincoreConstants { + public: + zipkincoreConstants(); + + std::string CLIENT_SEND; + std::string CLIENT_RECV; + std::string SERVER_SEND; + std::string SERVER_RECV; + std::string MESSAGE_SEND; + std::string MESSAGE_RECV; + std::string WIRE_SEND; + std::string WIRE_RECV; + std::string CLIENT_SEND_FRAGMENT; + std::string CLIENT_RECV_FRAGMENT; + std::string SERVER_SEND_FRAGMENT; + std::string SERVER_RECV_FRAGMENT; + std::string LOCAL_COMPONENT; + std::string CLIENT_ADDR; + std::string SERVER_ADDR; + std::string MESSAGE_ADDR; +}; + +extern const zipkincoreConstants g_zipkincore_constants; + +}}} // namespace + +#endif diff --git a/exporters/jaeger/thrift-gen/zipkincore_types.cpp b/exporters/jaeger/thrift-gen/zipkincore_types.cpp new file mode 100644 index 0000000000..a8b52e902d --- /dev/null +++ b/exporters/jaeger/thrift-gen/zipkincore_types.cpp @@ -0,0 +1,913 @@ +/** + * Autogenerated by Thrift Compiler (0.14.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +#include "zipkincore_types.h" + +#include +#include + +#include + +namespace twitter { namespace zipkin { namespace thrift { + +int _kAnnotationTypeValues[] = { + AnnotationType::BOOL, + AnnotationType::BYTES, + AnnotationType::I16, + AnnotationType::I32, + AnnotationType::I64, + AnnotationType::DOUBLE, + AnnotationType::STRING +}; +const char* _kAnnotationTypeNames[] = { + "BOOL", + "BYTES", + "I16", + "I32", + "I64", + "DOUBLE", + "STRING" +}; +const std::map _AnnotationType_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(7, _kAnnotationTypeValues, _kAnnotationTypeNames), ::apache::thrift::TEnumIterator(-1, nullptr, nullptr)); + +std::ostream& operator<<(std::ostream& out, const AnnotationType::type& val) { + std::map::const_iterator it = _AnnotationType_VALUES_TO_NAMES.find(val); + if (it != _AnnotationType_VALUES_TO_NAMES.end()) { + out << it->second; + } else { + out << static_cast(val); + } + return out; +} + +std::string to_string(const AnnotationType::type& val) { + std::map::const_iterator it = _AnnotationType_VALUES_TO_NAMES.find(val); + if (it != _AnnotationType_VALUES_TO_NAMES.end()) { + return std::string(it->second); + } else { + return std::to_string(static_cast(val)); + } +} + + +Endpoint::~Endpoint() noexcept { +} + + +void Endpoint::__set_ipv4(const int32_t val) { + this->ipv4 = val; +} + +void Endpoint::__set_port(const int16_t val) { + this->port = val; +} + +void Endpoint::__set_service_name(const std::string& val) { + this->service_name = val; +} + +void Endpoint::__set_ipv6(const std::string& val) { + this->ipv6 = val; +__isset.ipv6 = true; +} +std::ostream& operator<<(std::ostream& out, const Endpoint& obj) +{ + obj.printTo(out); + return out; +} + + +uint32_t Endpoint::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_I32) { + xfer += iprot->readI32(this->ipv4); + this->__isset.ipv4 = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 2: + if (ftype == ::apache::thrift::protocol::T_I16) { + xfer += iprot->readI16(this->port); + this->__isset.port = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 3: + if (ftype == ::apache::thrift::protocol::T_STRING) { + xfer += iprot->readString(this->service_name); + this->__isset.service_name = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 4: + if (ftype == ::apache::thrift::protocol::T_STRING) { + xfer += iprot->readBinary(this->ipv6); + this->__isset.ipv6 = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t Endpoint::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("Endpoint"); + + xfer += oprot->writeFieldBegin("ipv4", ::apache::thrift::protocol::T_I32, 1); + xfer += oprot->writeI32(this->ipv4); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("port", ::apache::thrift::protocol::T_I16, 2); + xfer += oprot->writeI16(this->port); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("service_name", ::apache::thrift::protocol::T_STRING, 3); + xfer += oprot->writeString(this->service_name); + xfer += oprot->writeFieldEnd(); + + if (this->__isset.ipv6) { + xfer += oprot->writeFieldBegin("ipv6", ::apache::thrift::protocol::T_STRING, 4); + xfer += oprot->writeBinary(this->ipv6); + xfer += oprot->writeFieldEnd(); + } + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +void swap(Endpoint &a, Endpoint &b) { + using ::std::swap; + swap(a.ipv4, b.ipv4); + swap(a.port, b.port); + swap(a.service_name, b.service_name); + swap(a.ipv6, b.ipv6); + swap(a.__isset, b.__isset); +} + +Endpoint::Endpoint(const Endpoint& other0) { + ipv4 = other0.ipv4; + port = other0.port; + service_name = other0.service_name; + ipv6 = other0.ipv6; + __isset = other0.__isset; +} +Endpoint& Endpoint::operator=(const Endpoint& other1) { + ipv4 = other1.ipv4; + port = other1.port; + service_name = other1.service_name; + ipv6 = other1.ipv6; + __isset = other1.__isset; + return *this; +} +void Endpoint::printTo(std::ostream& out) const { + using ::apache::thrift::to_string; + out << "Endpoint("; + out << "ipv4=" << to_string(ipv4); + out << ", " << "port=" << to_string(port); + out << ", " << "service_name=" << to_string(service_name); + out << ", " << "ipv6="; (__isset.ipv6 ? (out << to_string(ipv6)) : (out << "")); + out << ")"; +} + + +Annotation::~Annotation() noexcept { +} + + +void Annotation::__set_timestamp(const int64_t val) { + this->timestamp = val; +} + +void Annotation::__set_value(const std::string& val) { + this->value = val; +} + +void Annotation::__set_host(const Endpoint& val) { + this->host = val; +__isset.host = true; +} +std::ostream& operator<<(std::ostream& out, const Annotation& obj) +{ + obj.printTo(out); + return out; +} + + +uint32_t Annotation::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_I64) { + xfer += iprot->readI64(this->timestamp); + this->__isset.timestamp = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 2: + if (ftype == ::apache::thrift::protocol::T_STRING) { + xfer += iprot->readString(this->value); + this->__isset.value = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 3: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->host.read(iprot); + this->__isset.host = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t Annotation::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("Annotation"); + + xfer += oprot->writeFieldBegin("timestamp", ::apache::thrift::protocol::T_I64, 1); + xfer += oprot->writeI64(this->timestamp); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("value", ::apache::thrift::protocol::T_STRING, 2); + xfer += oprot->writeString(this->value); + xfer += oprot->writeFieldEnd(); + + if (this->__isset.host) { + xfer += oprot->writeFieldBegin("host", ::apache::thrift::protocol::T_STRUCT, 3); + xfer += this->host.write(oprot); + xfer += oprot->writeFieldEnd(); + } + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +void swap(Annotation &a, Annotation &b) { + using ::std::swap; + swap(a.timestamp, b.timestamp); + swap(a.value, b.value); + swap(a.host, b.host); + swap(a.__isset, b.__isset); +} + +Annotation::Annotation(const Annotation& other2) { + timestamp = other2.timestamp; + value = other2.value; + host = other2.host; + __isset = other2.__isset; +} +Annotation& Annotation::operator=(const Annotation& other3) { + timestamp = other3.timestamp; + value = other3.value; + host = other3.host; + __isset = other3.__isset; + return *this; +} +void Annotation::printTo(std::ostream& out) const { + using ::apache::thrift::to_string; + out << "Annotation("; + out << "timestamp=" << to_string(timestamp); + out << ", " << "value=" << to_string(value); + out << ", " << "host="; (__isset.host ? (out << to_string(host)) : (out << "")); + out << ")"; +} + + +BinaryAnnotation::~BinaryAnnotation() noexcept { +} + + +void BinaryAnnotation::__set_key(const std::string& val) { + this->key = val; +} + +void BinaryAnnotation::__set_value(const std::string& val) { + this->value = val; +} + +void BinaryAnnotation::__set_annotation_type(const AnnotationType::type val) { + this->annotation_type = val; +} + +void BinaryAnnotation::__set_host(const Endpoint& val) { + this->host = val; +__isset.host = true; +} +std::ostream& operator<<(std::ostream& out, const BinaryAnnotation& obj) +{ + obj.printTo(out); + return out; +} + + +uint32_t BinaryAnnotation::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_STRING) { + xfer += iprot->readString(this->key); + this->__isset.key = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 2: + if (ftype == ::apache::thrift::protocol::T_STRING) { + xfer += iprot->readBinary(this->value); + this->__isset.value = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 3: + if (ftype == ::apache::thrift::protocol::T_I32) { + int32_t ecast4; + xfer += iprot->readI32(ecast4); + this->annotation_type = (AnnotationType::type)ecast4; + this->__isset.annotation_type = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 4: + if (ftype == ::apache::thrift::protocol::T_STRUCT) { + xfer += this->host.read(iprot); + this->__isset.host = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t BinaryAnnotation::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("BinaryAnnotation"); + + xfer += oprot->writeFieldBegin("key", ::apache::thrift::protocol::T_STRING, 1); + xfer += oprot->writeString(this->key); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("value", ::apache::thrift::protocol::T_STRING, 2); + xfer += oprot->writeBinary(this->value); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("annotation_type", ::apache::thrift::protocol::T_I32, 3); + xfer += oprot->writeI32((int32_t)this->annotation_type); + xfer += oprot->writeFieldEnd(); + + if (this->__isset.host) { + xfer += oprot->writeFieldBegin("host", ::apache::thrift::protocol::T_STRUCT, 4); + xfer += this->host.write(oprot); + xfer += oprot->writeFieldEnd(); + } + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +void swap(BinaryAnnotation &a, BinaryAnnotation &b) { + using ::std::swap; + swap(a.key, b.key); + swap(a.value, b.value); + swap(a.annotation_type, b.annotation_type); + swap(a.host, b.host); + swap(a.__isset, b.__isset); +} + +BinaryAnnotation::BinaryAnnotation(const BinaryAnnotation& other5) { + key = other5.key; + value = other5.value; + annotation_type = other5.annotation_type; + host = other5.host; + __isset = other5.__isset; +} +BinaryAnnotation& BinaryAnnotation::operator=(const BinaryAnnotation& other6) { + key = other6.key; + value = other6.value; + annotation_type = other6.annotation_type; + host = other6.host; + __isset = other6.__isset; + return *this; +} +void BinaryAnnotation::printTo(std::ostream& out) const { + using ::apache::thrift::to_string; + out << "BinaryAnnotation("; + out << "key=" << to_string(key); + out << ", " << "value=" << to_string(value); + out << ", " << "annotation_type=" << to_string(annotation_type); + out << ", " << "host="; (__isset.host ? (out << to_string(host)) : (out << "")); + out << ")"; +} + + +Span::~Span() noexcept { +} + + +void Span::__set_trace_id(const int64_t val) { + this->trace_id = val; +} + +void Span::__set_name(const std::string& val) { + this->name = val; +} + +void Span::__set_id(const int64_t val) { + this->id = val; +} + +void Span::__set_parent_id(const int64_t val) { + this->parent_id = val; +__isset.parent_id = true; +} + +void Span::__set_annotations(const std::vector & val) { + this->annotations = val; +} + +void Span::__set_binary_annotations(const std::vector & val) { + this->binary_annotations = val; +} + +void Span::__set_debug(const bool val) { + this->debug = val; +__isset.debug = true; +} + +void Span::__set_timestamp(const int64_t val) { + this->timestamp = val; +__isset.timestamp = true; +} + +void Span::__set_duration(const int64_t val) { + this->duration = val; +__isset.duration = true; +} + +void Span::__set_trace_id_high(const int64_t val) { + this->trace_id_high = val; +__isset.trace_id_high = true; +} +std::ostream& operator<<(std::ostream& out, const Span& obj) +{ + obj.printTo(out); + return out; +} + + +uint32_t Span::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_I64) { + xfer += iprot->readI64(this->trace_id); + this->__isset.trace_id = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 3: + if (ftype == ::apache::thrift::protocol::T_STRING) { + xfer += iprot->readString(this->name); + this->__isset.name = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 4: + if (ftype == ::apache::thrift::protocol::T_I64) { + xfer += iprot->readI64(this->id); + this->__isset.id = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 5: + if (ftype == ::apache::thrift::protocol::T_I64) { + xfer += iprot->readI64(this->parent_id); + this->__isset.parent_id = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 6: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + this->annotations.clear(); + uint32_t _size7; + ::apache::thrift::protocol::TType _etype10; + xfer += iprot->readListBegin(_etype10, _size7); + this->annotations.resize(_size7); + uint32_t _i11; + for (_i11 = 0; _i11 < _size7; ++_i11) + { + xfer += this->annotations[_i11].read(iprot); + } + xfer += iprot->readListEnd(); + } + this->__isset.annotations = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 8: + if (ftype == ::apache::thrift::protocol::T_LIST) { + { + this->binary_annotations.clear(); + uint32_t _size12; + ::apache::thrift::protocol::TType _etype15; + xfer += iprot->readListBegin(_etype15, _size12); + this->binary_annotations.resize(_size12); + uint32_t _i16; + for (_i16 = 0; _i16 < _size12; ++_i16) + { + xfer += this->binary_annotations[_i16].read(iprot); + } + xfer += iprot->readListEnd(); + } + this->__isset.binary_annotations = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 9: + if (ftype == ::apache::thrift::protocol::T_BOOL) { + xfer += iprot->readBool(this->debug); + this->__isset.debug = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 10: + if (ftype == ::apache::thrift::protocol::T_I64) { + xfer += iprot->readI64(this->timestamp); + this->__isset.timestamp = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 11: + if (ftype == ::apache::thrift::protocol::T_I64) { + xfer += iprot->readI64(this->duration); + this->__isset.duration = true; + } else { + xfer += iprot->skip(ftype); + } + break; + case 12: + if (ftype == ::apache::thrift::protocol::T_I64) { + xfer += iprot->readI64(this->trace_id_high); + this->__isset.trace_id_high = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + return xfer; +} + +uint32_t Span::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("Span"); + + xfer += oprot->writeFieldBegin("trace_id", ::apache::thrift::protocol::T_I64, 1); + xfer += oprot->writeI64(this->trace_id); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("name", ::apache::thrift::protocol::T_STRING, 3); + xfer += oprot->writeString(this->name); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("id", ::apache::thrift::protocol::T_I64, 4); + xfer += oprot->writeI64(this->id); + xfer += oprot->writeFieldEnd(); + + if (this->__isset.parent_id) { + xfer += oprot->writeFieldBegin("parent_id", ::apache::thrift::protocol::T_I64, 5); + xfer += oprot->writeI64(this->parent_id); + xfer += oprot->writeFieldEnd(); + } + xfer += oprot->writeFieldBegin("annotations", ::apache::thrift::protocol::T_LIST, 6); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->annotations.size())); + std::vector ::const_iterator _iter17; + for (_iter17 = this->annotations.begin(); _iter17 != this->annotations.end(); ++_iter17) + { + xfer += (*_iter17).write(oprot); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldBegin("binary_annotations", ::apache::thrift::protocol::T_LIST, 8); + { + xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast(this->binary_annotations.size())); + std::vector ::const_iterator _iter18; + for (_iter18 = this->binary_annotations.begin(); _iter18 != this->binary_annotations.end(); ++_iter18) + { + xfer += (*_iter18).write(oprot); + } + xfer += oprot->writeListEnd(); + } + xfer += oprot->writeFieldEnd(); + + if (this->__isset.debug) { + xfer += oprot->writeFieldBegin("debug", ::apache::thrift::protocol::T_BOOL, 9); + xfer += oprot->writeBool(this->debug); + xfer += oprot->writeFieldEnd(); + } + if (this->__isset.timestamp) { + xfer += oprot->writeFieldBegin("timestamp", ::apache::thrift::protocol::T_I64, 10); + xfer += oprot->writeI64(this->timestamp); + xfer += oprot->writeFieldEnd(); + } + if (this->__isset.duration) { + xfer += oprot->writeFieldBegin("duration", ::apache::thrift::protocol::T_I64, 11); + xfer += oprot->writeI64(this->duration); + xfer += oprot->writeFieldEnd(); + } + if (this->__isset.trace_id_high) { + xfer += oprot->writeFieldBegin("trace_id_high", ::apache::thrift::protocol::T_I64, 12); + xfer += oprot->writeI64(this->trace_id_high); + xfer += oprot->writeFieldEnd(); + } + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +void swap(Span &a, Span &b) { + using ::std::swap; + swap(a.trace_id, b.trace_id); + swap(a.name, b.name); + swap(a.id, b.id); + swap(a.parent_id, b.parent_id); + swap(a.annotations, b.annotations); + swap(a.binary_annotations, b.binary_annotations); + swap(a.debug, b.debug); + swap(a.timestamp, b.timestamp); + swap(a.duration, b.duration); + swap(a.trace_id_high, b.trace_id_high); + swap(a.__isset, b.__isset); +} + +Span::Span(const Span& other19) { + trace_id = other19.trace_id; + name = other19.name; + id = other19.id; + parent_id = other19.parent_id; + annotations = other19.annotations; + binary_annotations = other19.binary_annotations; + debug = other19.debug; + timestamp = other19.timestamp; + duration = other19.duration; + trace_id_high = other19.trace_id_high; + __isset = other19.__isset; +} +Span& Span::operator=(const Span& other20) { + trace_id = other20.trace_id; + name = other20.name; + id = other20.id; + parent_id = other20.parent_id; + annotations = other20.annotations; + binary_annotations = other20.binary_annotations; + debug = other20.debug; + timestamp = other20.timestamp; + duration = other20.duration; + trace_id_high = other20.trace_id_high; + __isset = other20.__isset; + return *this; +} +void Span::printTo(std::ostream& out) const { + using ::apache::thrift::to_string; + out << "Span("; + out << "trace_id=" << to_string(trace_id); + out << ", " << "name=" << to_string(name); + out << ", " << "id=" << to_string(id); + out << ", " << "parent_id="; (__isset.parent_id ? (out << to_string(parent_id)) : (out << "")); + out << ", " << "annotations=" << to_string(annotations); + out << ", " << "binary_annotations=" << to_string(binary_annotations); + out << ", " << "debug="; (__isset.debug ? (out << to_string(debug)) : (out << "")); + out << ", " << "timestamp="; (__isset.timestamp ? (out << to_string(timestamp)) : (out << "")); + out << ", " << "duration="; (__isset.duration ? (out << to_string(duration)) : (out << "")); + out << ", " << "trace_id_high="; (__isset.trace_id_high ? (out << to_string(trace_id_high)) : (out << "")); + out << ")"; +} + + +Response::~Response() noexcept { +} + + +void Response::__set_ok(const bool val) { + this->ok = val; +} +std::ostream& operator<<(std::ostream& out, const Response& obj) +{ + obj.printTo(out); + return out; +} + + +uint32_t Response::read(::apache::thrift::protocol::TProtocol* iprot) { + + ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); + uint32_t xfer = 0; + std::string fname; + ::apache::thrift::protocol::TType ftype; + int16_t fid; + + xfer += iprot->readStructBegin(fname); + + using ::apache::thrift::protocol::TProtocolException; + + bool isset_ok = false; + + while (true) + { + xfer += iprot->readFieldBegin(fname, ftype, fid); + if (ftype == ::apache::thrift::protocol::T_STOP) { + break; + } + switch (fid) + { + case 1: + if (ftype == ::apache::thrift::protocol::T_BOOL) { + xfer += iprot->readBool(this->ok); + isset_ok = true; + } else { + xfer += iprot->skip(ftype); + } + break; + default: + xfer += iprot->skip(ftype); + break; + } + xfer += iprot->readFieldEnd(); + } + + xfer += iprot->readStructEnd(); + + if (!isset_ok) + throw TProtocolException(TProtocolException::INVALID_DATA); + return xfer; +} + +uint32_t Response::write(::apache::thrift::protocol::TProtocol* oprot) const { + uint32_t xfer = 0; + ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); + xfer += oprot->writeStructBegin("Response"); + + xfer += oprot->writeFieldBegin("ok", ::apache::thrift::protocol::T_BOOL, 1); + xfer += oprot->writeBool(this->ok); + xfer += oprot->writeFieldEnd(); + + xfer += oprot->writeFieldStop(); + xfer += oprot->writeStructEnd(); + return xfer; +} + +void swap(Response &a, Response &b) { + using ::std::swap; + swap(a.ok, b.ok); +} + +Response::Response(const Response& other21) { + ok = other21.ok; +} +Response& Response::operator=(const Response& other22) { + ok = other22.ok; + return *this; +} +void Response::printTo(std::ostream& out) const { + using ::apache::thrift::to_string; + out << "Response("; + out << "ok=" << to_string(ok); + out << ")"; +} + +}}} // namespace diff --git a/exporters/jaeger/thrift-gen/zipkincore_types.h b/exporters/jaeger/thrift-gen/zipkincore_types.h new file mode 100644 index 0000000000..c03421f434 --- /dev/null +++ b/exporters/jaeger/thrift-gen/zipkincore_types.h @@ -0,0 +1,493 @@ +/** + * Autogenerated by Thrift Compiler (0.14.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +#ifndef zipkincore_TYPES_H +#define zipkincore_TYPES_H + +#include + +#include +#include +#include +#include +#include + +#include +#include + + +namespace twitter { namespace zipkin { namespace thrift { + +struct AnnotationType { + enum type { + BOOL = 0, + BYTES = 1, + I16 = 2, + I32 = 3, + I64 = 4, + DOUBLE = 5, + STRING = 6 + }; +}; + +extern const std::map _AnnotationType_VALUES_TO_NAMES; + +std::ostream& operator<<(std::ostream& out, const AnnotationType::type& val); + +std::string to_string(const AnnotationType::type& val); + +class Endpoint; + +class Annotation; + +class BinaryAnnotation; + +class Span; + +class Response; + +typedef struct _Endpoint__isset { + _Endpoint__isset() : ipv4(false), port(false), service_name(false), ipv6(false) {} + bool ipv4 :1; + bool port :1; + bool service_name :1; + bool ipv6 :1; +} _Endpoint__isset; + +/** + * Indicates the network context of a service recording an annotation with two + * exceptions. + * + * When a BinaryAnnotation, and key is CLIENT_ADDR or SERVER_ADDR, + * the endpoint indicates the source or destination of an RPC. This exception + * allows zipkin to display network context of uninstrumented services, or + * clients such as web browsers. + */ +class Endpoint : public virtual ::apache::thrift::TBase { + public: + + Endpoint(const Endpoint&); + Endpoint& operator=(const Endpoint&); + Endpoint() : ipv4(0), port(0), service_name(), ipv6() { + } + + virtual ~Endpoint() noexcept; + /** + * IPv4 host address packed into 4 bytes. + * + * Ex for the ip 1.2.3.4, it would be (1 << 24) | (2 << 16) | (3 << 8) | 4 + */ + int32_t ipv4; + /** + * IPv4 port + * + * Note: this is to be treated as an unsigned integer, so watch for negatives. + * + * Conventionally, when the port isn't known, port = 0. + */ + int16_t port; + /** + * Service name in lowercase, such as "memcache" or "zipkin-web" + * + * Conventionally, when the service name isn't known, service_name = "unknown". + */ + std::string service_name; + /** + * IPv6 host address packed into 16 bytes. Ex Inet6Address.getBytes() + */ + std::string ipv6; + + _Endpoint__isset __isset; + + void __set_ipv4(const int32_t val); + + void __set_port(const int16_t val); + + void __set_service_name(const std::string& val); + + void __set_ipv6(const std::string& val); + + bool operator == (const Endpoint & rhs) const + { + if (!(ipv4 == rhs.ipv4)) + return false; + if (!(port == rhs.port)) + return false; + if (!(service_name == rhs.service_name)) + return false; + if (__isset.ipv6 != rhs.__isset.ipv6) + return false; + else if (__isset.ipv6 && !(ipv6 == rhs.ipv6)) + return false; + return true; + } + bool operator != (const Endpoint &rhs) const { + return !(*this == rhs); + } + + bool operator < (const Endpoint & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + + virtual void printTo(std::ostream& out) const; +}; + +void swap(Endpoint &a, Endpoint &b); + +std::ostream& operator<<(std::ostream& out, const Endpoint& obj); + +typedef struct _Annotation__isset { + _Annotation__isset() : timestamp(false), value(false), host(false) {} + bool timestamp :1; + bool value :1; + bool host :1; +} _Annotation__isset; + +/** + * An annotation is similar to a log statement. It includes a host field which + * allows these events to be attributed properly, and also aggregatable. + */ +class Annotation : public virtual ::apache::thrift::TBase { + public: + + Annotation(const Annotation&); + Annotation& operator=(const Annotation&); + Annotation() : timestamp(0), value() { + } + + virtual ~Annotation() noexcept; + /** + * Microseconds from epoch. + * + * This value should use the most precise value possible. For example, + * gettimeofday or syncing nanoTime against a tick of currentTimeMillis. + */ + int64_t timestamp; + std::string value; + /** + * Always the host that recorded the event. By specifying the host you allow + * rollup of all events (such as client requests to a service) by IP address. + */ + Endpoint host; + + _Annotation__isset __isset; + + void __set_timestamp(const int64_t val); + + void __set_value(const std::string& val); + + void __set_host(const Endpoint& val); + + bool operator == (const Annotation & rhs) const + { + if (!(timestamp == rhs.timestamp)) + return false; + if (!(value == rhs.value)) + return false; + if (__isset.host != rhs.__isset.host) + return false; + else if (__isset.host && !(host == rhs.host)) + return false; + return true; + } + bool operator != (const Annotation &rhs) const { + return !(*this == rhs); + } + + bool operator < (const Annotation & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + + virtual void printTo(std::ostream& out) const; +}; + +void swap(Annotation &a, Annotation &b); + +std::ostream& operator<<(std::ostream& out, const Annotation& obj); + +typedef struct _BinaryAnnotation__isset { + _BinaryAnnotation__isset() : key(false), value(false), annotation_type(false), host(false) {} + bool key :1; + bool value :1; + bool annotation_type :1; + bool host :1; +} _BinaryAnnotation__isset; + +/** + * Binary annotations are tags applied to a Span to give it context. For + * example, a binary annotation of "http.uri" could the path to a resource in a + * RPC call. + * + * Binary annotations of type STRING are always queryable, though more a + * historical implementation detail than a structural concern. + * + * Binary annotations can repeat, and vary on the host. Similar to Annotation, + * the host indicates who logged the event. This allows you to tell the + * difference between the client and server side of the same key. For example, + * the key "http.uri" might be different on the client and server side due to + * rewriting, like "/api/v1/myresource" vs "/myresource. Via the host field, + * you can see the different points of view, which often help in debugging. + */ +class BinaryAnnotation : public virtual ::apache::thrift::TBase { + public: + + BinaryAnnotation(const BinaryAnnotation&); + BinaryAnnotation& operator=(const BinaryAnnotation&); + BinaryAnnotation() : key(), value(), annotation_type((AnnotationType::type)0) { + } + + virtual ~BinaryAnnotation() noexcept; + std::string key; + std::string value; + /** + * + * @see AnnotationType + */ + AnnotationType::type annotation_type; + /** + * The host that recorded tag, which allows you to differentiate between + * multiple tags with the same key. There are two exceptions to this. + * + * When the key is CLIENT_ADDR or SERVER_ADDR, host indicates the source or + * destination of an RPC. This exception allows zipkin to display network + * context of uninstrumented services, or clients such as web browsers. + */ + Endpoint host; + + _BinaryAnnotation__isset __isset; + + void __set_key(const std::string& val); + + void __set_value(const std::string& val); + + void __set_annotation_type(const AnnotationType::type val); + + void __set_host(const Endpoint& val); + + bool operator == (const BinaryAnnotation & rhs) const + { + if (!(key == rhs.key)) + return false; + if (!(value == rhs.value)) + return false; + if (!(annotation_type == rhs.annotation_type)) + return false; + if (__isset.host != rhs.__isset.host) + return false; + else if (__isset.host && !(host == rhs.host)) + return false; + return true; + } + bool operator != (const BinaryAnnotation &rhs) const { + return !(*this == rhs); + } + + bool operator < (const BinaryAnnotation & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + + virtual void printTo(std::ostream& out) const; +}; + +void swap(BinaryAnnotation &a, BinaryAnnotation &b); + +std::ostream& operator<<(std::ostream& out, const BinaryAnnotation& obj); + +typedef struct _Span__isset { + _Span__isset() : trace_id(false), name(false), id(false), parent_id(false), annotations(false), binary_annotations(false), debug(true), timestamp(false), duration(false), trace_id_high(false) {} + bool trace_id :1; + bool name :1; + bool id :1; + bool parent_id :1; + bool annotations :1; + bool binary_annotations :1; + bool debug :1; + bool timestamp :1; + bool duration :1; + bool trace_id_high :1; +} _Span__isset; + +/** + * A trace is a series of spans (often RPC calls) which form a latency tree. + * + * The root span is where trace_id = id and parent_id = Nil. The root span is + * usually the longest interval in the trace, starting with a SERVER_RECV + * annotation and ending with a SERVER_SEND. + */ +class Span : public virtual ::apache::thrift::TBase { + public: + + Span(const Span&); + Span& operator=(const Span&); + Span() : trace_id(0), name(), id(0), parent_id(0), debug(false), timestamp(0), duration(0), trace_id_high(0) { + } + + virtual ~Span() noexcept; + int64_t trace_id; + /** + * Span name in lowercase, rpc method for example + * + * Conventionally, when the span name isn't known, name = "unknown". + */ + std::string name; + int64_t id; + int64_t parent_id; + std::vector annotations; + std::vector binary_annotations; + bool debug; + /** + * Microseconds from epoch of the creation of this span. + * + * This value should be set directly by instrumentation, using the most + * precise value possible. For example, gettimeofday or syncing nanoTime + * against a tick of currentTimeMillis. + * + * For compatibility with instrumentation that precede this field, collectors + * or span stores can derive this via Annotation.timestamp. + * For example, SERVER_RECV.timestamp or CLIENT_SEND.timestamp. + * + * This field is optional for compatibility with old data: first-party span + * stores are expected to support this at time of introduction. + */ + int64_t timestamp; + /** + * Measurement of duration in microseconds, used to support queries. + * + * This value should be set directly, where possible. Doing so encourages + * precise measurement decoupled from problems of clocks, such as skew or NTP + * updates causing time to move backwards. + * + * For compatibility with instrumentation that precede this field, collectors + * or span stores can derive this by subtracting Annotation.timestamp. + * For example, SERVER_SEND.timestamp - SERVER_RECV.timestamp. + * + * If this field is persisted as unset, zipkin will continue to work, except + * duration query support will be implementation-specific. Similarly, setting + * this field non-atomically is implementation-specific. + * + * This field is i64 vs i32 to support spans longer than 35 minutes. + */ + int64_t duration; + /** + * Optional unique 8-byte additional identifier for a trace. If non zero, this + * means the trace uses 128 bit traceIds instead of 64 bit. + */ + int64_t trace_id_high; + + _Span__isset __isset; + + void __set_trace_id(const int64_t val); + + void __set_name(const std::string& val); + + void __set_id(const int64_t val); + + void __set_parent_id(const int64_t val); + + void __set_annotations(const std::vector & val); + + void __set_binary_annotations(const std::vector & val); + + void __set_debug(const bool val); + + void __set_timestamp(const int64_t val); + + void __set_duration(const int64_t val); + + void __set_trace_id_high(const int64_t val); + + bool operator == (const Span & rhs) const + { + if (!(trace_id == rhs.trace_id)) + return false; + if (!(name == rhs.name)) + return false; + if (!(id == rhs.id)) + return false; + if (__isset.parent_id != rhs.__isset.parent_id) + return false; + else if (__isset.parent_id && !(parent_id == rhs.parent_id)) + return false; + if (!(annotations == rhs.annotations)) + return false; + if (!(binary_annotations == rhs.binary_annotations)) + return false; + if (__isset.debug != rhs.__isset.debug) + return false; + else if (__isset.debug && !(debug == rhs.debug)) + return false; + if (__isset.timestamp != rhs.__isset.timestamp) + return false; + else if (__isset.timestamp && !(timestamp == rhs.timestamp)) + return false; + if (__isset.duration != rhs.__isset.duration) + return false; + else if (__isset.duration && !(duration == rhs.duration)) + return false; + if (__isset.trace_id_high != rhs.__isset.trace_id_high) + return false; + else if (__isset.trace_id_high && !(trace_id_high == rhs.trace_id_high)) + return false; + return true; + } + bool operator != (const Span &rhs) const { + return !(*this == rhs); + } + + bool operator < (const Span & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + + virtual void printTo(std::ostream& out) const; +}; + +void swap(Span &a, Span &b); + +std::ostream& operator<<(std::ostream& out, const Span& obj); + + +class Response : public virtual ::apache::thrift::TBase { + public: + + Response(const Response&); + Response& operator=(const Response&); + Response() : ok(0) { + } + + virtual ~Response() noexcept; + bool ok; + + void __set_ok(const bool val); + + bool operator == (const Response & rhs) const + { + if (!(ok == rhs.ok)) + return false; + return true; + } + bool operator != (const Response &rhs) const { + return !(*this == rhs); + } + + bool operator < (const Response & ) const; + + uint32_t read(::apache::thrift::protocol::TProtocol* iprot); + uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const; + + virtual void printTo(std::ostream& out) const; +}; + +void swap(Response &a, Response &b); + +std::ostream& operator<<(std::ostream& out, const Response& obj); + +}}} // namespace + +#endif diff --git a/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_data.h b/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_data.h index 34d6d4865e..d2c9ca3271 100644 --- a/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_data.h +++ b/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_data.h @@ -3,7 +3,8 @@ #include "opentelemetry/sdk/common/circular_buffer.h" #include "opentelemetry/sdk/trace/recordable.h" #include "opentelemetry/sdk/trace/span_data.h" -#include "vector" + +#include OPENTELEMETRY_BEGIN_NAMESPACE namespace exporter diff --git a/tools/format.sh b/tools/format.sh index 28b793cbc3..6f5ae40d56 100755 --- a/tools/format.sh +++ b/tools/format.sh @@ -6,7 +6,7 @@ fi set -e -FIND="find . -name third_party -prune -o -name tools -prune -o -name .git -prune -o -name _deps -prune -o -name .build -prune -o -name out -prune -o -name .vs -prune -o -name opentelemetry_logo.png -prune -o -name TraceLoggingDynamic.h -prune -o" +FIND="find . -name third_party -prune -o -name tools -prune -o -name .git -prune -o -name _deps -prune -o -name .build -prune -o -name out -prune -o -name .vs -prune -o -name opentelemetry_logo.png -prune -o -name TraceLoggingDynamic.h -prune -o -name thrift-gen -prune -o" # GNU syntax. SED=(sed -i)