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(instrumentation-aws-lambda): use require-in-the-middle directly #1314

Closed
wants to merge 2 commits into from

Conversation

mhassan1
Copy link
Contributor

@mhassan1 mhassan1 commented Nov 29, 2022

Which problem is this PR solving?

@opentelemetry/instrumentation-aws-lambda is incompatible with @opentelemetry/instrumentation@^0.34.0 and higher, since it no longer supports instrumentation of absolute paths. This PR switches to using require-in-the-middle directly.

Fixes #1285

Short description of the changes

This PR replaces usage of InstrumentationNodeModuleDefinition and InstrumentationNodeModuleFile with direct invocation of require-in-the-middle. Any instrumentation plugins that instrument absolute paths will need to use this strategy; currently, this is the only one.

One downside of this approach is that it does not use the normal instrumentation patching infrastructure, so some features (e.g. instrumentation.disable) may not work.

In #1285, we discussed a few options for resolving the need to instrument absolute paths. This PR represents option 3:

In @opentelemetry/instrumentation-aws-lambda, instrument code using another method, e.g. use require-in-the-middle directly, or patch the code directly

@codecov
Copy link

codecov bot commented Nov 29, 2022

Codecov Report

Merging #1314 (9c5c676) into main (092a250) will decrease coverage by 0.54%.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1314      +/-   ##
==========================================
- Coverage   96.08%   95.53%   -0.55%     
==========================================
  Files          14       16       +2     
  Lines         893     1097     +204     
  Branches      191      228      +37     
==========================================
+ Hits          858     1048     +190     
- Misses         35       49      +14     
Impacted Files Coverage Δ
...-instrumentation-aws-lambda/src/instrumentation.ts 91.21% <100.00%> (ø)
...tapackages/auto-instrumentations-node/src/utils.ts 98.21% <0.00%> (ø)

]
),
];
// Use RITM directly because `@opentelemetry/instrumentation` does not support absolute paths.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it might make more sense for this to happen inside an enable override, rather than in init.

@mhassan1
Copy link
Contributor Author

mhassan1 commented Dec 5, 2022

Superseded by open-telemetry/opentelemetry-js#3457.

@mhassan1 mhassan1 closed this Dec 5, 2022
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.

@opentelemetry/instrumentation-aws-lambda is not compatible with @opentelemetry/instrumentation@^0.34.0
2 participants