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

feat: Added opentelemetry bridge instrumentation that adds a context manager, and processor to handle synthesizing segments and time slice metrics. #2906

Merged
merged 2 commits into from
Jan 29, 2025

Conversation

bizob2828
Copy link
Member

Description

This PR creates a basic otel trace provider with a span processor and context manager. I also wired up the creation of timeslice metrics for internal and http external segments.

I updated the existing context to include the necessary get/set/delete Value methods needed for otel. We could inherit the root context and add just for this project. The otel context manager properly runs the necessary calls in our context manager. I added a span processor to assign the synthesized segment/transaction to segment, then in the setValue we read it and assign to new context.

I have a todo to reconcile any span attributes on span end but not sure the best way to approach just yet. Currently the only thing we do on end is update the segment duration with the duration from span for consistency. During my testing I noticed we are missing some core attributes but again, can solve later. This PR is intended to unleash the rest of the work and is far from feature complete.

How to Test

npm run verisoned:internal otel-bridge

Related Issues

Closes #2660
Closes #2654

Copy link

codecov bot commented Jan 27, 2025

Codecov Report

Attention: Patch coverage is 96.50655% with 8 lines in your changes missing coverage. Please review.

Project coverage is 97.36%. Comparing base (751eb96) to head (09d7c51).
Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
lib/otel/context-manager.js 84.61% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2906      +/-   ##
==========================================
- Coverage   97.38%   97.36%   -0.03%     
==========================================
  Files         309      313       +4     
  Lines       47406    47650     +244     
==========================================
+ Hits        46166    46393     +227     
- Misses       1240     1257      +17     
Flag Coverage Δ
integration-tests-cjs-18.x 72.47% <52.83%> (?)
integration-tests-cjs-20.x 72.48% <52.83%> (-0.65%) ⬇️
integration-tests-cjs-22.x 72.70% <53.27%> (?)
integration-tests-esm-18.x 49.61% <52.83%> (-0.21%) ⬇️
integration-tests-esm-20.x 49.62% <52.83%> (-0.21%) ⬇️
integration-tests-esm-22.x 49.67% <53.27%> (-0.20%) ⬇️
unit-tests-18.x 89.12% <89.95%> (?)
unit-tests-20.x 89.12% <89.95%> (+<0.01%) ⬆️
unit-tests-22.x 89.13% <89.95%> (?)
versioned-tests-18.x 79.23% <93.88%> (-0.19%) ⬇️
versioned-tests-20.x 79.23% <93.88%> (-0.19%) ⬇️
versioned-tests-22.x 79.24% <93.88%> (-0.19%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

…manager, and processor to handle synthesizing segments and time slice metrics.
@bizob2828 bizob2828 force-pushed the otel-instrumentation-bootstrap branch from f6591ad to f4755b2 Compare January 27, 2025 21:54
Copy link
Contributor

@jsumners-nr jsumners-nr left a comment

Choose a reason for hiding this comment

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

OTEL parts look a lot like what I was coming up with 🎉. Just have a couple of suggestions.

lib/context-manager/context.js Outdated Show resolved Hide resolved
lib/context-manager/context.js Show resolved Hide resolved
lib/context-manager/context.js Show resolved Hide resolved
lib/otel/context-manager.js Show resolved Hide resolved
@bizob2828 bizob2828 merged commit d2e8a9e into newrelic:main Jan 29, 2025
25 of 27 checks passed
@bizob2828 bizob2828 deleted the otel-instrumentation-bootstrap branch January 29, 2025 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done: Issues recently completed
3 participants