Skip to content

Commit 16996bb

Browse files
authored
fix(remix): Ensure origin is correctly set for remix server spans (#13305)
Noticed here: #13282 that we are not correctly setting origin for remix spans.
1 parent b29d771 commit 16996bb

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

packages/remix/src/utils/integrations/opentelemetry.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { RemixInstrumentation } from 'opentelemetry-instrumentation-remix';
22

3-
import { defineIntegration } from '@sentry/core';
4-
import { SEMANTIC_ATTRIBUTE_SENTRY_OP, generateInstrumentOnce, getClient, spanToJSON } from '@sentry/node';
3+
import { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, defineIntegration } from '@sentry/core';
4+
import { generateInstrumentOnce, getClient, spanToJSON } from '@sentry/node';
55
import type { Client, IntegrationFn, Span } from '@sentry/types';
66
import type { RemixOptions } from '../remixOptions';
77

@@ -47,13 +47,13 @@ const addRemixSpanAttributes = (span: Span): void => {
4747
// `requestHandler` span from `opentelemetry-instrumentation-remix` is the main server span.
4848
// It should be marked as the `http.server` operation.
4949
// The incoming requests are skipped by the custom `RemixHttpIntegration` package.
50-
if (type === 'requestHandler') {
51-
span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'http.server');
52-
return;
53-
}
54-
5550
// All other spans are marked as `remix` operations with their specific type [loader, action]
56-
span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, `${type}.remix`);
51+
const op = type === 'requestHandler' ? 'http.server' : `${type}.remix`;
52+
53+
span.setAttributes({
54+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.otel.remix',
55+
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: op,
56+
});
5757
};
5858

5959
/**

packages/remix/test/integration/test/server/instrumentation-otel/loader.test.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,17 @@ describe('Remix API Loaders', () => {
103103
data: {
104104
'code.function': 'loader',
105105
'sentry.op': 'loader.remix',
106+
'sentry.origin': 'auto.http.otel.remix',
106107
},
107-
origin: 'manual',
108+
origin: 'auto.http.otel.remix',
108109
},
109110
{
110111
data: {
111112
'code.function': 'loader',
112113
'sentry.op': 'loader.remix',
114+
'sentry.origin': 'auto.http.otel.remix',
113115
},
114-
origin: 'manual',
116+
origin: 'auto.http.otel.remix',
115117
},
116118
],
117119
});

0 commit comments

Comments
 (0)