UNPKG

@aws/aws-distro-opentelemetry-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.88 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.AWSCloudWatchEMFExporter = void 0; const api_1 = require("@opentelemetry/api"); const cloudwatch_logs_client_1 = require("./cloudwatch-logs-client"); const emf_exporter_base_1 = require("./emf-exporter-base"); /** * OpenTelemetry metrics exporter for CloudWatch EMF format. * * This exporter converts OTel metrics into CloudWatch EMF logs which are then * sent to CloudWatch Logs. CloudWatch Logs automatically extracts the metrics * from the EMF logs. */ class AWSCloudWatchEMFExporter extends emf_exporter_base_1.EMFExporterBase { constructor(namespace = 'default', logGroupName, logStreamName, aggregationTemporalitySelector, aggregationSelector, cloudwatchLogsConfig = {}) { super(namespace, aggregationTemporalitySelector, aggregationSelector); this.logClient = new cloudwatch_logs_client_1.CloudWatchLogsClient(logGroupName, logStreamName, cloudwatchLogsConfig); } /** * Send a log event to CloudWatch Logs using the log client. * * @param logEvent The log event to send * @returns {Promise<void>} */ async sendLogEvent(logEvent) { await this.logClient.sendLogEvent(logEvent); } /** * Force flush any pending metrics. */ async forceFlush() { await this.logClient.flushPendingEvents(); api_1.diag.debug('AWSCloudWatchEMFExporter force flushes the buffered metrics'); } /** * Shutdown the exporter. */ async shutdown() { await this.forceFlush(); api_1.diag.debug('AWSCloudWatchEMFExporter shutdown called'); } } exports.AWSCloudWatchEMFExporter = AWSCloudWatchEMFExporter; //# sourceMappingURL=aws-cloudwatch-emf-exporter.js.map