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

Context propagation in opentracing bridge #525

Merged
merged 11 commits into from
Mar 10, 2020

Conversation

krnowak
Copy link
Member

@krnowak krnowak commented Mar 6, 2020

This PR implements the context propagation in opentracing bridge in terms of OpenTelemetry context propagation.

I had to add some hacky hooky code to correlation package to make the otel span to know about baggage items set with the OT API, and to make the OT span to know about correlation key values set with Otel API. Hopefully it's not too scary, but it's always making me wonder if things won't go boom with threads. I think I'll need to go through the code with this in mind once again, but in the mean time I'd like to get a review of the current state.

Copy link
Contributor

@jmacd jmacd left a comment

Choose a reason for hiding this comment

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

It's a little bit dizzying. 😀

krnowak added 10 commits March 10, 2020 16:16
We will put this map into the context with correlation context
functions, and that is easier if we have correlation.Map, not
map[string]string.
The otel propagators are now kinda sorta usable for opentracing
bridge. Some more work is needed to make it fully work, though -
correlation context set with the otel API is not propagated to OT
spans as baggage items yet.
This introduces two kinds of hooks into the correlation context
code.

The set hook gets called every time we set a Map in the context. The
hook receives a context with the Map and returns a new context.

The get hook gets called every time we get a Map from the context. The
hook receives the context and the map, and returns a new Map.

These hooks will be used for correlation context and baggage items
propagation between the Otel and OT APIs.
So I do not need to remember about initializing a newly added member
in several places now.
This uses the set hook functionality to propagate correlation context
changes from Otel to OT spans by inserting keys and values into the
baggage items. The get hook functionality is used to propagate baggage
items from active OT span into the otel correlation context.
This prepares the context by installing the hooks, so the correlation
context and baggage items can be propagated between the APIs.
We will need this for testing the correlation context and baggage
items propagation between the APIs.
The test adds a baggage item to active OT span and some correlation
key value to current Otel span. Then makes sure that the OT span
contains both the baggage item and some translated version of the
correlation key value its Otel sibling got, and that the Otel span
contains both the correlation key value and the baggage item its OT
sibling got.
@krnowak krnowak force-pushed the ctx-prop-in-ot-bridge branch from 0580976 to 9a42b69 Compare March 10, 2020 15:16

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@jmacd
Copy link
Contributor

jmacd commented Mar 10, 2020

I intend to merge this without further reviews based on

  1. @krnowak is the primary author of both the latest context propagation PR and the OT bridge,
  2. @krnowak and I are the only approvers with a background in OpenTracing to my knowledge,
  3. @krnowak's strong track record of quality code. 😁

@jmacd jmacd merged commit 8cddf30 into open-telemetry:master Mar 10, 2020
@krnowak krnowak deleted the ctx-prop-in-ot-bridge branch March 11, 2020 17:36
MikeGoldsmith pushed a commit to MikeGoldsmith/opentelemetry-go that referenced this pull request Mar 13, 2020

Verified

This commit was signed with the committer’s verified signature. The key has expired.
MikeGoldsmith Mike Goldsmith
* Propagate context changes in mix tests

We will need this for testing the correlation context and baggage
items propagation between the APIs.

* Add baggage interoperation tests

The test adds a baggage item to active OT span and some correlation
key value to current Otel span. Then makes sure that the OT span
contains both the baggage item and some translated version of the
correlation key value its Otel sibling got, and that the Otel span
contains both the correlation key value and the baggage item its OT
sibling got.

* Add hooks functionality to baggage propagation

This introduces two kinds of hooks into the correlation context
code.

The set hook gets called every time we set a Map in the context. The
hook receives a context with the Map and returns a new context.

The get hook gets called every time we get a Map from the context. The
hook receives the context and the map, and returns a new Map.

These hooks will be used for correlation context and baggage items
propagation between the Otel and OT APIs.

* Warn on foreign opentracing span

* fixup for using otel propagators

* Add utility function for setting up bridge and context

This prepares the context by installing the hooks, so the correlation
context and baggage items can be propagated between the APIs.

* Add bridge span constructor

So I do not need to remember about initializing a newly added member
in several places now.

* Propagate baggage across otel and OT APIs

This uses the set hook functionality to propagate correlation context
changes from Otel to OT spans by inserting keys and values into the
baggage items. The get hook functionality is used to propagate baggage
items from active OT span into the otel correlation context.

* Use correlation Map for baggage items

We will put this map into the context with correlation context
functions, and that is easier if we have correlation.Map, not
map[string]string.

* Use otel propagators in bridge

The otel propagators are now kinda sorta usable for opentracing
bridge. Some more work is needed to make it fully work, though -
correlation context set with the otel API is not propagated to OT
spans as baggage items yet.

Co-authored-by: Joshua MacDonald <jmacd@users.noreply.github.com>
@pellared pellared added this to the untracked milestone Nov 8, 2024
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.

None yet

3 participants