Skip to content

Commit 91ad0ef

Browse files
committed
No need to pass trace_id around anymore
1 parent 5c23a90 commit 91ad0ef

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

lib/sentry/opentelemetry/span_processor.ex

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ defmodule Sentry.Opentelemetry.SpanProcessor do
101101
op: root_span.name
102102
}
103103
},
104-
spans: Enum.map([root_span | child_spans], &build_span(&1, root_span.trace_id))
104+
spans: Enum.map([root_span | child_spans], &build_span(&1))
105105
})
106106
end
107107

@@ -143,7 +143,7 @@ defmodule Sentry.Opentelemetry.SpanProcessor do
143143
"query_time_microseconds" => attributes[:query_time_microseconds]
144144
},
145145
measurements: %{},
146-
spans: Enum.map(child_spans, &build_span(&1, root_span.trace_id))
146+
spans: Enum.map(child_spans, &build_span(&1))
147147
})
148148
end
149149

@@ -190,7 +190,7 @@ defmodule Sentry.Opentelemetry.SpanProcessor do
190190
}
191191
},
192192
measurements: %{},
193-
spans: Enum.map(child_spans, &build_span(&1, root_span.trace_id))
193+
spans: Enum.map(child_spans, &build_span(&1))
194194
})
195195
end
196196

@@ -230,7 +230,7 @@ defmodule Sentry.Opentelemetry.SpanProcessor do
230230
}
231231
},
232232
measurements: %{},
233-
spans: Enum.map(child_spans, &build_span(&1, root_span.trace_id))
233+
spans: Enum.map(child_spans, &build_span(&1))
234234
}
235235
end
236236

@@ -248,26 +248,25 @@ defmodule Sentry.Opentelemetry.SpanProcessor do
248248
end
249249

250250
defp build_span(
251-
%SpanRecord{origin: "opentelemetry_phoenix", attributes: attributes} = span_record,
252-
trace_id
251+
%SpanRecord{origin: "opentelemetry_phoenix", attributes: attributes} = span_record
253252
) do
254253
op = "#{attributes[:"phoenix.plug"]}##{attributes[:"phoenix.action"]}"
255254

256255
%Span{
257256
op: op,
258257
start_timestamp: cast_timestamp(span_record.start_time),
259258
timestamp: cast_timestamp(span_record.end_time),
260-
trace_id: trace_id,
259+
trace_id: span_record.trace_id,
261260
span_id: span_record.span_id,
262261
parent_span_id: span_record.parent_span_id,
263262
description: attributes[:"http.route"],
264263
origin: span_record.origin
265264
}
266265
end
267266

268-
defp build_span(%SpanRecord{origin: "phoenix_app"} = span_record, trace_id) do
267+
defp build_span(%SpanRecord{origin: "phoenix_app"} = span_record) do
269268
%Span{
270-
trace_id: trace_id,
269+
trace_id: span_record.trace_id,
271270
op: span_record.name,
272271
start_timestamp: cast_timestamp(span_record.start_time),
273272
timestamp: cast_timestamp(span_record.end_time),
@@ -276,9 +275,9 @@ defmodule Sentry.Opentelemetry.SpanProcessor do
276275
}
277276
end
278277

279-
defp build_span(%SpanRecord{origin: "opentelemetry_bandit"} = span_record, trace_id) do
278+
defp build_span(%SpanRecord{origin: "opentelemetry_bandit"} = span_record) do
280279
%Span{
281-
trace_id: trace_id,
280+
trace_id: span_record.trace_id,
282281
op: span_record.name,
283282
start_timestamp: cast_timestamp(span_record.start_time),
284283
timestamp: cast_timestamp(span_record.end_time),
@@ -289,12 +288,9 @@ defmodule Sentry.Opentelemetry.SpanProcessor do
289288
}
290289
end
291290

292-
defp build_span(
293-
%SpanRecord{origin: "opentelemetry_ecto", attributes: attributes} = span_record,
294-
trace_id
295-
) do
291+
defp build_span(%SpanRecord{origin: "opentelemetry_ecto", attributes: attributes} = span_record) do
296292
%Span{
297-
trace_id: trace_id,
293+
trace_id: span_record.trace_id,
298294
op: span_record.name,
299295
start_timestamp: cast_timestamp(span_record.start_time),
300296
timestamp: cast_timestamp(span_record.end_time),
@@ -308,12 +304,9 @@ defmodule Sentry.Opentelemetry.SpanProcessor do
308304
}
309305
end
310306

311-
defp build_span(
312-
%SpanRecord{origin: :undefined, attributes: _attributes} = span_record,
313-
trace_id
314-
) do
307+
defp build_span(%SpanRecord{origin: :undefined, attributes: _attributes} = span_record) do
315308
%Span{
316-
trace_id: trace_id,
309+
trace_id: span_record.trace_id,
317310
op: span_record.name,
318311
start_timestamp: cast_timestamp(span_record.start_time),
319312
timestamp: cast_timestamp(span_record.end_time),

0 commit comments

Comments
 (0)