microsoft / ApplicationInsights-Java

Application Insights for Java
http://aka.ms/application-insights
Other
296 stars 200 forks source link

Sampling based on dependency result #3619

Closed xsmrcek closed 8 months ago

xsmrcek commented 8 months ago

To impelment better cost cutting policy I would like to have option to sample dependency spans based on their result and duration. Example: I would like to record only dependency calls to CosmosBD which failed or took longer than 1 second.

It is possible now? If so can you please guide me how?
If not, would it be possible to consider implementing of such sampling in future?

heyams commented 8 months ago

@xsmrcek please check out this sample app i have created to filter out spans based on duration. You can do something similar for dependency using the OpenTelemetry Extensions. In this case, you can use a specific attribute to identify a CosmosDB dependency. DurationSpanExporter

Instruction: https://github.com/Azure-Samples/ApplicationInsights-Java-Samples/tree/main/opentelemetry-api/java-agent/TelemetryFilteredBaseOnRequestDuration

xsmrcek commented 8 months ago

Hi @heyams , thank you for response and example. I will totally try this!