Skip to content

Commit

Permalink
fix(remix): Ensure origin is correctly set for remix server spans (#…
Browse files Browse the repository at this point in the history
…13305)

Noticed here: #13282
that we are not correctly setting origin for remix spans.
  • Loading branch information
mydea authored Aug 12, 2024
1 parent b29d771 commit 16996bb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
16 changes: 8 additions & 8 deletions packages/remix/src/utils/integrations/opentelemetry.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { RemixInstrumentation } from 'opentelemetry-instrumentation-remix';

import { defineIntegration } from '@sentry/core';
import { SEMANTIC_ATTRIBUTE_SENTRY_OP, generateInstrumentOnce, getClient, spanToJSON } from '@sentry/node';
import { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, defineIntegration } from '@sentry/core';
import { generateInstrumentOnce, getClient, spanToJSON } from '@sentry/node';
import type { Client, IntegrationFn, Span } from '@sentry/types';
import type { RemixOptions } from '../remixOptions';

Expand Down Expand Up @@ -47,13 +47,13 @@ const addRemixSpanAttributes = (span: Span): void => {
// `requestHandler` span from `opentelemetry-instrumentation-remix` is the main server span.
// It should be marked as the `http.server` operation.
// The incoming requests are skipped by the custom `RemixHttpIntegration` package.
if (type === 'requestHandler') {
span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'http.server');
return;
}

// All other spans are marked as `remix` operations with their specific type [loader, action]
span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, `${type}.remix`);
const op = type === 'requestHandler' ? 'http.server' : `${type}.remix`;

span.setAttributes({
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.otel.remix',
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: op,
});
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,17 @@ describe('Remix API Loaders', () => {
data: {
'code.function': 'loader',
'sentry.op': 'loader.remix',
'sentry.origin': 'auto.http.otel.remix',
},
origin: 'manual',
origin: 'auto.http.otel.remix',
},
{
data: {
'code.function': 'loader',
'sentry.op': 'loader.remix',
'sentry.origin': 'auto.http.otel.remix',
},
origin: 'manual',
origin: 'auto.http.otel.remix',
},
],
});
Expand Down

0 comments on commit 16996bb

Please sign in to comment.