Skip to content

ddtrace/opentracer: implement Context Extension #855

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

Merged
merged 11 commits into from
Apr 19, 2021

Conversation

sjmtan
Copy link
Contributor

@sjmtan sjmtan commented Feb 23, 2021

Solves #813.

This implements the OpenTracing context extension. If a span was started by a Datadog OpenTracer, then the underlying object should be a pointer to a opentracer.span. If that is the case, we're able to use the context with the underlying Datadog Span (of the opentracer.span).

I've tested this locally to connect opentracing spans with Datadog spans assuming I set the opentracing.SetGlobalTracer(datadogOpenTracer).

@sjmtan
Copy link
Contributor Author

sjmtan commented Feb 23, 2021

I can't set the milestone btw.

@gbbr gbbr changed the title Implement Context Extension ddtrace/opentracer: implement Context Extension Feb 24, 2021
Copy link
Contributor

@gbbr gbbr left a comment

Choose a reason for hiding this comment

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

This is very interesting. We'll have to run some tests. I'm hoping to get a chance to look at it soon. This could potentially solve a big limitation if it does what it claims it does 🙂

Copy link
Contributor

@gbbr gbbr left a comment

Choose a reason for hiding this comment

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

Thanks. I think it's fine to do this. AFAIU this simply adds more context into the uhm... context 🙂

@gbbr gbbr added this to the 1.30.0 milestone Feb 26, 2021
@sjmtan
Copy link
Contributor Author

sjmtan commented Feb 26, 2021

@gbbr for what its worth, this only solves part of the problem. This allows using opentracing as a parent for DD spans, but no ability to use a DD span as a parent for opentracing spans.

This is because DD span needs to call opentracing.ContextWithSpan in order for that work.

@sjmtan
Copy link
Contributor Author

sjmtan commented Feb 26, 2021

This actually means that barring a significant change to support that (I tried and failed without having to rewrite a bunch of stuff), we'll be moving off ddtrace completely and adopting opentracing only.

@nishkala-square
Copy link

I still find this to be a useful change and hope we can merge it even though it only solves half the issue. While it would be great if we could also implement something to work in the other direction, this still allows us to use some of the extensions (such as database tracing)

gbbr
gbbr previously approved these changes Mar 1, 2021
Copy link
Contributor

@gbbr gbbr left a comment

Choose a reason for hiding this comment

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

This is fine by me to merge. We are currently in code freeze so I'll leave it here until that ends, and merge it afterwards.

@gbbr for what its worth, this only solves part of the problem. This allows using opentracing as a parent for DD spans, but no ability to use a DD span as a parent for opentracing spans.

This is because DD span needs to call opentracing.ContextWithSpan in order for that work.

@shannontan-bolt I see. I'm happy for us to fix that, if we can work around some restrictions. For us, it was a hard requirement that the Datadog tracer (ddtrace package) never imports opentracing. If we can solve this somehow and keep this requirement, I'm open.

@sjmtan
Copy link
Contributor Author

sjmtan commented Mar 1, 2021

@gbbr - I don't see any good way of doing that since somehow, you'll need to set the context within opentracing when starting a span from within ddtrace. Therefore, you'll eventually need to call opentracing.ContextWithSpan.

One thought I had, but no good way to do it is: when ddtrace is used with opentracing, actually use the opentracer instead of using a global tracer. opentracer can call opentracing.ContextWithSpan before returning a started span.

@sjmtan
Copy link
Contributor Author

sjmtan commented Mar 4, 2021

@gbbr - when is the code freeze over? Since this is a blocker for me a bit, I might need to fork this temporarily if the code freeze/time to release is a while.

@gbbr
Copy link
Contributor

gbbr commented Mar 4, 2021

@gbbr - when is the code freeze over? Since this is a blocker for me a bit, I might need to fork this temporarily if the code freeze/time to release is a while.

If you don't mind, please go ahead and fork it. It will be a good way to test. Code freeze is over in about a week generally if all goes well, but then we'll still have to wait again until the next version.

gbbr
gbbr previously approved these changes Mar 12, 2021
Copy link
Contributor

@gbbr gbbr left a comment

Choose a reason for hiding this comment

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

Thanks for this! I assume you've tested it and it does what you expect it to :)

@sjmtan sjmtan force-pushed the shannontan/openTracingContextExtension branch from c68fa21 to e576811 Compare March 29, 2021 23:57
Copy link
Contributor

@gbbr gbbr left a comment

Choose a reason for hiding this comment

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

Thanks! Just a few nits.

Copy link
Contributor

@gbbr gbbr left a comment

Choose a reason for hiding this comment

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

@shannontan-bolt would love to get this merged for you, are you still interested in doing the last few final changes?

Shannon Tan and others added 5 commits April 19, 2021 11:36
Co-authored-by: Gabriel Aszalos <gabriel.aszalos@datadoghq.com>
Co-authored-by: Gabriel Aszalos <gabriel.aszalos@datadoghq.com>
@gbbr gbbr force-pushed the shannontan/openTracingContextExtension branch from ca55feb to 7239b9c Compare April 19, 2021 08:36
@gbbr
Copy link
Contributor

gbbr commented Apr 19, 2021

@shannontan-bolt since this was a popular PR and haven't heard back from you, I took the liberty to commit into your PR. I hope that's ok.

@gbbr gbbr merged commit 58da3e4 into DataDog:v1 Apr 19, 2021
@sjmtan
Copy link
Contributor Author

sjmtan commented Apr 19, 2021

@gbbr that's awesome, thanks!

@sjmtan sjmtan deleted the shannontan/openTracingContextExtension branch April 19, 2021 18:24
stlimtat pushed a commit to stlimtat/dd-trace-go that referenced this pull request May 17, 2021
* 'v1' of https://github.com/DataDog/dd-trace-go:
  Implement DD_PROFILING_OUTPUT_DIR for dev/debug (DataDog#924)
  contrib/go-pg/pg.v10: add INTEGRATION flag check for tests (DataDog#921)
  contrib/go-redis/redis.v8: optimize BeforeProcess and BeforeProcessPipeline (DataDog#920)
  CI: check go.sum is up-to-date (DataDog#918)
  README: Fix go get instructions (DataDog#913)
  internal/log: Improve API for testing (DataDog#916)
  ddtrace/tracer: add support for agent discovery endpoint, feature flags, stats & drops (DataDog#859)
  internal/version: bump to v1.31.0 (DataDog#910)
  CONTRIBUTING.md: add link to contrib/README.md (DataDog#802)
  profiler: Disable agentless mode for WithAPIKey (DataDog#906)
  contrib/Shopify/sarama: fix possible deadlock in WrapAsyncProducer (DataDog#907)
  contrib/database/sql.tracedConn implement driver.SessionResetter (DataDog#908)
  ddtrace/opentracer: consider FollowsFrom references as children (DataDog#905)
  ddtrace/opentracer: add support for opentracing.TracerContextWithSpanExtension (DataDog#855)
  ddtrace/tracer: follow noDebugStack setting when using SetTag with an error (DataDog#900)
  contrib/net/http: add a getter to retrieve original round tripper (DataDog#903)
  ddtrace/tracer: ensure Flush call is synchronous (DataDog#901)
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.

4 participants