UNPKG

@dynatrace/opentelemetry-core

Version:

Dynatrace OpenTelemetry core package

57 lines (54 loc) 2.8 kB
"use strict"; /* Copyright 2022 Dynatrace LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.detectResource = detectResource; const resources_1 = require("@opentelemetry/resources"); const SemConvResource = require("../../gen/dynatrace/odin/semconv/v1/SemConvResource"); const version_1 = require("../version"); /** * Get all resources which are available at agent init time */ function detectResource() { const resourceAttributes = { [SemConvResource.TELEMETRY_EXPORTER_NAME]: "odin", [SemConvResource.TELEMETRY_EXPORTER_VERSION]: version_1.VERSIONS.fullVersion, [SemConvResource.TELEMETRY_EXPORTER_PACKAGE_VERSION]: version_1.VERSIONS.pkgVersion, // Os Semantic conventions (skip DT_OS_DESCRIPTION as nodejs doesn't provide info like lsb_release -a) [SemConvResource.DT_OS_TYPE]: getOsType(), // Runtime [SemConvResource.PROCESS_RUNTIME_NAME]: SemConvResource.ProcessRuntimeNameValues.NODEJS, [SemConvResource.PROCESS_RUNTIME_VERSION]: process.version }; // https://www.dynatrace.com/support/help/how-to-use-dynatrace/process-groups/configuration/define-your-own-process-group-metadata/ if (process.env.DT_CUSTOM_PROP) { resourceAttributes[SemConvResource.DT_ENV_VARS_DT_CUSTOM_PROP] = process.env.DT_CUSTOM_PROP; } // https://www.dynatrace.com/support/help/how-to-use-dynatrace/tags-and-metadata/setup/define-tags-based-on-environment-variables/ if (process.env.DT_TAGS) { resourceAttributes[SemConvResource.DT_ENV_VARS_DT_TAGS] = process.env.DT_TAGS; } return (0, resources_1.defaultResource)().merge((0, resources_1.resourceFromAttributes)(resourceAttributes)); } function getOsType() { // only map types knonw by cluster switch (process.platform) { case "win32": return SemConvResource.DtOsTypeValues.WINDOWS; case "linux": return SemConvResource.DtOsTypeValues.LINUX; case "aix": return SemConvResource.DtOsTypeValues.AIX; case "darwin": return SemConvResource.DtOsTypeValues.DARWIN; case "sunos": return SemConvResource.DtOsTypeValues.SOLARIS; } return SemConvResource.DtOsTypeValues.UNKNOWN; } //# sourceMappingURL=Resource.js.map