@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.
105 lines • 3.28 kB
TypeScript
import type { CloudWatchLogsClientConfig, LogEvent } from '@aws-sdk/client-cloudwatch-logs';
/**
* Container for a batch of CloudWatch log events with metadata.
*/
export declare class LogEventBatch {
logEvents: Required<LogEvent>[];
byteTotal: number;
minTimestampMs: number;
maxTimestampMs: number;
createdTimestampMs: number;
constructor();
/**
* Add a log event to the batch.
*
* @param logEvent The log event to add
* @param eventSize The byte size of the event
*/
addEvent(logEvent: Required<LogEvent>, eventSize: number): void;
/**
* Check if the batch is empty.
*
* @returns {boolean}
*/
isEmpty(): boolean;
/**
* Get the number of events in the batch
*
* @returns {number}
*/
size(): number;
clear(): void;
}
/**
* CloudWatch Logs client for batching and sending log events.
*/
export declare class CloudWatchLogsClient {
static readonly CW_MAX_EVENT_PAYLOAD_BYTES: number;
static readonly CW_MAX_REQUEST_EVENT_COUNT: number;
static readonly CW_PER_EVENT_HEADER_BYTES: number;
static readonly BATCH_FLUSH_INTERVAL: number;
static readonly CW_MAX_REQUEST_PAYLOAD_BYTES: number;
static readonly CW_TRUNCATED_SUFFIX: string;
static readonly CW_EVENT_TIMESTAMP_LIMIT_PAST: number;
static readonly CW_EVENT_TIMESTAMP_LIMIT_FUTURE: number;
private logGroupName;
private logStreamName;
private logsClient;
private eventBatch?;
constructor(logGroupName: string, logStreamName?: string, cloudwatchLogsConfig?: CloudWatchLogsClientConfig);
/**
* Generate a unique log stream name.
*
* @returns {string}
*/
private generateLogStreamName;
/**
* Ensure the log group exists, create if it doesn't.
*/
private ensureLogGroupExists;
/**
* Ensure the log stream exists, create if it doesn't.
*/
private ensureLogStreamExists;
/**
* Validate the log event according to CloudWatch Logs constraints.
*/
private validateLogEvent;
/**
* Create a new log event batch.
*/
private createEventBatch;
/**
* Check if adding the next event would exceed CloudWatch Logs limits.
*/
private eventBatchExceedsLimit;
/**
* Check if the event batch spans more than 24 hours.
*
* @param batch The event batch
* @param targetTimestampMs The timestamp of the event to add
* @returns {boolean} true if the batch is active and can accept the event
*/
private isBatchActive;
/**
* Sort log events in the batch by timestamp.
*/
private sortLogEvents;
/**
* Send a batch of log events to CloudWatch Logs.
*/
private sendLogBatch;
/**
* Send a log event to CloudWatch Logs.
*
* This function implements the same logic as the Go version in the OTel Collector.
* It batches log events according to CloudWatch Logs constraints and sends them
* when the batch is full or spans more than 24 hours.
*/
sendLogEvent(logEvent: Required<LogEvent>): Promise<void>;
/**
* Force flush any pending log events.
*/
flushPendingEvents(): Promise<void>;
}
//# sourceMappingURL=cloudwatch-logs-client.d.ts.map