{"version":3,"file":"EnvDetector.cjs","names":["ResourceAttributesEnvDetector","getStringFromEnv","ATTR_SERVICE_NAME"],"sources":["../../src/detectors/EnvDetector.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { Attributes } from '@opentelemetry/api';\nimport { diag } from '@opentelemetry/api';\nimport { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';\nimport type { ResourceDetectionConfig } from '../config';\nimport type { DetectedResource } from '../types';\nimport { getStringFromEnv } from '@opentelemetry/core';\nimport { ResourceAttributesEnvDetector } from './ResourceAttributesEnvDetector';\n\n/**\n * EnvDetector reads attributes from OTEL_RESOURCE_ATTRIBUTES and\n * OTEL_SERVICE_NAME.\n *\n * @deprecated Use {ResourceAttributesEnvDetector} and {ServiceNameEnvDetector}\n */\nclass EnvDetector extends ResourceAttributesEnvDetector {\n  /**\n   * Returns a {@link Resource} populated with attributes from the\n   * OTEL_RESOURCE_ATTRIBUTES environment variable. Note this is an async\n   * function to conform to the Detector interface.\n   *\n   * @param config The resource detection config\n   */\n  override detect(_config?: ResourceDetectionConfig): DetectedResource {\n    const attributes: Attributes = {};\n\n    const rawAttributes = getStringFromEnv('OTEL_RESOURCE_ATTRIBUTES');\n    const serviceName = getStringFromEnv('OTEL_SERVICE_NAME');\n\n    if (rawAttributes) {\n      try {\n        const parsedAttributes = this._parseResourceAttributes(rawAttributes);\n        Object.assign(attributes, parsedAttributes);\n      } catch (e) {\n        diag.debug(`EnvDetector failed: ${e instanceof Error ? e.message : e}`);\n      }\n    }\n\n    if (serviceName) {\n      attributes[ATTR_SERVICE_NAME] = serviceName;\n    }\n\n    return { attributes };\n  }\n}\n\n/**\n * @deprecated Use {resourceAttributesEnvDetector} and {serviceNameEnvDetector}\n */\nexport const envDetector = new EnvDetector();\n"],"mappings":";;;;;;;;;;;AAmBA,IAAM,cAAN,cAA0BA,sCAAAA,8BAA8B;;;;;;;;CAQtD,OAAgB,SAAqD;EACnE,MAAM,aAAyB,CAAC;EAEhC,MAAM,iBAAA,GAAgBC,oBAAAA,iBAAAA,CAAiB,0BAA0B;EACjE,MAAM,eAAA,GAAcA,oBAAAA,iBAAAA,CAAiB,mBAAmB;EAExD,IAAI,eACF,IAAI;GACF,MAAM,mBAAmB,KAAK,yBAAyB,aAAa;GACpE,OAAO,OAAO,YAAY,gBAAgB;EAC5C,SAAS,GAAG;GACV,mBAAA,KAAK,MAAM,uBAAuB,aAAa,QAAQ,EAAE,UAAU,GAAG;EACxE;EAGF,IAAI,aACF,WAAWC,oCAAAA,qBAAqB;EAGlC,OAAO,EAAE,WAAW;CACtB;AACF;;;;AAKA,MAAa,cAAc,IAAI,YAAY"}