From 4c730f6603c8d18bfc58e424ecd864c9031d42e9 Mon Sep 17 00:00:00 2001 From: Oleksii Sholik Date: Fri, 13 Dec 2024 16:41:50 +0200 Subject: [PATCH] Set OTEL span status to error when an exception is recorded for it (#2165) Closes #2027. --- .../sync-service/lib/electric/telemetry/open_telemetry.ex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/sync-service/lib/electric/telemetry/open_telemetry.ex b/packages/sync-service/lib/electric/telemetry/open_telemetry.ex index 699af4dff4..ce6c1c3d8e 100644 --- a/packages/sync-service/lib/electric/telemetry/open_telemetry.ex +++ b/packages/sync-service/lib/electric/telemetry/open_telemetry.ex @@ -154,7 +154,9 @@ defmodule Electric.Telemetry.OpenTelemetry do Exception.format_stacktrace(stacktrace)} ] - :otel_span.add_event(get_current_context(), "exception", semantic_attributes ++ attributes) + ctx = get_current_context() + :otel_span.add_event(ctx, "exception", semantic_attributes ++ attributes) + :otel_span.set_status(ctx, :error, message) end defp tracer, do: :opentelemetry.get_tracer()