-
Notifications
You must be signed in to change notification settings - Fork 558
Add OTLP/HTTP+JSON Protocol exporter #810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5e91f3e
ad3a6cf
dcc66c6
5e502df
2cdf438
d4d3459
eaca36e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -29,13 +29,23 @@ def opentelemetry_cpp_deps(): | |||
| ) | ||||
|
|
||||
| # Load gRPC dependency | ||||
| maybe( | ||||
| http_archive, | ||||
| name = "com_github_grpc_grpc_legacy", | ||||
| sha256 = "2060769f2d4b0d3535ba594b2ab614d7f68a492f786ab94b4318788d45e3278a", | ||||
| strip_prefix = "grpc-1.33.2", | ||||
| urls = [ | ||||
| "https://github.com/grpc/grpc/archive/v1.33.2.tar.gz", | ||||
| ], | ||||
| ) | ||||
|
|
||||
| maybe( | ||||
| http_archive, | ||||
| name = "com_github_grpc_grpc", | ||||
| sha256 = "d6277f77e0bb922d3f6f56c0f93292bb4cfabfc3c92b31ee5ccea0e100303612", | ||||
| strip_prefix = "grpc-1.28.0", | ||||
| sha256 = "2060769f2d4b0d3535ba594b2ab614d7f68a492f786ab94b4318788d45e3278a", | ||||
| strip_prefix = "grpc-1.33.2", | ||||
| urls = [ | ||||
| "https://github.com/grpc/grpc/archive/v1.28.0.tar.gz", | ||||
| "https://github.com/grpc/grpc/archive/v1.33.2.tar.gz", | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why upgrade this to 1.33? I think 1.34 is used in our CI. opentelemetry-cpp/ci/setup_grpc.sh Line 16 in 0f6199f
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think 1.33 is the only version support both bazel 4+ and legacy gcc 4.8.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume for Windows, while eventually getting to prebuilt DLL / SDK, we can most likely use whatever recent version of gRPC from vcpkg? Mine right now is 1.37.0 C:\work\opentelemetry-cpp\tools\vcpkg>vcpkg list grpc
grpc:x64-windows 1.37.0#2 An RPC library and frameworkI hope that one works with Visual Studio 2015 Update 2 and above.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tested several toolchains with different versions of gRPC, and here is the result:
Right now, we have legacy gcc 4.8 in CI matrix, so I just update gRPC in bazel to 1.33 for compatiability. Maybe it can be upgraded to newer version in the future and in another PR. |
||||
| ], | ||||
| ) | ||||
|
|
||||
|
|
||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| if(WITH_OTLP) | ||
| if(WITH_OTLP_GRPC OR WITH_OTLP_HTTP) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need that level of granularity, can one flag build both?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is rare for one build to have both, so 2 flags make sense. Or we could introduce a third flag
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sometimes we want only either |
||
| add_subdirectory(otlp) | ||
| add_subdirectory(grpc) | ||
| endif() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #include "opentelemetry/exporters/otlp/otlp_http_exporter.h" | ||
| #include "opentelemetry/sdk/trace/simple_processor.h" | ||
| #include "opentelemetry/sdk/trace/tracer_provider.h" | ||
| #include "opentelemetry/trace/provider.h" | ||
|
|
||
| #include <string> | ||
|
|
||
| #include "foo_library/foo_library.h" | ||
|
|
||
| namespace trace = opentelemetry::trace; | ||
| namespace nostd = opentelemetry::nostd; | ||
| namespace sdktrace = opentelemetry::sdk::trace; | ||
| namespace otlp = opentelemetry::exporter::otlp; | ||
|
|
||
| namespace | ||
| { | ||
| opentelemetry::exporter::otlp::OtlpHttpExporterOptions opts; | ||
| void InitTracer() | ||
| { | ||
| // Create OTLP exporter instance | ||
| auto exporter = std::unique_ptr<sdktrace::SpanExporter>(new otlp::OtlpHttpExporter(opts)); | ||
| auto processor = std::unique_ptr<sdktrace::SpanProcessor>( | ||
| new sdktrace::SimpleSpanProcessor(std::move(exporter))); | ||
| auto provider = | ||
| nostd::shared_ptr<trace::TracerProvider>(new sdktrace::TracerProvider(std::move(processor))); | ||
| // Set the global trace provider | ||
| trace::Provider::SetTracerProvider(provider); | ||
| } | ||
| } // namespace | ||
|
|
||
| int main(int argc, char *argv[]) | ||
| { | ||
| if (argc > 1) | ||
| { | ||
| opts.url = argv[1]; | ||
| if (argc > 2) | ||
| { | ||
| std::string debug = argv[2]; | ||
| opts.console_debug = debug != "" && debug != "0" && debug != "no"; | ||
| } | ||
|
|
||
| if (argc > 3) | ||
| { | ||
| std::string binary_mode = argv[3]; | ||
| if (binary_mode.size() >= 3 && binary_mode.substr(0, 3) == "bin") | ||
| { | ||
| opts.content_type = opentelemetry::exporter::otlp::HttpRequestContentType::kBinary; | ||
| } | ||
| } | ||
| } | ||
| // Removing this line will leave the default noop TracerProvider in place. | ||
| InitTracer(); | ||
|
|
||
| foo_library(); | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.