Skip to content

Commit 574af7c

Browse files
committed
WIP
1 parent 01fc79e commit 574af7c

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

test_integrations/phoenix_app/lib/phoenix_app/application.ex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ defmodule PhoenixApp.Application do
1414
})
1515

1616
OpentelemetryBandit.setup()
17+
18+
# Set up Sentry's LiveView context propagation BEFORE OpentelemetryPhoenix
19+
# This enables distributed tracing context to flow from HTTP requests to LiveView WebSocket processes
20+
Sentry.OpenTelemetry.LiveViewPropagator.setup()
21+
1722
OpentelemetryPhoenix.setup(adapter: :bandit)
1823
OpentelemetryOban.setup()
1924
OpentelemetryEcto.setup([:phoenix_app, :repo], db_statement: :enabled)

test_integrations/phoenix_app/lib/phoenix_app_web/router.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ defmodule PhoenixAppWeb.Router do
88
plug :put_root_layout, html: {PhoenixAppWeb.Layouts, :root}
99
plug :protect_from_forgery
1010
plug :put_secure_browser_headers
11+
plug Sentry.Plug.LiveViewContext
1112
end
1213

1314
pipeline :api do

test_integrations/tracing/tests/tracing.spec.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ test.describe("Tracing", () => {
490490
(event) =>
491491
event.contexts?.trace?.op === "http.server" &&
492492
((event.contexts?.trace?.data as any)?.["http.route"] === "/users" ||
493-
event.transaction?.includes("/users"))
493+
event.transaction?.includes("/users"))
494494
);
495495
expect(liveViewHttpTransaction).toBeDefined();
496496

@@ -502,19 +502,26 @@ test.describe("Tracing", () => {
502502
event.transaction?.includes("UserLive.Index.mount") ||
503503
event.transaction?.includes(".mount")
504504
);
505-
505+
506506
// Find mount transaction that has spans (prefer one with DB spans)
507-
const liveViewMountTransaction = liveViewMountTransactions.find(tx => {
508-
const spans = (tx as any).spans || [];
509-
return spans.length > 0;
510-
}) || liveViewMountTransactions[0];
511-
507+
const liveViewMountTransaction =
508+
liveViewMountTransactions.find((tx) => {
509+
const spans = (tx as any).spans || [];
510+
return spans.length > 0;
511+
}) || liveViewMountTransactions[0];
512+
512513
expect(liveViewMountTransaction).toBeDefined();
513514

514515
// All should have valid trace IDs
515-
expect(apiTransaction?.contexts?.trace?.trace_id).toMatch(/^[a-f0-9]{32}$/);
516-
expect(liveViewHttpTransaction?.contexts?.trace?.trace_id).toMatch(/^[a-f0-9]{32}$/);
517-
expect(liveViewMountTransaction?.contexts?.trace?.trace_id).toMatch(/^[a-f0-9]{32}$/);
516+
expect(apiTransaction?.contexts?.trace?.trace_id).toMatch(
517+
/^[a-f0-9]{32}$/
518+
);
519+
expect(liveViewHttpTransaction?.contexts?.trace?.trace_id).toMatch(
520+
/^[a-f0-9]{32}$/
521+
);
522+
expect(liveViewMountTransaction?.contexts?.trace?.trace_id).toMatch(
523+
/^[a-f0-9]{32}$/
524+
);
518525

519526
// Verify the API transaction has database spans
520527
const apiSpans = (apiTransaction as any)?.spans || [];

0 commit comments

Comments
 (0)