Skip to content

Commit c781dcb

Browse files
committed
formatting
1 parent fb7b731 commit c781dcb

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

lib/sentry/opentelemetry/span_processor.ex

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,21 @@ if Code.ensure_loaded?(OpenTelemetry) do
1515
alias Sentry.{Transaction, OpenTelemetry.SpanStorage, OpenTelemetry.SpanRecord}
1616
alias Sentry.Interfaces.Span
1717

18-
# This can be a no-op since we can postpone inserting the span into storage until on_end
18+
# This can be a no-op since we can postpone inserting the span into storage until on_end
1919
@impl :otel_span_processor
2020
def on_start(_ctx, otel_span, _config) do
2121
otel_span
2222
end
2323

24-
@impl :otel_span_processor
24+
@impl :otel_span_processor
2525
def on_end(otel_span, _config) do
2626
span_record = SpanRecord.new(otel_span)
2727

2828
SpanStorage.store_span(span_record)
2929

3030
# Check if this is a root span (no parent) or a transaction root (HTTP request span)
31-
is_transaction_root = span_record.parent_span_id == nil or is_http_request_span?(span_record)
31+
is_transaction_root =
32+
span_record.parent_span_id == nil or is_http_request_span?(span_record)
3233

3334
if is_transaction_root do
3435
child_span_records = SpanStorage.get_child_spans(span_record.span_id)
@@ -71,12 +72,13 @@ if Code.ensure_loaded?(OpenTelemetry) do
7172
has_url_path = Map.has_key?(attributes, to_string(URLAttributes.url_path()))
7273

7374
# Check if the name looks like an HTTP endpoint
74-
name_looks_like_http = String.contains?(name, ["/", "POST", "GET", "PUT", "DELETE", "PATCH"])
75+
name_looks_like_http =
76+
String.contains?(name, ["/", "POST", "GET", "PUT", "DELETE", "PATCH"])
7577

7678
(has_http_method and (has_http_route or has_url_path)) or name_looks_like_http
7779
end
7880

79-
defp build_transaction(root_span_record, child_span_records) do
81+
defp build_transaction(root_span_record, child_span_records) do
8082
root_span = build_span(root_span_record)
8183
child_spans = Enum.map(child_span_records, &build_span(&1))
8284

@@ -93,7 +95,7 @@ if Code.ensure_loaded?(OpenTelemetry) do
9395
})
9496
end
9597

96-
defp transaction_name(
98+
defp transaction_name(
9799
%{attributes: %{unquote(to_string(MessagingAttributes.messaging_system())) => :oban}} =
98100
span_record
99101
) do

test/sentry/opentelemetry/span_processor_test.exs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ defmodule Sentry.Opentelemetry.SpanProcessorTest do
234234
assert length(transaction.spans) == 0
235235
assert transaction.transaction == "child_instrumented_function_standalone"
236236
end
237-
237+
238238
@tag span_storage: true
239239
test "treats HTTP request spans as transaction roots even with external parents" do
240240
put_test_config(environment_name: "test", traces_sample_rate: 1.0)
@@ -248,7 +248,7 @@ defmodule Sentry.Opentelemetry.SpanProcessorTest do
248248

249249
# Create a span with HTTP attributes and an external parent span ID
250250
external_parent_span_id = "b943d7459127970c"
251-
251+
252252
# Start a span that simulates an HTTP request from an external trace
253253
Tracer.with_span "POST /api/v1alpha", %{
254254
attributes: %{
@@ -258,7 +258,9 @@ defmodule Sentry.Opentelemetry.SpanProcessorTest do
258258
"server.address" => "localhost",
259259
"server.port" => 4000
260260
},
261-
parent: {:span_context, :undefined, external_parent_span_id, :undefined, :undefined, :undefined, :undefined, :undefined, :undefined, :undefined}
261+
parent:
262+
{:span_context, :undefined, external_parent_span_id, :undefined, :undefined, :undefined,
263+
:undefined, :undefined, :undefined, :undefined}
262264
} do
263265
# Simulate child spans (database queries, etc.) with proper DB attributes
264266
Tracer.with_span "matrix_data.repo.query", %{
@@ -269,7 +271,7 @@ defmodule Sentry.Opentelemetry.SpanProcessorTest do
269271
} do
270272
Process.sleep(10)
271273
end
272-
274+
273275
Tracer.with_span "matrix_data.repo.query:agents", %{
274276
attributes: %{
275277
"db.system" => :postgresql,
@@ -295,11 +297,11 @@ defmodule Sentry.Opentelemetry.SpanProcessorTest do
295297

296298
# Verify all spans share the same trace ID
297299
trace_id = transaction.contexts.trace.trace_id
300+
298301
Enum.each(transaction.spans, fn span ->
299302
assert span.trace_id == trace_id
300303
end)
301304
end
302-
303305

304306
@tag span_storage: true
305307
test "concurrent traces maintain independent sampling decisions" do

0 commit comments

Comments
 (0)