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.

187 lines 6.27 kB
/** * OpenTelemetry EMF (Embedded Metric Format) Exporter for CloudWatch. * This exporter converts OTel metrics into CloudWatch EMF format. */ import { Attributes } from '@opentelemetry/api'; import { CloudWatchLogsClientConfig } from '@aws-sdk/client-cloudwatch-logs'; import { Aggregation, AggregationTemporality, InstrumentType, PushMetricExporter, ResourceMetrics } from '@opentelemetry/sdk-metrics'; import { ExportResult } from '@opentelemetry/core'; export declare const CW_MAX_EVENT_PAYLOAD_BYTES: number; export declare const CW_MAX_REQUEST_EVENT_COUNT = 10000; export declare const CW_PER_EVENT_HEADER_BYTES = 26; export declare const BATCH_FLUSH_INTERVAL: number; export declare const CW_MAX_REQUEST_PAYLOAD_BYTES: number; export declare const CW_TRUNCATED_SUFFIX = "[Truncated...]"; export declare const CW_EVENT_TIMESTAMP_LIMIT_PAST: number; export declare const CW_EVENT_TIMESTAMP_LIMIT_FUTURE: number; export declare const RECORD_DATA_TYPES: { SUM_DATA: string; HISTOGRAM_DATA: string; EXP_HISTOGRAM_DATA: string; }; export interface Record { name?: string; timestamp: number; attributes: Attributes; sumData?: RecordData; histogramData?: RecordData; expHistogramData?: RecordData; value?: number; instrument: Instrument; } interface RecordData { type: string; value: RecordValue | number; } export interface RecordValue { Values?: number[]; Counts?: number[]; Count: number; Sum: number; Max: number; Min: number; } interface Instrument { name: string; unit: string; description: string; } export interface EMFLog { 'EC2.AutoScalingGroup'?: string; 'Telemetry.Extended'?: string; Service?: string; Error?: EmfLogError; Host?: string; Fault?: Fault; Operation?: string; Latency?: Latency; 'K8s.Namespace'?: string; _aws: Aws; 'K8s.Node'?: string; 'EC2.InstanceId'?: string; 'Telemetry.SDK'?: string; Environment?: string; 'K8s.WorkLoad'?: string; 'aws.log.group.names'?: string; PlatformType?: string; [key: `resource.${string}`]: string; [metricName: string]: string | EmfLogError | Fault | undefined | Aws | RecordValue | number; Version: string; } export interface EmfLogError { Counts: number[]; Min: number; Max: number; Values: number[]; Sum: number; Count: number; } export interface Fault { Counts: number[]; Min: number; Max: number; Values: number[]; Sum: number; Count: number; } export interface Latency { Counts: number[]; Min: number; Max: number; Values: number[]; Sum: number; Count: number; } export interface Aws { CloudWatchMetrics: CloudWatchMetric[]; Timestamp: number; } export interface CloudWatchMetric { Namespace: string; Dimensions: string[][]; Metrics: Metric[]; } export interface Metric { Name: string; Unit?: string; } export interface LogEvent { message: string; timestamp: number; } export interface EventBatch { logEvents: LogEvent[]; byteTotal: number; minTimestampMs: number; maxTimestampMs: number; createdTimestampMs: number; } /** * 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. */ export declare class CloudWatchEMFExporter implements PushMetricExporter { private namespace; private logGroupName; private logStreamName; private aggregationTemporality; private logsClient; private logGroupExists; private logGroupExistsPromise; private eventBatch; private UNIT_MAPPING; /** * Initialize the CloudWatch EMF exporter. * * @param namespace CloudWatch namespace for metrics * @param logGroupName CloudWatch log group name * @param logStreamName CloudWatch log stream name (auto-generated if None) * @param awsRegion AWS region (auto-detected if None) * @param AggregationTemporality Optional AggregationTemporality to indicate the way additive quantities are expressed * @param cloudwatchLogsConfig Additional arguments passed to boto3 client */ constructor(namespace: string | undefined, logGroupName: string | undefined, logStreamName: string | undefined, awsRegion: string | undefined, aggregationTemporality?: AggregationTemporality, cloudwatchLogsConfig?: CloudWatchLogsClientConfig); private generateLogStreamName; private ensureLogGroupExists; private getMetricName; private getUnit; private getDimensionNames; private getAttributesKey; private normalizeTimestamp; private createMetricRecord; private convertGauge; private convertSum; private convertHistogram; private convertExpHistogram; private groupByAttributesAndTimestamp; private createEmfLog; private pushMetricRecordIntoGroupedMetrics; export(resourceMetrics: ResourceMetrics, resultCallback: (result: ExportResult) => void): Promise<void>; private validateLogEvent; private createEventBatch; private eventBatchExceedsLimit; private isBatchActive; private appendToBatch; private sortLogEvents; private sendLogBatch; private sendLogEvent; forceFlush(timeoutMillis?: number): Promise<void>; shutdown(): Promise<void>; selectAggregationTemporality(instrumentType: InstrumentType): AggregationTemporality; selectAggregation(instrumentType: InstrumentType): Aggregation; } /** * Convenience function to create a CloudWatch EMF exporter with DELTA temporality. * * @param namespace CloudWatch namespace for metrics * @param logGroupName CloudWatch log group name * @param logStreamName CloudWatch log stream name (auto-generated if not provided) * @param awsRegion AWS region (auto-detected if not provided) * @returns {CloudWatchEMFExporter} Configured CloudWatchEMFExporter instance */ export declare function createEmfExporter(namespace?: string, logGroupName?: string, logStreamName?: string, awsRegion?: string, cloudwatchLogsConfig?: CloudWatchLogsClientConfig): CloudWatchEMFExporter; export {}; //# sourceMappingURL=otlp-aws-emf-exporter.d.ts.map