Skip to content

Conversation

@david-luna
Copy link
Contributor

@david-luna david-luna commented Nov 25, 2025

Which problem is this PR solving?

this PR add a factory function to create instrumentations. the factory function has a single param to get an object that implements the InstrumentationDelegate interface. The factory function wraps the delegate and takes care of the enabling or disabling the instrumentation (interaction with RITM and ITM).

This approach removes the inheritance from InstrumentationAbstract -> InstrumentationBase avoiding any initialisation issue in the constructor as it happens in #1989.

with this change we will have two ways of creating instrumentations:

  • extending InstrumentationBase
  • calling createInstrumentation function with a delegate

IMHO the path should be to sunset the former in favour of the later so we avoid the init issue in all instrumentations and also simplifies a bit the instrumentation code.

Fixes #1989

Short description of the changes

  • added a new function createInstrumentation in instrumentation package for node
  • created aHttpInstrumentationDelegate class and export createHttpInstrumentation function in http instrumentation
  • TODO: added a new function createInstrumentation in instrumentation package for browser

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • tests added for the new way of creating a HTTP instrumentation http-delegate-*.test.ts files
  • tests added in the instrumentation package

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added
  • Documentation has been updated (TODO)

@codecov
Copy link

codecov bot commented Nov 25, 2025

Codecov Report

❌ Patch coverage is 99.06542% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 95.43%. Comparing base (167185a) to head (8193af9).
⚠️ Report is 21 commits behind head on main.

Files with missing lines Patch % Lines
...ntal/packages/otlp-transformer/src/common/utils.ts 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6163      +/-   ##
==========================================
+ Coverage   95.40%   95.43%   +0.02%     
==========================================
  Files         317      317              
  Lines        9439     9521      +82     
  Branches     2187     2197      +10     
==========================================
+ Hits         9005     9086      +81     
- Misses        434      435       +1     
Files with missing lines Coverage Δ
...ages/configuration/src/EnvironmentConfigFactory.ts 99.07% <100.00%> (+<0.01%) ⬆️
...al/packages/configuration/src/FileConfigFactory.ts 96.85% <100.00%> (ø)
...tal/packages/otlp-transformer/src/logs/internal.ts 100.00% <100.00%> (ø)
...ackages/otlp-transformer/src/logs/protobuf/logs.ts 100.00% <100.00%> (ø)
.../packages/otlp-transformer/src/metrics/internal.ts 100.00% <100.00%> (ø)
...s/otlp-transformer/src/metrics/protobuf/metrics.ts 100.00% <100.00%> (ø)
...al/packages/otlp-transformer/src/trace/internal.ts 98.59% <100.00%> (ø)
...kages/otlp-transformer/src/trace/protobuf/trace.ts 100.00% <100.00%> (ø)
packages/opentelemetry-resources/src/utils.ts 100.00% <ø> (+14.28%) ⬆️
...ntal/packages/otlp-transformer/src/common/utils.ts 97.56% <92.30%> (-2.44%) ⬇️

... and 42 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@david-luna
Copy link
Contributor Author

david-luna commented Dec 9, 2025

There is still work to do but is ready to be reviewed. IMHO we should decide 1st if the approach is the right one and then I can do the browser version and apply it to the rest of instrumentations in this repository

@david-luna david-luna marked this pull request as ready for review December 9, 2025 18:43
@david-luna david-luna requested a review from a team as a code owner December 9, 2025 18:43
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.

InstrumentationBase calls init on partly initialized Instrumentations

1 participant