Closed garthk closed 4 years ago
Yes, I also faced the same issue as existing event-based tracking code is not correct. I can give PR on this issue. Meanwhile, we can use the following code.
instead of sending the event type to OpenTelemetry.Span.add_event/1
call the custom API which directly calls the erlang API
Follow this process.
define your attributes and event_name
Once you define the event_name
and event_attributes
require OpenTelemetry.Tracer
require OpenTelemetry.Span
OpenTelemetry.register_application_tracer(:this_otp_app)
OpenTelemetry.Tracer.start_span("some-span")
event_attributes = [{"query", query}, {"total_time", total_time}]
event_name = "ecto.query"
add_event(event_name, event_attributes)
OpenTelemetry.Tracer.end_span()
Custom API to push the event to current span
defp add_event(event_name, attributes) do
tracer = :opentelemetry.get_tracer(__MODULE__)
span_ctx = OpenTelemetry.Tracer.current_span_ctx()
# Elixir API is having issues so directly using erlang API
:ot_span.add_event(tracer, span_ctx, event_name, attributes)
end
Thanks, not sure how I let this issue slip by me. I'll try to resolve it today.
@tsloughter Hey I have given a PR can you have a look and tell me what all is needed in case it's having some issues.
@tsloughter This should be closed since its fixed in #56
OpenTelemetry.Span.add_event/1` doesn't work.
I'm trying the example code in
lib/open_telemetry.ex
. Roughly adapted:The call to
OpenTelemetry.Span.add_event/1
is failing because:The calling code is:
That argument order was present in the first version of
:ot_span.add_events/3
but hasn't been seen since we switched to tracer, events, context in November.