| 79 | * @since 4.0.0 |
| 80 | */ |
| 81 | export const configToAttributes = (options: { |
| 82 | readonly serviceName: string |
| 83 | readonly serviceVersion?: string |
| 84 | readonly attributes?: OtelApi.Attributes |
| 85 | }): Record<string, string> => { |
| 86 | const attributes: Record<string, string> = { |
| 87 | ...(options.attributes ?? undefined), |
| 88 | [OtelSemConv.ATTR_SERVICE_NAME]: options.serviceName, |
| 89 | [OtelSemConv.ATTR_TELEMETRY_SDK_NAME]: "@effect/opentelemetry", |
| 90 | [OtelSemConv.ATTR_TELEMETRY_SDK_LANGUAGE]: typeof (globalThis as any).document === "undefined" |
| 91 | ? OtelSemConv.TELEMETRY_SDK_LANGUAGE_VALUE_NODEJS |
| 92 | : OtelSemConv.TELEMETRY_SDK_LANGUAGE_VALUE_WEBJS |
| 93 | } |
| 94 | if (options.serviceVersion) { |
| 95 | attributes[OtelSemConv.ATTR_SERVICE_VERSION] = options.serviceVersion |
| 96 | } |
| 97 | return attributes |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * Creates a `Resource` layer from OpenTelemetry environment variables, optionally merging additional attributes. |