opentelemetry-erlang-contrib
opentelemetry-erlang-contrib copied to clipboard
Selective emitting of events
Is your feature request related to a problem? Please describe. I would like to send selective metrics instead of every query executed.
Describe the solution you'd like Optionally enable selective emitting of events via configurations
config :opentelemetry_ecto,
explicit_capture: true,
capture_key: :capture,
capture_value: true
# In my application that is a hot code path
# I care about this query's metrics
MyRepo.all(query, telemetry_options: [capture: true])
# Somewhere else in my application that is NOT a hot code path
# I don't care about this query, it's just noise and expensive to report and store
MyRepo.all(query)
In handle_event/4 if :explicit_capture is enabled we only emit events with the appropriate capture key and value
Describe alternatives you've considered
I can't think of an alternative to conditionally emitting events besides implementing my own subscribe and handle_event/4
Additional context Every metric that you store and emit has a cost to it, I'm trying to limit that.
Would you welcome an MR that attempts to implement some version of this?
Would it work in your case if you could wrap the code that has queries you don't want to collect in a call to something like untraced that would be a macro like with_span but that disables any child spans from being sampled?