import { ConfigurationParameters } from '@datadog/datadog-api-client/dist/packages/datadog-api-client-common/configuration'; import { v2 } from '@datadog/datadog-api-client'; import { HTTPLogItem } from '@datadog/datadog-api-client/dist/packages/datadog-api-client-v2/models/HTTPLogItem'; interface DDTransportOptions { /** * DataDog client configuration parameters. * @see https://datadoghq.dev/datadog-api-client-typescript/interfaces/client.Configuration.html */ ddClientConf: ConfigurationParameters; /** * Datadog server config for the client. Use this to change the Datadog server region. * @see https://github.com/DataDog/datadog-api-client-typescript/blob/1e1097c68a437894b482701ecbe3d61522429319/packages/datadog-api-client-common/servers.ts#L90 */ ddServerConf?: { /** * The datadog server to use. Default is datadoghq.com. * Other values could be: * - us3.datadoghq.com * - us5.datadoghq.com * - datadoghq.eu * - ddog-gov.com */ site?: string; subdomain?: string; protocol?: string; }; /** * The integration name associated with your log: the technology from which * the log originated. When it matches an integration name, Datadog * automatically installs the corresponding parsers and facets. * @see https://docs.datadoghq.com/logs/log_collection/?tab=host#reserved-attributes */ ddsource?: string; /** * Comma separated tags associated with your logs. Ex: "env:prod,org:finance" */ ddtags?: string; /** * The name of the application or service generating the log events. * It is used to switch from Logs to APM, so make sure you define the same * value when you use both products. * @see https://docs.datadoghq.com/logs/log_collection/?tab=host#reserved-attributes */ service?: string; /** * Called when the plugin is ready to process logs. */ onInit?: () => void; /** * Error handler for when the submitLog() call fails. See readme on how to * properly implement this callback. */ onError?: (err: any, logs?: Array>) => void; /** * Define this callback to get debug messages from this transport */ onDebug?: (msg: string) => void; /** * Number of times to retry sending the log before onError() is called. * Default is 5. */ retries?: number; /** * Interval in which logs are sent to Datadog. * Default is 3000 milliseconds. */ sendIntervalMs?: number; /** * Set to true to disable batch sending and send each log as it comes in. This disables * the send interval. */ sendImmediate?: boolean; } interface SendLogOpts { apiInstance: v2.LogsApi; logsToSend: Array; bucketName: string; options: DDTransportOptions; } declare class DataDogTransport { /** * Batch storage for logs */ private logStorage; /** * Timer for sending log batches at specific intervals */ private timer; /** * Datadog Logs API v2 instance * @private */ private apiInstance; /** * Configuration options * @private */ private config; constructor(options: DDTransportOptions); /** * Performs the actual sending of logs to datadog * @private */ private sendLogs; /** * Sets up interval timer for sending logs periodically */ private setupRegularSend; /** * Sets up a hook to send any remaining logs on application exit */ private setupExitHook; /** * Submits log data to be queued or sent to datadog */ processLog(data: Record): void; } /** * Manages storage of log data into buckets. */ declare class LogStorage { /** * Identifier for the current log bucket. * @type {string} */ currentBucket: string; /** * Stores the log data buckets by their identifiers. * @type {Record} * @private */ private logBucket; /** * Initializes the log storage and creates the first log bucket. */ constructor(); /** * Creates a new log bucket, deleting the current one if it exists. * @private */ private newLogBucket; /** * Retrieves the byte size of the current log bucket. * @returns {number} The size of the current log bucket in bytes. */ getLogBucketByteSize(): number; /** * Gets the count of logs in the current log bucket. * @returns {number} The number of log items in the current bucket. */ getLogCount(): number; /** * Finishes the current log batch, returning its logs and creating a new log bucket. * @returns {Array} The log items from the finished log bucket. */ finishLogBatch(): Array; /** * Adds a log item to the current log bucket. * @param {HTTPLogItem} log - The log item to be added. * @param {number} logByteSize - The size of the log item in bytes. */ addLog(log: HTTPLogItem, logByteSize: number): void; } export { type DDTransportOptions, DataDogTransport, LogStorage, type SendLogOpts };