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

Different behaviour, hard to control between implementations #184

Closed
marcingrzejszczak opened this issue Mar 10, 2023 · 1 comment
Closed
Labels
bug A general bug
Milestone

Comments

@marcingrzejszczak
Copy link
Contributor

by @maciej-gromul

https://github.com/spring-projects-experimental/spring-cloud-sleuth-otel/blob/a449cd64898d2898c2d95a27735d3f50a5ea245b/spring-cloud-sleuth-otel/src/main/java/org/springframework/cloud/sleuth/otel/bridge/OtelSpanInScope.java#L47

Current otel implementation is behaving differently than default one with brave tracer. Brave tracer when it get's extracted parent context through propagator creates a new span with parent context connected. When you open scope for that span, any new span will be connected with that new span.

Because in otel the OtelSpanInScope changes context to parent context when creating new span it's like having a child span but the scope is always to it's parent. It's even different with the builder where BraveBuilder simply creates new span with parent context, while otel returns after calling start a new span with method return of

if (this.parentContext != null) {
  return OtelSpan.fromOtel(new SpanFromSpanContext(span, span.getSpanContext(), (OtelTraceContext) this.parentContext));
}

So for brave if we get kafka record with b3 headers of 000000000000000a-000000000000000b-1-000000000000000a, method extract gives us a child span of random spanId connected with trace id 000000000000000a, and if we use tracer.withSpan(child) we will have that child as a scope and current trace context.

In case of otel calling tracer.withSpan(child) will have parent span and trace context as current span and trace context.

related issue spring-projects-experimental/spring-cloud-sleuth-otel#156

@marcingrzejszczak marcingrzejszczak added the bug A general bug label Mar 10, 2023
@marcingrzejszczak marcingrzejszczak added this to the 1.0.3 milestone Mar 10, 2023
@marcingrzejszczak
Copy link
Contributor Author

done via f4274f1

@shakuzen shakuzen modified the milestones: 1.0.3, 1.1.0-M2 Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants