MCPcopy Create free account
hub / github.com/Effect-TS/effect / configToAttributes

Function configToAttributes

packages/opentelemetry/src/Resource.ts:81–98  ·  view source on GitHub ↗
(options: {
  readonly serviceName: string
  readonly serviceVersion?: string
  readonly attributes?: OtelApi.Attributes
})

Source from the content-addressed store, hash-verified

79 * @since 4.0.0
80 */
81export 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.

Callers 1

layerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected