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

fix: handling of multipleInstrumentationNodeModuleDefinition with the same name #3

Conversation

RafalSumislawski
Copy link

When there are multiple InstrumentationNodeModuleDefinitions the urrent implementation chooses one of theInstrumentationNodeModuleDefinitions in bunle-time and then in runtime selects it by name. This breaks when there are multiple InstrumentationNodeModuleDefinitions with the same name, as the wrong one may be selected.

This is the case with:
mongodb - https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts#L96
winston - https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/plugins/node/opentelemetry-instrumentation-winston/src/instrumentation.ts#L48
socket.io - https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/plugins/node/instrumentation-socket.io/src/socket.io.ts#L218
generic-pool - https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/plugins/node/opentelemetry-instrumentation-generic-pool/src/instrumentation.ts#L43

This PR approaches the problem analogically to how instrumentation.files are handled. By iterating over the instrumentation in runtime and applying the ones with matching version.

@github-actions github-actions bot requested a review from drewcorlin1 November 20, 2024 15:50
@RafalSumislawski RafalSumislawski marked this pull request as draft November 20, 2024 16:45
@RafalSumislawski
Copy link
Author

Indeed we do. I converted this PR to a draft exactly because I realized aws-sdk stopped working after these changes.

@RafalSumislawski RafalSumislawski marked this pull request as ready for review November 21, 2024 14:14
}

module.exports = mod;
} catch (e) {
Copy link
Owner

Choose a reason for hiding this comment

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

Shouldn't we throw the underlying error to make any issues with this visible to users without requiring them to set the OTel diag log level?

Copy link
Author

Choose a reason for hiding this comment

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

My opinion is that bugs in instrumentation (especially automatic) shouldn't break the service. I would like to surface the errors message of course.

I'm not sure what's idiomatic across otel, but I think this is a similar case to how auto-instrumentations-node handles startup errors here: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/metapackages/auto-instrumentations-node/src/register.ts#L37

Copy link
Owner

Choose a reason for hiding this comment

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

Good point + agree the consistency with auto instrumentations is good

packages/esbuild-plugin-node/src/common.ts Show resolved Hide resolved
packages/esbuild-plugin-node/src/common.ts Show resolved Hide resolved
packages/esbuild-plugin-node/src/common.ts Show resolved Hide resolved
@drewcorlin1
Copy link
Owner

@RafalSumislawski i'll merge if that works for you?

@RafalSumislawski
Copy link
Author

Sure 👍

@drewcorlin1 drewcorlin1 merged commit f412b86 into drewcorlin1:esbuild-plugin Nov 21, 2024
17 checks passed
@drewcorlin1
Copy link
Owner

thanks again for the fix!

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.

2 participants