-
Notifications
You must be signed in to change notification settings - Fork 649
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
OpenTracing Bridge - Initial implementation #211
OpenTracing Bridge - Initial implementation #211
Conversation
Looks like reviewers don't get tagged in draft PRs. Changing to a regular PR. |
Do we want to make this a top level folder? I suggest that we move it to the ext folder. |
Nice work! Thanks @johananl.
If you merge via github we have this repo configured to automatically squash the branch into a single commit, you just have to remember to fix the ugly generated commit message. I think it's fine to split inject/extract and baggage into separate PRs. |
3c3766a
to
af1ff0e
Compare
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.
In addition:
- Shouldn't that be a namespace package under
opentelemetry
instead of a new top-level package? EDIT: I think I duplicated OpenTracing Bridge - Initial implementation #211 (comment) here 😄
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 looks great. After reviewing I see how type annotations could be helpful here -- the code gets confusing quickly when we've got two different packages with the same class names.
Descriptions for args and return values in docstrings for non-API methods would be helpful. So would a module docstring or README that describes how to use the shim.
It'll be especially helpful to see tests or examples that show code instrumented with only the OpenTracing API, but create OpenTelemetry objects under the hood.
None of my comments are blocking, but I still see a few from @Oberon00. I'll review again and stamp it once those are resolved.
ext/opentelemetry-ext-opentracing-shim/src/opentelemetry/ext/opentracingshim/__init__.py
Outdated
Show resolved
Hide resolved
ext/opentelemetry-ext-opentracing-shim/src/opentelemetry/ext/opentracingshim/__init__.py
Outdated
Show resolved
Hide resolved
ext/opentelemetry-ext-opentracing-shim/src/opentelemetry/ext/opentracingshim/__init__.py
Outdated
Show resolved
Hide resolved
ext/opentelemetry-ext-opentracing-shim/src/opentelemetry/ext/opentracingshim/__init__.py
Outdated
Show resolved
Hide resolved
ext/opentelemetry-ext-opentracing-shim/src/opentelemetry/ext/opentracingshim/__init__.py
Outdated
Show resolved
Hide resolved
ext/opentelemetry-ext-opentracing-shim/src/opentelemetry/ext/opentracingshim/__init__.py
Outdated
Show resolved
Hide resolved
ext/opentelemetry-ext-opentracing-shim/src/opentelemetry/ext/opentracingshim/__init__.py
Outdated
Show resolved
Hide resolved
ext/opentelemetry-ext-opentracing-shim/src/opentelemetry/ext/opentracingshim/__init__.py
Outdated
Show resolved
Hide resolved
ext/opentelemetry-ext-opentracing-shim/src/opentelemetry/ext/opentracingshim/__init__.py
Outdated
Show resolved
Hide resolved
ext/opentelemetry-ext-opentracing-shim/src/opentelemetry/ext/opentracingshim/__init__.py
Outdated
Show resolved
Hide resolved
Maybe a dumb question - what's the difference between bridge and shim here? This PR seems to be focusing on the OpenTracing shim, which means one can use the shim to convert an OpenTelemetry tracer into OpenTracing tracer. A bridge sounds like bi-directional thing, which also means one can turn an OpenTracing tracer into an OpenTelemetry one. |
@reyang that's a great question actually. I've been using the two terms interchangeably. In the code I've stuck to "shim" for consistency, however in issues etc. I've seen people use both. I don't have a strong opinion on which one to use, as long as we're consistent with it. We should also remember we have a similar term in other languages. |
ext/opentelemetry-ext-opentracing-shim/src/opentelemetry/ext/opentracingshim/__init__.py
Outdated
Show resolved
Hide resolved
ext/opentelemetry-ext-opentracing-shim/src/opentelemetry/ext/opentracingshim/__init__.py
Outdated
Show resolved
Hide resolved
ext/opentelemetry-ext-opentracing-shim/src/opentelemetry/ext/opentracingshim/__init__.py
Outdated
Show resolved
Hide resolved
ext/opentelemetry-ext-opentracing-shim/src/opentelemetry/ext/opentracingshim/__init__.py
Outdated
Show resolved
Hide resolved
ext/opentelemetry-ext-opentracing-shim/src/opentelemetry/ext/opentracingshim/__init__.py
Outdated
Show resolved
Hide resolved
ext/opentelemetry-ext-opentracing-shim/src/opentelemetry/ext/opentracingshim/__init__.py
Outdated
Show resolved
Hide resolved
ext/opentelemetry-ext-opentracing-shim/src/opentelemetry/ext/opentracingshim/__init__.py
Outdated
Show resolved
Hide resolved
ext/opentelemetry-ext-opentracing-shim/src/opentelemetry/ext/opentracingshim/__init__.py
Outdated
Show resolved
Hide resolved
c42ff3d
to
564cc0e
Compare
ext/opentelemetry-ext-opentracing-shim/src/opentelemetry/ext/opentracing_shim/__init__.py
Outdated
Show resolved
Hide resolved
- Remove an unnecessary context manager layers. - Allow creating `ContextWrapper` objects either from a `SpanWrapper` or from a `Span` context manager.
39c1d80
to
8b00729
Compare
Rebased over current master. @carlosalberto, could you please merge if things look OK to you? Editing the squashed commit message is going to be a mess... I guess we can call it "Add initial OpenTracing bridge implementation" or something similar. |
Until we figure out how to handle unsupported frameworks (e.g. gevent), we remove the `scope_manager` argument of `create_tracer` to avoid breaking the OpenTelemetry context propagation.
These are obvious and therefore unnecessary.
The API docs are clear about the `references` argument being a list. We don't try to compensate for wrong argument types elsewhere, so no reason to do that here.
Not all classes in the shim are actually wrappers, which makes the XWrapper naming convention confusing. XShim is more neutral.
In the OpenTracing API, when an exception occurs while a span is active, information about the exception is added to the span as logs and a tag is added as well. We re-add this functionality to the shim since we've overridden the `__exit__()` method in which it lives.
Validating the parent type complicates the logic of `start_span()`. Since the OpenTracing API clearly specifies the valid types for a parent span, it's the user's responsibility to specify a valid parent.
Verify that calling `close()` on a `ScopeShim` deactivates the span in the OpenTelemetry tracer.
We shouldn't return OpenTelemetry objects to the OpenTracing API.
Make it clearer that the provided tracer object should be an OpenTelemetry tracer, not an OpenTracing tracer.
81b59ed
to
082183a
Compare
@carlosalberto please delete the generated commit message or rewrite it as a nice summary when you merge! No more ugly commits on master. :D |
@c24t done ;) |
The example of the jaeger exporter is failing because e4d8949 ("OpenTracing Bridge - Initial implementation (open-telemetry#211)") introduced a new timestamp parameter to add_event, the example was passing parameter by position so it was messed up.
e4d8949 ("OpenTracing Bridge - Initial implementation (open-telemetry#211)") introduced a new timestamp argument to the add_event method. This commit moves that argument to be the last one because it is more common to have event attributes than an explicitly timestamp.
General
This is an initial implementation for the OpenTracing bridge for the Python OpenTelemetry library. There are still some things I would like to handle before considering a merge. On the other hand this is a big PR and I would like to start getting feedback as soon as possible, so I'm opening a draft PR while I work on closing the remaining work items (see TODO section below).
This PR supersedes #120. I have found it easier to open a new PR rather than altering the old one due to a significantly different implementation. Please tell me if I should edit the original PR instead.
Implementation
The PR adds an OpenTracing "shim". The shim is a collection of wrapper classes which should allow an OpenTracing user to instantiate an OpenTelemetry tracer and use it as if it were an OpenTracing tracer, without altering instrumentation code.
TODO
The following should probably be done before merging:
The following features haven't been implemented yet:
Testing
To run the unit tests, execute
tox
. Following are full instructions for running the tests from scratch, in case somebody finds it useful:To use the bridge for tracing a dummy app, use the following:
Then, instrument an app: