UNPKG

enhanced-adot-node-autoinstrumentation

Version:

This package provides Amazon Web Services distribution of the OpenTelemetry Node Instrumentation, which allows for auto-instrumentation of NodeJS applications.

46 lines 1.86 kB
"use strict"; // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 Object.defineProperty(exports, "__esModule", { value: true }); exports.getAwsRegionFromEnvironment = exports.isAgentObservabilityEnabled = exports.getNodeVersion = void 0; const api_1 = require("@opentelemetry/api"); const AGENT_OBSERVABILITY_ENABLED = 'AGENT_OBSERVABILITY_ENABLED'; const getNodeVersion = () => { const nodeVersion = process.versions.node; const versionParts = nodeVersion.split('.'); if (versionParts.length === 0) { return -1; } const majorVersion = parseInt(versionParts[0], 10); if (isNaN(majorVersion)) { return -1; } return majorVersion; }; exports.getNodeVersion = getNodeVersion; const isAgentObservabilityEnabled = () => { const agentObservabilityEnabled = process.env[AGENT_OBSERVABILITY_ENABLED]; if (agentObservabilityEnabled === undefined) { return false; } return agentObservabilityEnabled.toLowerCase() === 'true'; }; exports.isAgentObservabilityEnabled = isAgentObservabilityEnabled; /** * Get AWS region from environment or boto3 session. * Returns the AWS region in the following priority order: * 1. AWS_REGION environment variable * 2. AWS_DEFAULT_REGION environment variable * 3. undefined if no region can be determined */ const getAwsRegionFromEnvironment = () => { var _a; const region = (_a = process.env.AWS_REGION) !== null && _a !== void 0 ? _a : process.env.AWS_DEFAULT_REGION; if (region) { return region; } api_1.diag.warn('AWS region not found in environment variables (AWS_REGION, AWS_DEFAULT_REGION). Please set AWS_REGION environment variable explicitly.'); return undefined; }; exports.getAwsRegionFromEnvironment = getAwsRegionFromEnvironment; //# sourceMappingURL=utils.js.map