(serviceNameFallback: string)
| 80 | * per the OpenTelemetry specification. |
| 81 | */ |
| 82 | export 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 | } |
no test coverage detected