Skip to content

Comments

Fully customizable OpenTelemetry Instumenter beans#734

Draft
lgathy wants to merge 1 commit intomicronaut-projects:7.0.xfrom
lgathy:fully-customisable-otel-instrumenters
Draft

Fully customizable OpenTelemetry Instumenter beans#734
lgathy wants to merge 1 commit intomicronaut-projects:7.0.xfrom
lgathy:fully-customisable-otel-instrumenters

Conversation

@lgathy
Copy link
Contributor

@lgathy lgathy commented Apr 3, 2025

Make OTel Instrumenter beans fully customizable via their factory methods

@lgathy
Copy link
Contributor Author

lgathy commented Apr 4, 2025

@n0tl3ss This draft exposes all customizations available on the OpenTelemetry InstrumenterBuilder-s by injecting them as beans in the factory methods. This way it is easy to add new client or server metrics, or replace the SpanNameExtractor-s, etc. Could you please take a look to see if this is a viable approach? I haven't added test just yet.

Another question I had: I saw that all beans defined in these factories are declared as @Prototype, but I couldn't quite figure out why that's needed. If I understand correctly, the Instrumenter object does not have any mutable state, as far as I can tell, every bean could be @Singleton, no? For now I added the new ones as singletons, but I'm keen to hear if you think that could be the case for all the existing beans in here as well. Thanks.

@graemerocher graemerocher requested a review from n0tl3ss April 4, 2025 07:12
@n0tl3ss
Copy link
Member

n0tl3ss commented Apr 4, 2025

Hi @lgathy I think you are right that @Prototype should be changed to @Singleton. Everything else looks ok to me. :)

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