MCPcopy Create free account
hub / github.com/getsentry/sentry-javascript / getSentryResource

Function getSentryResource

packages/opentelemetry/src/resource.ts:82–102  ·  view source on GitHub ↗
(serviceNameFallback: string)

Source from the content-addressed store, hash-verified

80 * per the OpenTelemetry specification.
81 */
82export function getSentryResource(serviceNameFallback: string): SentryResource {
83 const env = typeof process !== 'undefined' ? process.env : {};
84 const otelServiceName = env.OTEL_SERVICE_NAME;
85 const otelResourceAttrs = parseOtelResourceAttributes(env.OTEL_RESOURCE_ATTRIBUTES);
86
87 return new SentryResource({
88 // Lowest priority: Sentry defaults
89 // eslint-disable-next-line typescript/no-deprecated
90 [SEMRESATTRS_SERVICE_NAMESPACE]: 'sentry',
91 [SERVICE_NAME]: serviceNameFallback,
92 // OTEL_RESOURCE_ATTRIBUTES overrides defaults (including service.name and service.namespace)
93 ...otelResourceAttrs,
94 // OTEL_SERVICE_NAME explicitly overrides service.name
95 ...(otelServiceName ? { [SERVICE_NAME]: otelServiceName } : {}),
96 // Highest priority: Sentry SDK telemetry attrs (cannot be overridden by env vars)
97 [SERVICE_VERSION]: SDK_VERSION,
98 [ATTR_TELEMETRY_SDK_LANGUAGE]: SDK_INFO[ATTR_TELEMETRY_SDK_LANGUAGE],
99 [ATTR_TELEMETRY_SDK_NAME]: SDK_INFO[ATTR_TELEMETRY_SDK_NAME],
100 [ATTR_TELEMETRY_SDK_VERSION]: SDK_INFO[ATTR_TELEMETRY_SDK_VERSION],
101 });
102}

Callers 5

setupOtelFunction · 0.90
setupOtelFunction · 0.90
resource.test.tsFile · 0.90
setupOtelFunction · 0.90
setupOtelFunction · 0.90

Calls 1

Tested by

no test coverage detected