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

OpenTelemetry Traces support #2496

Merged
merged 13 commits into from
Jan 27, 2023
Merged

OpenTelemetry Traces support #2496

merged 13 commits into from
Jan 27, 2023

Conversation

marcotc
Copy link
Member

@marcotc marcotc commented Dec 19, 2022

What does this PR do?

The PR is divided into compartmentalized commits, if you prefer reviewing one commit at a time.

This PR allows ddtrace users to use Datadog Tracing and OpenTelemetry Traces together.

OpenTelemetry Traces created by the host application will be collected by ddtrace and sent to the Datadog UI without any code changes.

Datadog and OpenTelemetry spans will form a single trace, with correct parenting being handled by ddtrace.

To activate the OpenTelemetry Traces collection, run this line:

require 'datadog/opentelemetry'

Motivation

OpenTelemetry is a vendor-agnostic instrumentation specification that is being widely supported across the tech community today.

We should support users that want to keep using this vendor-agnostic API while using Datadog to process the telemetry data created.

Additional Notes

This is the first version of OpenTelemetry Traces support. It will be released as experimental.

This PR includes:

  • Testing: Unit test coverage.
  • Testing: An integration app exercising OpenTelemetry trace interweaving.
  • Testing: Run the OpenTelemetry Ruby repository test suite with ddtrace integration enabled (bundle exec rake upstream:opentelemetry).
  • Documentation about how to configure Datadog APM with OpenTelemetry, including current limitations.
  • Telemetry collection for OpenTelemetry (a boolean flag for when OpenTelemetry integration is enabled).

Examples (from the integration app)

OpenTelemetry root span, with a Datadog child span:

Screen Shot 2023-01-13 at 10 30 11 AM

Datadog root span, with an OpenTelemetry child span:

Screen Shot 2023-01-13 at 10 29 47 AM

And because we handle trace parenting now, a baseline test case to ensure this PR didn't break pure OpenTelemetry parenting:

Screen Shot 2023-01-13 at 10 30 38 AM

How to test the change?

  • The easiest way is to run the integration/apps/opentelemetry integration app, to see real spans in the Datadog UI.
  • bundle exec rake upstream:opentelemetry ensures no OpenTelemetry contract has been violated by this integration.

@marcotc marcotc force-pushed the otel-2 branch 2 times, most recently from 1b475c0 to d25fb0d Compare December 22, 2022 20:51
@github-actions github-actions bot added the core Involves Datadog core libraries label Jan 11, 2023
@marcotc marcotc changed the title [WIP] OpenTelemetry support OpenTelemetry Traces support Jan 13, 2023
@marcotc marcotc added core Involves Datadog core libraries feature Involves a product feature and removed core Involves Datadog core libraries labels Jan 13, 2023
@marcotc marcotc marked this pull request as ready for review January 13, 2023 01:14
@marcotc marcotc requested a review from a team January 13, 2023 01:14
@codecov-commenter
Copy link

codecov-commenter commented Jan 25, 2023

Codecov Report

Merging #2496 (848a5e6) into master (b8f4cec) will decrease coverage by 0.02%.
The diff coverage is 95.02%.

@@            Coverage Diff             @@
##           master    #2496      +/-   ##
==========================================
- Coverage   98.06%   98.04%   -0.02%     
==========================================
  Files        1135     1143       +8     
  Lines       61702    62033     +331     
  Branches     2777     2801      +24     
==========================================
+ Hits        60505    60822     +317     
- Misses       1197     1211      +14     
Impacted Files Coverage Δ
lib/datadog/tracing/configuration/ext.rb 100.00% <ø> (ø)
lib/datadog/tracing/metadata/tagging.rb 95.23% <50.00%> (-2.27%) ⬇️
lib/datadog/opentelemetry/sdk/propagator.rb 82.35% <82.35%> (ø)
lib/datadog/opentelemetry/sdk/span_processor.rb 83.87% <83.87%> (ø)
lib/datadog/opentelemetry/api/context.rb 91.42% <91.42%> (ø)
lib/datadog/core/telemetry/collector.rb 100.00% <100.00%> (ø)
lib/datadog/kit/appsec/events.rb 100.00% <100.00%> (ø)
lib/datadog/opentelemetry.rb 100.00% <100.00%> (ø)
lib/datadog/opentelemetry/api/trace/span.rb 100.00% <100.00%> (ø)
lib/datadog/opentelemetry/sdk/configurator.rb 100.00% <100.00%> (ø)
... and 11 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@delner
Copy link
Contributor

delner commented Jan 27, 2023

Rebased on the latest master and added some documentation. Waiting for a green build.

Copy link
Contributor

@delner delner left a comment

Choose a reason for hiding this comment

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

Reviewed this with @marcotc at a high level.

There's a lot to digest in the details (which I'm not fully knowledgeable), but overall the general strategy to patch into OTel over re-implementing the API seems sound; less brittle in regards to changes within OTel (needing to duplicate a lot of implementation to meet spec). It's also reassuring to see the OTel test suite passing in combination with these changes in our CI.

This should be sufficient for experimental support; we'll want to performance test this for stability and run in other environments to validate it before promoting support to "beta".

All-in-all awesome job on this @marcotc ! Really excited to see this in action! 😄

@delner delner merged commit d0e8ec6 into master Jan 27, 2023
@delner delner deleted the otel-2 branch January 27, 2023 22:46
@github-actions github-actions bot added this to the 1.9.0 milestone Jan 27, 2023
@TonyCTHsu TonyCTHsu mentioned this pull request Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Involves Datadog core libraries feature Involves a product feature tracing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants