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

How to ignore some traces or methods being collected #7511

Closed
kingkongpoon opened this issue Jan 5, 2023 · 18 comments · Fixed by #7553
Closed

How to ignore some traces or methods being collected #7511

kingkongpoon opened this issue Jan 5, 2023 · 18 comments · Fixed by #7553
Labels
enhancement New feature or request

Comments

@kingkongpoon
Copy link

Java 8
SpringBoot 2.3.5.RELEASE
otel 1.19.0

my project have a kafka consumer
then it will collect too many traces which I don't want

code like this

@Component
public class KafkaMessageReceive {
    @KafkaListener(topics = "test-kafka")
    public void processMessageString(String content) {
        log.info("test-kafka", content);
    }
}

image

Operation like this
KafkaMessageListenerContainer$ListenerConsumer$$Lambda$.run

this is otlp metrics for per minute
image

-Dotel.traces.exporter=otlp -Dotel.exporter.otlp.endpoint=http://xxxx:xx -Dotel.metrics.exporter=otlp 
 -Dotel.service.name=666666  -Dotel.logs.exporter=none 
-Dotel.metric.export.interval=60000 -Dotel.javaagent.exclude-classes="com.example.service.KafkaMessageReceive"  
-javaagent:xxx\opentelemetry-javaagent.jar

how to ignore it?

@kingkongpoon kingkongpoon added the enhancement New feature or request label Jan 5, 2023
@mateuszrzeszutek
Copy link
Member

Hey @kingkongpoon ,

Can you post full contents of that unwanted span?

@kingkongpoon
Copy link
Author

kingkongpoon commented Jan 6, 2023

HI @mateuszrzeszutek .
do you mean this?

KafkaMessageListenerContainer$ListenerConsumer$$Lambda$.run
org.springframework.kafka.listener.KafkaMessageListenerContainer$ListenerConsumer$$Lambda$1163/1414529337

image

or the original span data in elasticsearch ?

some of my springboot project will consume message from kafka ,and the message can be 6 million per minute .
so too many unused traces/spans be collected.

how to ignore it ?

@kingkongpoon
Copy link
Author

kingkongpoon commented Jan 6, 2023

Although there is no new message from kafka ,it will still produce new traces from kafka listener consumer,why?

thread.name ThreadPoolTaskScheduler-1

it seems like a Scheduler's traces ?
image

@mateuszrzeszutek
Copy link
Member

Yeah, these spans are created by the spring scheduler.
To work around this issue, can you try running your application with the -Dotel.instrumentation.spring-scheduling.enabled=false option? It'll disable the spring scheduler instrumentation.

@kingkongpoon
Copy link
Author

Ok, it works,thanks a lot. :)

@kingkongpoon
Copy link
Author

In the same project,why it notice
clock skew adjustment disabled; not applying calculated delta of xxxx ?
image

@mateuszrzeszutek
Copy link
Member

@kingkongpoon
Copy link
Author

OK ,thank you ! 👍

@kingkongpoon
Copy link
Author

Hello @mateuszrzeszutek
I think this problem still exist
this is my env prod span data
image
jaeger
image
otlp
image
image

otlp span collector metrics
image
it still seem too many traces ?

@mateuszrzeszutek
Copy link
Member

Hey @kingkongpoon ,

What version of the agent are you using? The fix I made was included as a part of the 1.22.0 release.

@kingkongpoon
Copy link
Author

@mateuszrzeszutek Hello
the kafka problem has sloved,
but the new problem seem different
I update to 1.22.1
but the problem do not slove.
is there any metrics like processedSpans can tell me which method product such tracs/spans?
image

@mateuszrzeszutek
Copy link
Member

The processedSpans counter is defined in the SDK repo: https://github.com/open-telemetry/opentelemetry-java/blob/aa873a05be27137d276de5fa50557add5f78184c/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/export/BatchSpanProcessor.java#L200

If you're missing it, then perhaps there is a bug in the OTel SDK - please file an issue in the opentelemetry-java repo.

@kingkongpoon
Copy link
Author

Hey @mateuszrzeszutek
I can find processedSpans
but it only tell me how many spans, it can not tell me why my program product lot's of useless spans.
is there any metrics like this
image
so I can find out why product so many spans ?

@kingkongpoon
Copy link
Author

some spans like this how to exclude ?
may be like -Dotel.instrumentation.spring-scheduling.enabled=false ?
image
image

@mateuszrzeszutek
Copy link
Member

but it only tell me how many spans, it can not tell me why my program product lot's of useless spans.
is there any metrics like this

No, there are no metrics like that. You can investigate the spans themselves though.

some spans like this how to exclude ?
may be like -Dotel.instrumentation.spring-scheduling.enabled=false ?

These look like SERVER spans; perhaps there is some process that periodically calls your application? Disabling the server instrumentations entirely is not exactly a good idea; you could use a custom sampler to filter these out though - take a look at #1060, might be useful for your case.

Anyway, since this deviated from the original topic, if you run into any other problems please open a new issue.

@MartinEmrich
Copy link

What would be the equivalent for -Dotel.instrumentation.spring-scheduling.enabled=false for RuntimeAttach.attachJavaagentToCurrentJvm();?

@trask
Copy link
Member

trask commented Dec 14, 2023

hi @MartinEmrich, can you open a new issue for your question? thx

@MartinEmrich
Copy link

@trask done: #10076

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
4 participants