Skip to content

Commit

Permalink
feat: use OpenTelemetry spans to also produce metrics (#1513)
Browse files Browse the repository at this point in the history
  • Loading branch information
icehaunter authored Aug 12, 2024
1 parent 3135678 commit a5b74de
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 1 addition & 4 deletions packages/sync-service/lib/electric/telemetry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ defmodule Electric.Telemetry do
tags: [:route],
unit: {:native, :millisecond}
),
summary("electric.query.duration", unit: {:native, :millisecond}),
summary("electric.query.serialization_duration", unit: {:native, :millisecond}),
summary("electric.snapshot.storage", unit: {:native, :millisecond}),
summary("electric.snapshot.encoding", unit: {:native, :millisecond})
summary("electric.shape_cache.create_snapshot_task.stop", unit: {:native, :millisecond})
]
|> Enum.map(&%{&1 | tags: [:instance_id | &1.tags]})
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ defmodule Electric.Telemetry.OpenTelemetry do
kind: :internal
}

:otel_tracer.with_span(tracer(), name, span_opts, fn _span_ctx -> fun.() end)
erlang_telemetry_event = [
:electric | name |> String.split(".", trim: true) |> Enum.map(&String.to_atom/1)
]

:telemetry.span(erlang_telemetry_event, Map.new(attributes), fn ->
{:otel_tracer.with_span(tracer(), name, span_opts, fn _span_ctx -> fun.() end), %{}}
end)
end

@doc """
Expand Down

0 comments on commit a5b74de

Please sign in to comment.