-
Notifications
You must be signed in to change notification settings - Fork 821
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
InstrumentationBase calls init on partly initialized Instrumentations #1989
Comments
@Flarna I believe this has been fixed. Can you confirm if this is still a bug? |
I don't think it's fixed as abstract |
Hi, As @Flarna mentioned this is not fixed yet and I think we would might want to challenge the design on how the Instrumentations are enabled/started to avoid more issues in the future. Here are my questions and thoughts about it. Bear in mind I wasn't there when this was designed and probably the context was different so the following observations are based in my knowledge of the project. Auto registration of Hooks upon constructor I've checked all documentation sources I know (website and *.md files from repos) and there is no example of using any instrumentation in isolation. The documented way of instrument an application is through the SDK (or auto instrumentations which uses the SDK under the hood) which actually does the wiring of many things: processors, exporters, readers, etc. The SDK also should be started before any require/import from the application. Why not then let the SDK signal the instrumentations when they should add their hooks? If we do so the logic could be placed in a different function rather than the constructor, breaking this parent-child constructor cycle (child calling super and parent calling child methods) Patch/unpatch logic exposed to overrides I guess a note in the dev guidelines compelling to call the super class function would suffice but I wonder if we could remove any chance of error. One possibility I see is to consider that an instrumentation have a lifecycle with at least 2 states: enabled, disabled. And provide Going back to this concrete issue @trentm and I though about using Here is an example of what we think it could fix the issue. IMO is a workaround and we should consider to solve the design issue for 2.0 |
This is not the only issue with the current design. I've just created open-telemetry/opentelemetry-js-contrib#2320 and I think we should discuss this in the SIG |
What version of OpenTelemetry are you using?
0.17.0
What version of Node are you using?
14.16.0
What did you do?
see open-telemetry/opentelemetry-js-contrib#354 (comment)
Implementing an
Instrumentation
which uses a private property ininit()
.What did you expect to see?
Instrumentation should work
What did you see instead?
init()
was called before the private property was initialized.Additional context
InstrumentationAbstract
declaresabstract init()
init()
most be implemented in a concrete instrumentation class extendingInstrumentationBase
InstrumentationBase
callsthis.init()
==> This result in calling
init()
of the concreteInstrumentation
instance before the constructor has finished. The functions of this instrumentation are in place but the properties are not yet initialized resulting in undefined behavior.Refs.: microsoft/TypeScript#9209
The text was updated successfully, but these errors were encountered: