How to suppress opentelemetry java auto instrumentation for some calls

Viewed 842

I use opentelemetry java agent for tracing. It provides auto instrumentation for JDBC calls. Recently I added the quartz java library. It provides a lot of traces when the quartz makes internal requests to DB.

I wonder if there is a way to suppress particular traces? I don't want to disable auto instrumentation for all JDBC calls.

UPDATED

I tried -Dotel.instrumentation.quartz.enabled=false, but it just disables the job execution traces, but jdbc calls still appear.

I tried -Dotel.javaagent.exclude-classes=, but it's definitely hard to identify which class of quartz I need to put here to suppress the jdbc calls.

2 Answers

You can use the following approach to suppress the quartz instrumentation:

-Dotel.instrumentation.quartz.enabled=false

Or using the environment variable:

OTEL_INSTRUMENTATION_QUARTZ_ENABLED=false

This would disable the quartz instrumentation, and it would avoid the over creation of spans in your case.
You can also control further using the fine-grained approach, where you can exclude the instrumentation of specific classes with a syntax like that:

otel.javaagent.exclude-classes="my.package.MyClass,my.package2.*"

Or with the environment variable:

OTEL_JAVAAGENT_EXCLUDE_CLASSES="my.package.MyClass,my.package2.*"

Here is the whole documentation on how to suppress specific agent instrumentation: https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/docs/suppressing-instrumentation.md#suppressing-specific-agent-instrumentation

Related