-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
tracing: Support dynamically loading tracing libraries. #2252
Conversation
Signed-off-by: Ryan Burn <ryan.burn@gmail.com>
@rnburn this is sweet. Real quick comment (have not reviewed): This is going to need v2 config defined here: https://github.com/envoyproxy/data-plane-api/blob/master/api/trace.proto. (Everything now is v2 first. v1 is optional). Can you do the data-plane-api PR and then work that into this PR? |
Also, from a quick scan, this will need tests. You are probably going to have to compile some type of test driver as an .so and load it or something. Not sure what is best. |
Yes, I'm working on a mocktracer library (similar to what's in opentracing-go) that will be distributed as part of opentracing-cpp and can be used to test dynamic loading against. |
Signed-off-by: Ryan Burn <ryan.burn@gmail.com>
I added a data plane PR to support corresponding v2 options and to document the v1 options. |
Signed-off-by: Ryan Burn <ryan.burn@gmail.com>
Add options for specifying a tracing library to load dynamically (See also envoyproxy/envoy#2252.) Signed-off-by: Ryan Burn <ryan.burn@gmail.com>
@rnburn friendly ping on this. If this won't be completed for a while do you mind if we close for now and reopen when ready? |
Sorry for the delay. I just added in a mocktracer library implementing the dynamic loading interface to opentracing-cpp (opentracing/opentracing-cpp@359bafe) that I can use to add testing coverage for the dynamic loading code. I plan to do that this week. If some blocker comes up and I can't finish the PR soon, I'll close it out and reopen. |
…amic-tracing Signed-off-by: Ryan Burn <ryan.burn@gmail.com>
Signed-off-by: Ryan Burn <ryan.burn@gmail.com>
Signed-off-by: Ryan Burn <ryan.burn@gmail.com>
Signed-off-by: Ryan Burn <ryan.burn@gmail.com>
Updated to use the configuration changes from envoyproxy/data-plane-api#386. I'm adding in testing coverage next. |
@yurishkuro @isaachier -- are you ok with the build requirements that this method of dynamic loading imposes on the tracing library? Is it a build you could see supporting for Jaeger's C++ client? Just to summarize: What you need to do is
(I also outlined the approach in this SO post). |
I think CMake helps with the exports: https://cmake.org/cmake/help/v3.0/module/GenerateExportHeader.html. I can fix the linking issue. |
@rnburn re: linking, this is our first foray into dynamic linking which I think we will be doing more of in the future. We can also have a compile option for Envoy which dynamically links if that is preferable for some deployments. |
So I have a library I'm trying to figure out how to write a Any suggestions on how to do this? (also asked on SO) |
I found one way to do it: If you list a library in the data attribute for cc_test, then it will be available in the current working directory (albeit in a platform-architecture dependent location); but you can then run the |
@jmillikin-stripe @htuch any idea on @rnburn question above? |
See https://github.com/envoyproxy/envoy/blob/master/test/test_common/environment.h#L73; this is how you access the data files. Examples are the SSL cert tests, e.g. https://github.com/envoyproxy/envoy/blob/master/test/common/ssl/BUILD#L11 and https://github.com/envoyproxy/envoy/blob/master/test/common/ssl/ssl_socket_test.cc#L1115. In that example, the "rundir" is from a JSON template, but the first link I provided gives you access to the directory as a simple string. |
The library will show up in Is there an environmental variable for the |
Maybe a |
For data files with annoying complex paths like that, I've usually seen them passed to tests with the
For C++ tests in particular, I think (based on the docs) you can also put the path into a preprocessor macro with |
Signed-off-by: Ryan Burn <ryan.burn@gmail.com>
@jmillikin-stripe I tried using I wanted to at least start to get some testing in, so I went forward with using an ugly |
…amic-tracing Signed-off-by: Ryan Burn <ryan.burn@gmail.com>
Signed-off-by: Ryan Burn <ryan.burn@gmail.com>
Signed-off-by: Ryan Burn <ryan.burn@gmail.com>
I added a TODO for an example; I merged in opentracing/opentracing-cpp#45 and I updated the build so that it no longer points to my fork of opentracing-cpp. I'm going to put in a few more commits to address #2252 (comment); then I think I should be caught up with everything. |
Signed-off-by: Ryan Burn <ryan.burn@gmail.com>
Signed-off-by: Ryan Burn <ryan.burn@gmail.com>
Signed-off-by: Ryan Burn <ryan.burn@gmail.com>
code LGTM modulo the two build failures. Clean those up and you're good to go |
Signed-off-by: Ryan Burn <ryan.burn@gmail.com>
Signed-off-by: Ryan Burn <ryan.burn@gmail.com>
Signed-off-by: Ryan Burn <ryan.burn@gmail.com>
…amic-tracing Signed-off-by: Ryan Burn <ryan.burn@gmail.com>
Ok. I fixed the build. I also added more test coverage so that now these files from my last PR are covered: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. @htuch could you take a quick pass on this one before we merge?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left a couple of comments that can be addressed post-merge optionally.
throw EnvoyException{formatErrorMessage(tracer_maybe.error(), error_message)}; | ||
} | ||
tracer_ = std::move(*tracer_maybe); | ||
RELEASE_ASSERT(tracer_ != nullptr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this RELEASE_ASSERT
and not ASSERT
?
RELEASE_ASSERT(tracer_ != nullptr); | ||
} | ||
|
||
std::string DynamicOpenTracingDriver::formatErrorMessage(std::error_code error_code, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be in the anonymous namespace, it's not using any state from the instance.
|
||
DynamicOpenTracingDriver::DynamicOpenTracingDriver(Stats::Store& stats, const std::string& library, | ||
const std::string& tracer_config) | ||
: OpenTracingDriver{stats} { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tiny nit: FYI, most of Envoy doesn't use brace style when calling super.
* test envoy wasm build * circle cmake * update circle builder image * Update envoy-wasm sha to the latest * pin circle ci bazel version at 0.25.0 * update circle ci commands
* jni: fix mismatched return value types The Java side expects an `int` return value: https://github.com/envoyproxy/envoy-mobile/blob/9a397d72760acba3f3e96077f705971a8dc93d91/library/java/io/envoyproxy/envoymobile/engine/JniLibrary.java#L323 Signed-off-by: JP Simard <jp@jpsim.com>
* jni: fix mismatched return value types The Java side expects an `int` return value: https://github.com/envoyproxy/envoy-mobile/blob/9a397d72760acba3f3e96077f705971a8dc93d91/library/java/io/envoyproxy/envoymobile/engine/JniLibrary.java#L323 Signed-off-by: JP Simard <jp@jpsim.com>
Signed-off-by: Ryan Burn ryan.burn@gmail.com
Description:
This PR adds support for dynamically loading tracers into Envoy. It will allow authors of OpenTracing compliant tracers to support envoy without requiring envoy to bake their tracers into its build. Tracing libraries can be enabled by adding a section like this to envoy's configuration:
With this change, Envoy will be able to use Jaeger's new C++ tracing library. Some features this will allow that aren't available when using Jaeger as a collector for Zipkin:
While it might also make sense sometime in the future to offer a version of Jaeger or other tracers built into Envoy, decoupled plug-in support will allow for quicker on-boarding of tracers and more experimentation in the area without making Envoy's external dependencies become unmanageable.
Notes:
-static-libstdc++
. If plugin libraries are linked to thelibstdc++
in a standard way, this will create problems as two versions of the standard library will be loaded and calls to their functions from the plugin will be intermingled between them, breaking many of the standard library functions. The approach I took with Jaeger was to have it also use-static-libstdc++
and then use an export map to ensure that it's version of the standard library is used without any intermingling (see dsohowto for background on the approach). It does mean that there will be multiple copies oflibstdc++
running, but from what I've heard this can be made to work. Another approach could be to add a config option to linklibstdc++
dynamically.Risk Level: Medium
Testing:
I have a small example that demoes this functionality using docker and a branch of jaeger.
I also plan to add unit test coverage using a mock tracer library that will be added to opentracing-cpp.
Docs Changes:
envoyproxy/data-plane-api#386
Release Notes:
Included in PR.