UNPKG

@sentry/remix

Version:
63 lines (49 loc) 1.96 kB
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const core = require('@sentry/core'); const node = require('@sentry/node'); const instrumentation = require('../../vendor/instrumentation.js'); const INTEGRATION_NAME = 'Remix'; const instrumentRemix = node.generateInstrumentOnce(INTEGRATION_NAME, (options) => { return new instrumentation.RemixInstrumentation(options); }); const _remixIntegration = (() => { return { name: 'Remix', setupOnce() { const client = node.getClient(); const options = client?.getOptions() ; instrumentRemix({ actionFormDataAttributes: options?.sendDefaultPii ? options?.captureActionFormDataKeys : undefined, }); }, setup(client) { client.on('spanStart', span => { addRemixSpanAttributes(span); }); }, }; }) ; const addRemixSpanAttributes = (span) => { const attributes = node.spanToJSON(span).data; // this is one of: loader, action, requestHandler const type = attributes['code.function']; // If this is already set, or we have no remix span, no need to process again... if (attributes[core.SEMANTIC_ATTRIBUTE_SENTRY_OP] || !type) { return; } // `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. // All other spans are marked as `remix` operations with their specific type [loader, action] const op = type === 'requestHandler' ? 'http.server' : `${type}.remix`; span.setAttributes({ [core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.otel.remix', [core.SEMANTIC_ATTRIBUTE_SENTRY_OP]: op, }); }; /** * Instrumentation for aws-sdk package */ const remixIntegration = core.defineIntegration(_remixIntegration); exports.remixIntegration = remixIntegration; //# sourceMappingURL=opentelemetry.js.map