Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(remix): Ensure origin is correctly set for remix server spans #13305

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading