Open RoadRunnr opened 3 months ago
Hey @RoadRunnr, this repository is not the home of that library. Please raise the issue in its repo for assistance https://github.com/beam-telemetry/cowboy_telemetry
Also, please include a working example and failing test
@bryannaegele but the stacktrace shows otel_telemetry crashing?
@bryannaegele but the stacktrace shows otel_telemetry crashing?
The later comments and errors higher up the stacktrace are suggesting the issue is running both stream handlers, so the issue would be in that library.
using the cowboy_telemetry_h and cowboy_metrics_h handler together, the metrics cb fails
And the offending conflict appears to be happening in the setup with some prometheus callback that's being run from another library.
metrics_callback => fun prometheus_cowboy2_instrumenter:observe/1,
stream_handlers => [cowboy_telemetry_h, cowboy_metrics_h, cowboy_stream_h]
opentelemetry_cowboy
does nothing with stream handlers or anything else of that matter. It's just listening on telemetry events.
@bryannaegele the root cause is the way how cowboy_telemetry_h abuses cowboy_metrics_h, but the crash is in otel_telemetry:pop_from_tracer_stack/1
in this repo. The sister method otel_telemetry:peek_from_tracer_stack/1
does have special support for an empty context stack. So why would the others methods not have that too??
It's just listening on telemetry events.
And its exactly those events that cause a crash. I would think that listening to events not cause a crash like that.
If you want to open a PR, we can accept that. But this error means you are ending a span early and your trace will be missing the root span.
Describe the bug
When using the cowboy_telemetry_h and cowboy_metrics_h handler together, the metrics cb fails with:
Additionally, the cowboy_telemetry_h unconditionally overwrites the metrics_callback. That fact is neither documented nor desirable.
Expected behavior not failing
Additional context
cowboy setup: