{"version":3,"sources":["jsdelivr-header.js","/npm/rhizo-co-google-cloud-opentelemetry-resource-util@2.2.0/build/src/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,aAcA,OAAO,eAAe,QAAS,aAAc,CAAE,OAAO,IACtD,QAAQ,gBAAkB,QAAQ,YAAc,QAAQ,wCAAqC,EAC7F,MAAM,uBAAyB,QAAQ,uCACjC,YAAc,cACd,iBAAmB,mBACnB,eAAiB,iBACjB,mBAAqB,qBACrB,aAAe,eACf,mBAAqB,qBACrB,eAAiB,iBACjB,cAAgB,gBAChB,aAAe,eACf,cAAgB,YAChB,eAAiB,aACjB,aAAe,eACf,aAAe,eACf,aAAe,eACf,YAAc,cACd,IAAM,MACN,YAAc,cACd,cAAgB,gBAChB,SAAW,WACX,QAAU,UACV,SAAW,WACX,UAAY,YACZ,eAAiB,iBACjB,QAAU,UACV,UAAY,YACZ,SAAW,WACX,OAAS,SACT,cAAgB,gBAChB,aAAe,eACf,QAAU,UACV,KAAO,OACP,uBAAyB,kBAMzB,SAAW,CACb,CAAC,cAAe,CACZ,CAAC,MAAO,CACJ,SAAU,CAAC,uBAAuB,sCAEtC,CAAC,aAAc,CAAE,SAAU,CAAC,uBAAuB,uBAEvD,CAAC,eAAgB,CACb,CAAC,UAAW,CACR,SAAU,CAAC,uBAAuB,oCAAqC,uBAAuB,2BAElG,CAAC,cAAe,CACZ,SAAU,CAAC,uBAAuB,+BAEtC,CAAC,gBAAiB,CACd,SAAU,CAAC,uBAAuB,iCAEtC,CAAC,UAAW,CACR,SAAU,CAAC,uBAAuB,2BAEtC,CAAC,gBAAiB,CACd,SAAU,CAAC,uBAAuB,kCAG1C,CAAC,SAAU,CACP,CAAC,UAAW,CACR,SAAU,CAAC,uBAAuB,oCAAqC,uBAAuB,2BAElG,CAAC,cAAe,CACZ,SAAU,CAAC,uBAAuB,+BAEtC,CAAC,gBAAiB,CACd,SAAU,CAAC,uBAAuB,iCAEtC,CAAC,UAA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AP,OAAgB,EAAS,EAAG,WA/LnH,oBA+LwJ,CACvK,EAAU,EAAc,GACxB,KACJ,MAEY,IAAZ,GACA,EAAU,SAAS,SAAS,uBAAuB,4BAGnD,EAAU,EAAc,uBAAuB,gCAEnC,IAAZ,IACA,EAAwC,QAA7B,EAAK,EAAU,gBAA6B,IAAP,EAAgB,EAAK,IAIlD,iBAAZ,IACP,EAAU,KAAK,UAAU,IAE7B,EAAO,GAAS,CAAO,IAEpB,CACH,KAAM,EACN,SAER,CAlCA,QAAQ,mCAAqC,mCAmC7C,IAAI,WAAa,QAAQ,uBACzB,OAAO,eAAe,QAAS,cAAe,CAAE,YAAY,EAAM,IAAK,WAAc,OAAO,WAAW,WAAa,IACpH,OAAO,eAAe,QAAS,kBAAmB,CAAE,YAAY,EAAM,IAAK,WAAc,OAAO,WAAW,eAAiB","file":"/npm/rhizo-co-google-cloud-opentelemetry-resource-util@2.2.0/build/src/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/rhizo-co-google-cloud-opentelemetry-resource-util@2.2.0/build/src/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\n// Copyright 2021 Google LLC\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//      http://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.\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.GcpDetectorSync = exports.GcpDetector = exports.mapOtelResourceToMonitoredResource = void 0;\nconst semantic_conventions_1 = require(\"@opentelemetry/semantic-conventions\");\nconst AWS_ACCOUNT = 'aws_account';\nconst AWS_EC2_INSTANCE = 'aws_ec2_instance';\nconst CLOUD_FUNCTION = 'cloud_function';\nconst CLOUD_RUN_REVISION = 'cloud_run_revision';\nconst CLUSTER_NAME = 'cluster_name';\nconst CONFIGURATION_NAME = 'configuration_name';\nconst CONTAINER_NAME = 'container_name';\nconst FUNCTION_NAME = 'function_name';\nconst GAE_INSTANCE = 'gae_instance';\nconst GAE_MODULE_ID = 'module_id';\nconst GAE_VERSION_ID = 'version_id';\nconst GCE_INSTANCE = 'gce_instance';\nconst GENERIC_NODE = 'generic_node';\nconst GENERIC_TASK = 'generic_task';\nconst INSTANCE_ID = 'instance_id';\nconst JOB = 'job';\nconst K8S_CLUSTER = 'k8s_cluster';\nconst K8S_CONTAINER = 'k8s_container';\nconst K8S_NODE = 'k8s_node';\nconst K8S_POD = 'k8s_pod';\nconst LOCATION = 'location';\nconst NAMESPACE = 'namespace';\nconst NAMESPACE_NAME = 'namespace_name';\nconst NODE_ID = 'node_id';\nconst NODE_NAME = 'node_name';\nconst POD_NAME = 'pod_name';\nconst REGION = 'region';\nconst REVISION_NAME = 'revision_name';\nconst SERVICE_NAME = 'service_name';\nconst TASK_ID = 'task_id';\nconst ZONE = 'zone';\nconst UNKNOWN_SERVICE_PREFIX = 'unknown_service';\n/**\n * Mappings of GCM resource label keys onto mapping config from OTel resource for a given\n * monitored resource type. Copied from Go impl:\n * https://github.com/GoogleCloudPlatform/opentelemetry-operations-go/blob/v1.8.0/internal/resourcemapping/resourcemapping.go#L51\n */\nconst MAPPINGS = {\n    [GCE_INSTANCE]: {\n        [ZONE]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_CLOUD_AVAILABILITY_ZONE],\n        },\n        [INSTANCE_ID]: { otelKeys: [semantic_conventions_1.SEMRESATTRS_HOST_ID] },\n    },\n    [K8S_CONTAINER]: {\n        [LOCATION]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_CLOUD_AVAILABILITY_ZONE, semantic_conventions_1.SEMRESATTRS_CLOUD_REGION],\n        },\n        [CLUSTER_NAME]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_K8S_CLUSTER_NAME],\n        },\n        [NAMESPACE_NAME]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_K8S_NAMESPACE_NAME],\n        },\n        [POD_NAME]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_K8S_POD_NAME],\n        },\n        [CONTAINER_NAME]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_K8S_CONTAINER_NAME],\n        },\n    },\n    [K8S_POD]: {\n        [LOCATION]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_CLOUD_AVAILABILITY_ZONE, semantic_conventions_1.SEMRESATTRS_CLOUD_REGION],\n        },\n        [CLUSTER_NAME]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_K8S_CLUSTER_NAME],\n        },\n        [NAMESPACE_NAME]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_K8S_NAMESPACE_NAME],\n        },\n        [POD_NAME]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_K8S_POD_NAME],\n        },\n    },\n    [K8S_NODE]: {\n        [LOCATION]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_CLOUD_AVAILABILITY_ZONE, semantic_conventions_1.SEMRESATTRS_CLOUD_REGION],\n        },\n        [CLUSTER_NAME]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_K8S_CLUSTER_NAME],\n        },\n        [NODE_NAME]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_K8S_NODE_NAME],\n        },\n    },\n    [K8S_CLUSTER]: {\n        [LOCATION]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_CLOUD_AVAILABILITY_ZONE, semantic_conventions_1.SEMRESATTRS_CLOUD_REGION],\n        },\n        [CLUSTER_NAME]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_K8S_CLUSTER_NAME],\n        },\n    },\n    [AWS_EC2_INSTANCE]: {\n        [INSTANCE_ID]: { otelKeys: [semantic_conventions_1.SEMRESATTRS_HOST_ID] },\n        [REGION]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_CLOUD_AVAILABILITY_ZONE, semantic_conventions_1.SEMRESATTRS_CLOUD_REGION],\n        },\n        [AWS_ACCOUNT]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_CLOUD_ACCOUNT_ID],\n        },\n    },\n    [CLOUD_RUN_REVISION]: {\n        [LOCATION]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_CLOUD_REGION],\n        },\n        [SERVICE_NAME]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_FAAS_NAME],\n        },\n        [CONFIGURATION_NAME]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_FAAS_NAME],\n        },\n        [REVISION_NAME]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_FAAS_VERSION],\n        },\n    },\n    [CLOUD_FUNCTION]: {\n        [REGION]: { otelKeys: [semantic_conventions_1.SEMRESATTRS_CLOUD_REGION] },\n        [FUNCTION_NAME]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_FAAS_NAME],\n        },\n    },\n    [GAE_INSTANCE]: {\n        [LOCATION]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_CLOUD_AVAILABILITY_ZONE, semantic_conventions_1.SEMRESATTRS_CLOUD_REGION],\n        },\n        [GAE_MODULE_ID]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_FAAS_NAME],\n        },\n        [GAE_VERSION_ID]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_FAAS_VERSION],\n        },\n        [INSTANCE_ID]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_FAAS_INSTANCE],\n        },\n    },\n    [GENERIC_TASK]: {\n        [LOCATION]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_CLOUD_AVAILABILITY_ZONE, semantic_conventions_1.SEMRESATTRS_CLOUD_REGION],\n            fallback: 'global',\n        },\n        [NAMESPACE]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_SERVICE_NAMESPACE],\n        },\n        [JOB]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_SERVICE_NAME, semantic_conventions_1.SEMRESATTRS_FAAS_NAME],\n        },\n        [TASK_ID]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_SERVICE_INSTANCE_ID, semantic_conventions_1.SEMRESATTRS_FAAS_INSTANCE],\n        },\n    },\n    [GENERIC_NODE]: {\n        [LOCATION]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_CLOUD_AVAILABILITY_ZONE, semantic_conventions_1.SEMRESATTRS_CLOUD_REGION],\n            fallback: 'global',\n        },\n        [NAMESPACE]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_SERVICE_NAMESPACE],\n        },\n        [NODE_ID]: {\n            otelKeys: [semantic_conventions_1.SEMRESATTRS_HOST_ID, semantic_conventions_1.SEMRESATTRS_HOST_NAME],\n        },\n    },\n};\nfunction mapOtelResourceToMonitoredResource(resource, includeUnsupportedResources = false) {\n    const attrs = resource.attributes;\n    const platform = attrs[semantic_conventions_1.SEMRESATTRS_CLOUD_PLATFORM];\n    let mr;\n    if (platform === semantic_conventions_1.CLOUDPLATFORMVALUES_GCP_COMPUTE_ENGINE) {\n        mr = createMonitoredResource(GCE_INSTANCE, attrs);\n    }\n    else if (platform === semantic_conventions_1.CLOUDPLATFORMVALUES_GCP_APP_ENGINE) {\n        mr = createMonitoredResource(GAE_INSTANCE, attrs);\n    }\n    else if (platform === semantic_conventions_1.CLOUDPLATFORMVALUES_AWS_EC2) {\n        mr = createMonitoredResource(AWS_EC2_INSTANCE, attrs);\n    }\n    else if (platform === semantic_conventions_1.CLOUDPLATFORMVALUES_GCP_CLOUD_RUN) {\n        mr = createMonitoredResource(CLOUD_RUN_REVISION, attrs);\n    }\n    else if (includeUnsupportedResources &&\n        platform === semantic_conventions_1.CLOUDPLATFORMVALUES_GCP_CLOUD_FUNCTIONS) {\n        mr = createMonitoredResource(CLOUD_FUNCTION, attrs);\n    }\n    else if (semantic_conventions_1.SEMRESATTRS_K8S_CLUSTER_NAME in attrs) {\n        // if k8s.cluster.name is set, pattern match for various k8s resources.\n        // this will also match non-cloud k8s platforms like minikube.\n        if (semantic_conventions_1.SEMRESATTRS_K8S_CONTAINER_NAME in attrs) {\n            mr = createMonitoredResource(K8S_CONTAINER, attrs);\n        }\n        else if (semantic_conventions_1.SEMRESATTRS_K8S_POD_NAME in attrs) {\n            mr = createMonitoredResource(K8S_POD, attrs);\n        }\n        else if (semantic_conventions_1.SEMRESATTRS_K8S_NODE_NAME in attrs) {\n            mr = createMonitoredResource(K8S_NODE, attrs);\n        }\n        else {\n            mr = createMonitoredResource(K8S_CLUSTER, attrs);\n        }\n    }\n    else if ((semantic_conventions_1.SEMRESATTRS_SERVICE_NAME in attrs || semantic_conventions_1.SEMRESATTRS_FAAS_NAME in attrs) &&\n        (semantic_conventions_1.SEMRESATTRS_SERVICE_INSTANCE_ID in attrs ||\n            semantic_conventions_1.SEMRESATTRS_FAAS_INSTANCE in attrs)) {\n        // fallback to generic_task\n        mr = createMonitoredResource(GENERIC_TASK, attrs);\n    }\n    else {\n        // If not possible, finally fallback to generic_node\n        mr = createMonitoredResource(GENERIC_NODE, attrs);\n    }\n    return mr;\n}\nexports.mapOtelResourceToMonitoredResource = mapOtelResourceToMonitoredResource;\nfunction createMonitoredResource(monitoredResourceType, resourceAttrs) {\n    const mapping = MAPPINGS[monitoredResourceType];\n    const labels = {};\n    Object.entries(mapping).map(([mrKey, mapConfig]) => {\n        var _a, _b, _c;\n        let mrValue;\n        for (const otelKey of mapConfig.otelKeys) {\n            if (otelKey in resourceAttrs &&\n                !((_b = (_a = resourceAttrs[otelKey]) === null || _a === void 0 ? void 0 : _a.toString()) === null || _b === void 0 ? void 0 : _b.startsWith(UNKNOWN_SERVICE_PREFIX))) {\n                mrValue = resourceAttrs[otelKey];\n                break;\n            }\n        }\n        if (mrValue === undefined &&\n            mapConfig.otelKeys.includes(semantic_conventions_1.SEMRESATTRS_SERVICE_NAME)) {\n            // The service name started with unknown_service, was ignored above, and we couldn't find\n            // a better value for mrValue.\n            mrValue = resourceAttrs[semantic_conventions_1.SEMRESATTRS_SERVICE_NAME];\n        }\n        if (mrValue === undefined) {\n            mrValue = (_c = mapConfig.fallback) !== null && _c !== void 0 ? _c : '';\n        }\n        // OTel attribute values can be any of string, boolean, number, or array of any of them.\n        // Encode any non-strings as json string\n        if (typeof mrValue !== 'string') {\n            mrValue = JSON.stringify(mrValue);\n        }\n        labels[mrKey] = mrValue;\n    });\n    return {\n        type: monitoredResourceType,\n        labels,\n    };\n}\nvar detector_1 = require(\"./detector/detector\");\nObject.defineProperty(exports, \"GcpDetector\", { enumerable: true, get: function () { return detector_1.GcpDetector; } });\nObject.defineProperty(exports, \"GcpDetectorSync\", { enumerable: true, get: function () { return detector_1.GcpDetectorSync; } });\n"]}