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

Implement W3C Correlation Context propagator #179

Merged

Conversation

sjkaris
Copy link
Contributor

@sjkaris sjkaris commented Oct 10, 2019

#124

A couple open items on this PR.

  1. I feel that the interface shouldn't take/return []core.KeyValue, but was unsure what structure should be used in its place. tag.Map (soon to be renamed to dctx.Map/distrubtedcontext.Map) is a candidate, but doesn't allow for multiple same-valued keys as https://w3c.github.io/correlation-context/ states should be allowed.

  2. Properties defined in https://w3c.github.io/correlation-context/ are not handled very well, and its unclear to me what should be done with them.

  3. Do we want a separate interface for Correlation Context propagation vs SpanContext propagation

@freeformz
Copy link
Contributor

What decides and when what keys/values need to be propagated ? Reading the linked doc I don't get a great feel beyond "user-defined baggage associated with the trace". Is that type of data likely to be different for each trace? Or is it something meant to be setup once or modified only irregularly?

@freeformz
Copy link
Contributor

You could do something like this: https://github.com/sjkaris/opentelemetry-go/compare/feature/sk/w3s-correlation-ctx-prop...heroku:feature/sk/w3s-correlation-ctx-prop?expand=1

^ ends up conforming the new propagator to the propagation.TextFormatPropagator interface. To do so, I needed to expand core.SpanContext to also contain a []core.KeyValue. This has a side effect of making core.SpanContext not comparable, which can be dealt with in most cases, but not all. One example of a place that change affects is that the experimental streamer uses span contexts as a map key, which the new core.SpanContext can't be used as (adding a Hash() string function to spanContext or equivalent can get around that.

Thoughts?

@jmacd
Copy link
Contributor

jmacd commented Oct 11, 2019

@sjkaris @freeformz
I've read and thought about this a bit -- I'll admit I've been less focused on propagation issues than I should be. My understanding is that the grand "Context" consists of distributed context + span context. Whether they actually are stored in the same object or not seems to be the question here. Is the expectation here that Extract will convert the SpanContext into standards-conventional key-values? I believe until now, we've said that Inject should return the explicit key-values and SpanContext, not assemble a Golang Context directly--that should be up to the following span Start.

Am I understanding the issue, at least?

Also, @sjkaris I couldn't find what you mean by "doesn't allow for multiple same-valued keys"?

@freeformz About the experimental SDK. Distributed context can't be "forgotten" by the streaming SDK the way all other state can. I believe we should maintain a distributedcontext.Map in the context for all SDKs, i.e., this is part of the API. The experimental streaming back-end maintains the current state of the span using the SpanContext as the index key, which is independent from the current distributedcontext.Map values, and whenever the Span changes it uses a new EventID to convey that the span is in a new state. So if you added a new M distributedcontext.Map field in SpanContext to store distributedcontext.Map, that would be fine, but it wouldn't be used to index current state in the streaming SDK.

@sjkaris
Copy link
Contributor Author

sjkaris commented Oct 11, 2019

@jmacd, yep I think you understand the issue. Just to re-state, from what I gathered at the SIG meeting, this PR should be changed such that we return both the SpanContext and the dctx.Map in Extract and additionally take a dctx.Map as an argument to Inject to pass arbitrary keys along.

Its poorly worded, but what I meant by "doesn't allow for multiple same-valued keys", is basically that the dctx.Map doesn't let you have multiple entries for the same key, like a slice or list would allow. I'm not sure that this is actually problematic.

@sjkaris
Copy link
Contributor Author

sjkaris commented Oct 11, 2019

I would be interested to hear @freeformz thoughts on this as well though

@freeformz
Copy link
Contributor

I don't know what happened at the SIG meeting unfortunately. I'd prefer to not to add another interface like the original PR did, but make an interface that works for all of these types of headers, possibly with optional secondary interfaces as needed.

I am a bit worried about the question of needing to support multiple values for the same key. If that is a requirement then dctx.Map will need to be changed or can't be used for this.

@rghetia
Copy link
Contributor

rghetia commented Oct 14, 2019

Separation of correlation context from observability is discussed here. As part of this discussion, the interface for propagators will change as well. May I suggest that we finish this PR with a single propagator that handles both, trace-context and distributed-context with following signature?

inject(ctx context.Context, supplier Supplier)
extract(ctx, contex.Context, supplier Supplier) (SpanContext, dctx.Map)

Regarding multiple values correlation context - As per the DistributedContext spec, a key can only have one value. So for now, if there are duplicate keys during extraction we either take the last or the first entry. Open an issue to resolve the multiple value support in the spec.

@freeformz
Copy link
Contributor

Separation discussion URL: open-telemetry/oteps#42

@rghetia
Copy link
Contributor

rghetia commented Oct 15, 2019

Separation discussion URL: open-telemetry/oteps#42

thanks for posting the correct link.

@sjkaris
Copy link
Contributor Author

sjkaris commented Oct 15, 2019

Sounds good, ill update this today.

@sjkaris sjkaris force-pushed the feature/sk/w3s-correlation-ctx-prop branch from eadbb28 to b99e571 Compare October 16, 2019 18:02
@sjkaris sjkaris changed the title WIP Implement W3C Correlation Context propagator Implement W3C Correlation Context propagator Oct 16, 2019
api/propagation/propagator.go Outdated Show resolved Hide resolved
api/propagation/propagator.go Outdated Show resolved Hide resolved
correlationCtx.Foreach(func(kv core.KeyValue) bool {
attrs = append(attrs, kv)
return true
})
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be appended to attributes or returned second argument. I believe 'Context Entries' refer to DistributedContext here. @jmacd , can you please confirm?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I suspect you are right, this should be returned as the second arg.

Copy link
Contributor

Choose a reason for hiding this comment

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

(I'm open to improvements on this API.)

correlationCtx.Foreach(func(kv core.KeyValue) bool {
attrs = append(attrs, kv)
return true
})
Copy link
Contributor

Choose a reason for hiding this comment

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

(I'm open to improvements on this API.)

Copy link
Contributor

@rghetia rghetia left a comment

Choose a reason for hiding this comment

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

@sjkaris, LGTM. Can you please rebase?

@sjkaris sjkaris force-pushed the feature/sk/w3s-correlation-ctx-prop branch from f3728c5 to bc37f3d Compare October 16, 2019 23:33
@rghetia
Copy link
Contributor

rghetia commented Oct 17, 2019

@sjkaris, LGTM. Can you please rebase?

one more conflict due to #218

@sjkaris sjkaris force-pushed the feature/sk/w3s-correlation-ctx-prop branch from 1eaf812 to c138077 Compare October 17, 2019 18:32
@rghetia rghetia merged commit e11b90c into open-telemetry:master Oct 17, 2019
hstan referenced this pull request in hstan/opentelemetry-go Oct 15, 2020
…/github.com/Shopify/sarama (#179)

* Bump google.golang.org/grpc

Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.30.0 to 1.31.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](grpc/grpc-go@v1.30.0...v1.31.0)

Signed-off-by: dependabot[bot] <[email protected]>

* Auto-fix go.sum changes in dependent modules

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tyler Yahn <[email protected]>
@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.

5 participants