opentelemetry-python icon indicating copy to clipboard operation
opentelemetry-python copied to clipboard

Measure number of dropped spans in `BatchSpanProcessor`

Open wmwmw opened this issue 2 years ago • 7 comments

Is your feature request related to a problem? We would like to measure the number of dropped spans with the BatchSpanProcessor, simple True / False flag is not sufficient, as some (low) numbers of drops might not indicate anything bad.

Describe the solution you'd like Having a simple way to add a meter without having to override or wrap on_exit to see how many spans were dropped because of a full queue. Ideally, a call to a callback when spans are dropped due to a full queue.

Describe alternatives you've considered Re-implementing the on_exit of BatchSpanProcessor with added on_drop callback with a meter or adding a meter directly there. Eventually wrapping the existing method by checking the _spans_dropped flag and changing it back to false after incrementing a meter. Both methods might interfere with future changes, the latter would increase the log rate.

wmwmw avatar Jan 31 '23 16:01 wmwmw

Are you trying to access the counts programmatically or just monitor the queue? In the spirit of OTel, we should consider adding the metric instrumentation directly to the BatchSpanProcessor code.

aabmass avatar Feb 10 '23 19:02 aabmass

I am just trying to monitor it, so doing it that way would also solve the issue for me and I don't need to have the number anywhere else.

wmwmw avatar Feb 10 '23 19:02 wmwmw

Hi , Is this issue still open to be picked up ? cc - @srikanthccv

sreejitkar avatar Mar 26 '23 08:03 sreejitkar

@sreejitkar

Would you like to be assigned?

lzchen avatar Mar 27 '23 01:03 lzchen

Yes please. Thanks !

sreejitkar avatar Mar 27 '23 03:03 sreejitkar

I have submitted a PR for this, Can someone please review and suggest improvements?

rajat315315 avatar Jul 19 '23 12:07 rajat315315

Was having a look at this issue and noticed that when adding spans to the BatchSpanProcessor's queue, its size is never greater than the max_export_batch_size. BatchSpanProcessor validates that the max_export_batch_size is always <= max_queue_size (see _validate_arguments function that throws an error when max_export_batch_size > max_queue_size). This means that it is not possible to have any dropped spans. Please correct me if I am wrong.

soumyadeepm04 avatar Jul 13 '24 23:07 soumyadeepm04