Skip to content
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

Add OTLP/HTTP+JSON Protocol exporter #810

Merged
merged 7 commits into from
Jun 8, 2021

Conversation

owent
Copy link
Member

@owent owent commented May 30, 2021

Signed-off-by: owent [email protected]

Fixes # 803

Changes

Implementation of HTTP(OTLP/HTTP+JSON Protocol) exporter.

This is a uncompleted PR and it's used to discuss the details of API and changes for now. I will add tests and CHANGELOG some time later.

Almost finished.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@owent owent requested a review from a team May 30, 2021 15:25
@codecov
Copy link

codecov bot commented May 30, 2021

Codecov Report

Merging #810 (eaca36e) into main (12946c8) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #810   +/-   ##
=======================================
  Coverage   95.50%   95.50%           
=======================================
  Files         156      156           
  Lines        6619     6619           
=======================================
  Hits         6321     6321           
  Misses        298      298           

@lalitb
Copy link
Member

lalitb commented May 31, 2021

I add a OtlpHttpExporter , should we rename OtlpExporter into OtlpGrpcExporter and rename otlp_exporter.h|.cpp into otlp_exporter.h/.cpp ? It's a break change.

I agree we should rename OtlpExporter into OtlpGrpcExporter. We are not GA yet, so breaking changes are expected, and should be acceptable.

Copy link
Member

@lalitb lalitb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the contribution :)

CMakeLists.txt Show resolved Hide resolved
/**
* Create an OtlpHttpExporter using the given options.
*/
OtlpHttpExporter(const OtlpHttpExporterOptions &options);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit - can we make this explicit. I think this is missing for OtlpGrpcExporter too which also should be modified.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My negligence. I will add explicit later and add some tests.

urls = [
"https://github.com/grpc/grpc/archive/v1.28.0.tar.gz",
"https://github.com/grpc/grpc/archive/v1.33.2.tar.gz",
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

git clone --depth=1 -b v1.34.0 https://github.com/grpc/grpc

Copy link
Member Author

Choose a reason for hiding this comment

The 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.
setup_grpc.sh is only used when using cmake, not bazel.
I found grpc 1.34 upgrade abseil-cpp to 2020923.2 and it uses something gcc 4.8 do not support.
I submit another PR #666 and try to upgrade gRPC but failed on legacy toolchain. Maybe some one can help to switch the
grpc to old version or just disable OTLP Exporters when using bazel?I'm not familar with bazel.

Copy link
Contributor

@maxgolov maxgolov Jun 4, 2021

Choose a reason for hiding this comment

The 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 framework

I hope that one works with Visual Studio 2015 Update 2 and above.

Copy link
Member Author

@owent owent Jun 4, 2021

Choose a reason for hiding this comment

The 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.

@@ -42,7 +43,8 @@ docker run --rm -it -p 4317:4317 -v "%cd%/examples/otlp":/cfg otel/opentelemetry

Note that the OTLP exporter connects to the Collector at `localhost:4317` by
default. This can be changed with first argument from command-line, for example:
`./example_otlp gateway.docker.internal:4317`.
`./example_otlp_grpc gateway.docker.internal:4317` and
`./example_otlp_http gateway.docker.internal:4317`..
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: 2 dots at the end of line 47.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@@ -1,4 +1,4 @@
if(WITH_OTLP)
if(WITH_OTLP_GRPC OR WITH_OTLP_HTTP)
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor

Choose a reason for hiding this comment

The 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 WITH_OTLP to include both but then it seems over complicated.

Copy link
Member Author

@owent owent Jun 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometimes we want only either WITH_OTLP_GRPC or WITH_OTLP_HTTP .
Set WITH_OTLP=ON will try to turn WITH_OTLP_GRPC on when grpc is found and turn WITH_OTLP_HTTP on when both libcurl and nlohmann_json are found in this PR.
The WITH_OTLP option is just for backward compatibility, and the actually options take effect is WITH_OTLP_GRPC and WITH_OTLP_HTTP now.

@owent
Copy link
Member Author

owent commented Jun 4, 2021

Please do not merge this PR right now. I will add test codes and support for application/x-protobuf later.

All jobs done, could you please review the changes again? @maxgolov @ThomsonTan @lalitb

@owent owent force-pushed the otlp_http_exporter branch from 1e7054d to 69e4f24 Compare June 5, 2021 04:42
@owent owent mentioned this pull request Jun 5, 2021
3 tasks
Copy link
Member

@lalitb lalitb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for adding the tests.

owent added 7 commits June 7, 2021 19:28
…tlp_exporter.cpp` to `OtlpGrpcExporter`, `OtlpGrpcExporterOptions`, `otlp_grpc_exporter.h`, `otlp_grpc_exporter.cpp`

+ Update gRPC to 1.33.2(which is the first version support bazel 4+ and the last version support gcc 4.8)

Signed-off-by: owent <[email protected]>
@lalitb lalitb mentioned this pull request Mar 22, 2022
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants