Files
klz-cables.com/.pnpm-store/v10/files/0a/063de13e4af091c6512eb19ab2186fe2b091d4af94c83e62056e34d11d3dbcd05767b2a3c5734d009d1baa597ee038b92fd298835a115e26bf1aeffe3b8063
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

1 line
8.0 KiB
Plaintext

{"version":3,"file":"EnvDetector.js","sourceRoot":"","sources":["../../../src/detectors/EnvDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAc,IAAI,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAGxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;GAGG;AACH,MAAM,WAAW;IACf,+EAA+E;IAC9D,WAAW,GAAG,GAAG,CAAC;IAEnC,oEAAoE;IACnD,gBAAgB,GAAG,GAAG,CAAC;IAExC,qEAAqE;IACpD,yBAAyB,GAAG,GAAG,CAAC;IAEhC,4BAA4B,GAC3C,uEAAuE;QACvE,IAAI,CAAC,WAAW;QAChB,cAAc,CAAC;IAEA,4BAA4B,GAC3C,oDAAoD;QACpD,IAAI,CAAC,WAAW;QAChB,cAAc,CAAC;IAEjB;;;;;;OAMG;IACH,MAAM,CAAC,OAAiC;QACtC,MAAM,UAAU,GAAe,EAAE,CAAC;QAElC,MAAM,aAAa,GAAG,gBAAgB,CAAC,0BAA0B,CAAC,CAAC;QACnE,MAAM,WAAW,GAAG,gBAAgB,CAAC,mBAAmB,CAAC,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C,CAAC;aACvE;YACD,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;gBACzB,MAAM,IAAI,KAAK,CAAC,mBAAmB,IAAI,CAAC,4BAA4B,EAAE,CAAC,CAAC;aACzE;YACD,UAAU,CAAC,GAAG,CAAC,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;SAC7C;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;IAED;;;;;;OAMG;IACK,QAAQ,CAAC,IAAY;QAC3B,OAAO,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAC7E,CAAC;IAED,4CAA4C;IACpC,qBAAqB,CAAC,GAAW;QACvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACnC,MAAM,EAAE,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YAC7B,IAAI,EAAE,GAAG,IAAI,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,GAAG,IAAI,EAAE;gBACvE,OAAO,KAAK,CAAC;aACd;SACF;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACK,mBAAmB,CAAC,GAAW;QACrC,OAAO,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC9C,CAAC;CACF;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Attributes, diag } from '@opentelemetry/api';\nimport { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';\nimport { ResourceDetectionConfig } from '../config';\nimport { DetectedResource, ResourceDetector } from '../types';\nimport { getStringFromEnv } from '@opentelemetry/core';\n\n/**\n * EnvDetector can be used to detect the presence of and create a Resource\n * from the OTEL_RESOURCE_ATTRIBUTES environment variable.\n */\nclass EnvDetector implements ResourceDetector {\n // Type, attribute keys, and attribute values should not exceed 256 characters.\n private readonly _MAX_LENGTH = 255;\n\n // OTEL_RESOURCE_ATTRIBUTES is a comma-separated list of attributes.\n private readonly _COMMA_SEPARATOR = ',';\n\n // OTEL_RESOURCE_ATTRIBUTES contains key value pair separated by '='.\n private readonly _LABEL_KEY_VALUE_SPLITTER = '=';\n\n private readonly _ERROR_MESSAGE_INVALID_CHARS =\n 'should be a ASCII string with a length greater than 0 and not exceed ' +\n this._MAX_LENGTH +\n ' characters.';\n\n private readonly _ERROR_MESSAGE_INVALID_VALUE =\n 'should be a ASCII string with a length not exceed ' +\n this._MAX_LENGTH +\n ' characters.';\n\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 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.message}`);\n }\n }\n\n if (serviceName) {\n attributes[ATTR_SERVICE_NAME] = serviceName;\n }\n\n return { attributes };\n }\n\n /**\n * Creates an attribute map from the OTEL_RESOURCE_ATTRIBUTES environment\n * variable.\n *\n * OTEL_RESOURCE_ATTRIBUTES: A comma-separated list of attributes describing\n * the source in more detail, e.g. “key1=val1,key2=val2”. Domain names and\n * paths are accepted as attribute keys. Values may be quoted or unquoted in\n * general. If a value contains whitespace, =, or \" characters, it must\n * always be quoted.\n *\n * @param rawEnvAttributes The resource attributes as a comma-separated list\n * of key/value pairs.\n * @returns The sanitized resource attributes.\n */\n private _parseResourceAttributes(rawEnvAttributes?: string): Attributes {\n if (!rawEnvAttributes) return {};\n\n const attributes: Attributes = {};\n const rawAttributes: string[] = rawEnvAttributes.split(\n this._COMMA_SEPARATOR,\n -1\n );\n for (const rawAttribute of rawAttributes) {\n const keyValuePair: string[] = rawAttribute.split(\n this._LABEL_KEY_VALUE_SPLITTER,\n -1\n );\n if (keyValuePair.length !== 2) {\n continue;\n }\n let [key, value] = keyValuePair;\n // Leading and trailing whitespaces are trimmed.\n key = key.trim();\n value = value.trim().split(/^\"|\"$/).join('');\n if (!this._isValidAndNotEmpty(key)) {\n throw new Error(`Attribute key ${this._ERROR_MESSAGE_INVALID_CHARS}`);\n }\n if (!this._isValid(value)) {\n throw new Error(`Attribute value ${this._ERROR_MESSAGE_INVALID_VALUE}`);\n }\n attributes[key] = decodeURIComponent(value);\n }\n return attributes;\n }\n\n /**\n * Determines whether the given String is a valid printable ASCII string with\n * a length not exceed _MAX_LENGTH characters.\n *\n * @param str The String to be validated.\n * @returns Whether the String is valid.\n */\n private _isValid(name: string): boolean {\n return name.length <= this._MAX_LENGTH && this._isBaggageOctetString(name);\n }\n\n // https://www.w3.org/TR/baggage/#definition\n private _isBaggageOctetString(str: string): boolean {\n for (let i = 0; i < str.length; i++) {\n const ch = str.charCodeAt(i);\n if (ch < 0x21 || ch === 0x2c || ch === 0x3b || ch === 0x5c || ch > 0x7e) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Determines whether the given String is a valid printable ASCII string with\n * a length greater than 0 and not exceed _MAX_LENGTH characters.\n *\n * @param str The String to be validated.\n * @returns Whether the String is valid and not empty.\n */\n private _isValidAndNotEmpty(str: string): boolean {\n return str.length > 0 && this._isValid(str);\n }\n}\n\nexport const envDetector = new EnvDetector();\n"]}