Skip to content

Add Telemetry for Extension Finder SPIs#11298

Open
mhlidd wants to merge 4 commits intomasterfrom
mhlidd/add_extension_finder_telemetry
Open

Add Telemetry for Extension Finder SPIs#11298
mhlidd wants to merge 4 commits intomasterfrom
mhlidd/add_extension_finder_telemetry

Conversation

@mhlidd
Copy link
Copy Markdown
Contributor

@mhlidd mhlidd commented May 6, 2026

What Does This Do

This PR sends metrics for all tracked OTel SPIs that are registered at any of the JAR files on the path listed by otel.javaagent.extensions or dd.trace.extensions.path. We use a static list of SPIs in order to reduce the impact on startup time. This list can be updated as OTel increases their support scope.

Motivation

Additional Notes

Contributor Checklist

Jira ticket: [PROJ-IDENT]

Note: Once your PR is ready to merge, add it to the merge queue by commenting /merge. /merge -c cancels the queue request. /merge -f --reason "reason" skips all merge queue checks; please use this judiciously, as some checks do not run at the PR-level. For more information, see this doc.

@mhlidd mhlidd added type: enhancement Enhancements and improvements comp: telemetry Telemetry tag: ai generated Largely based on code generated by an AI or LLM labels May 6, 2026
@mhlidd mhlidd marked this pull request as ready for review May 6, 2026 23:28
@mhlidd mhlidd requested a review from a team as a code owner May 6, 2026 23:28
@mhlidd mhlidd requested review from amarziali and mcculls May 6, 2026 23:28
if (name.startsWith(SERVICES_PREFIX)) {
String fqn = name.substring(SERVICES_PREFIX.length());
if (fqn.startsWith(OTEL_NAMESPACE)) {
OtelSpiCollector.getInstance().recordSpiDetected(fqn, EXTENSIONS_PATH_SOURCE);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we exit here do avoid looping on entries if we already found?

Copy link
Copy Markdown
Contributor

@mcculls mcculls May 7, 2026

Choose a reason for hiding this comment

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

If the goal here is to report all service files under the OTel namespace then the best we could do is exit on the first entry that doesn't start with the services prefix. That's assuming that the service entries appear in a group, which they usually do. If assume that the service entries are ordered then we could exit on the next entry that doesn't start with the OTel namespace.

However I'd like to know about what we intend to gain from this telemetry since this will incur a non-trivial startup cost, albeit only when extensions are added to the tracer (which is uncommon.)

i.e. if the goal is to survey what SPIs are being added as extensions, even though we don't currently support them then I guess this is the only way to discover that (although it would be a good idea to short-circuit the searching when we get to jar entries that we know should appear after service entries - you can look at some example OTel extension jars to see if there's a pattern.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the goal is to survey what SPIs are being added as extensions, even though we don't currently support them

This is exactly the goal here. For the purpose of having information of what SPIs are commonly being used even though we don't support them yet.

Copy link
Copy Markdown
Contributor Author

@mhlidd mhlidd May 7, 2026

Choose a reason for hiding this comment

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

EDIT: See comment below. TLDR scanning from a static list instead of iterating through all jars.
@mcculls I had Claude go thru some sample OTel extension jar files from Maven Central and it found that Services entries are contiguous, but custom services entries can be shoved in-between OTel service entries.

e.g.:

[1357] META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider
[1358] META-INF/services/co.elastic.otel.common.ChainingSpanProcessorAutoConfiguration
[1359] META-INF/services/io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule

Generally, it appears that JAR files will write all service entries contiguously, but that's technically not guarnateed. IMO, some data is better than no data, so I'm fine w/ reading until the end of service entries, and quitting early. I'll implement this change here.

@mhlidd
Copy link
Copy Markdown
Contributor Author

mhlidd commented May 7, 2026

@amarziali @mcculls I've updated this PR to use a static list of known OTel SPIs instead of looping through all JAR files. This list is fairly limited and should hopefully reduce the impact on startup time.

@mhlidd mhlidd requested a review from amarziali May 7, 2026 18:56
Base automatically changed from mhlidd/add_extensions_metric to master May 7, 2026 19:09
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot requested review from a team as code owners May 7, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: telemetry Telemetry tag: ai generated Largely based on code generated by an AI or LLM type: enhancement Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants