{"version":3,"sources":["../src/DataDogTransport.ts","../src/vendor/p-retry/index.js","../src/vendor/is-network-error/index.js","../src/vendor/exit-hook/index.js","../src/LogStorage.ts"],"sourcesContent":["import type { HTTPLogItem } from \"@datadog/datadog-api-client/dist/packages/datadog-api-client-v2/models/HTTPLogItem\";\nimport type { LogsApiSubmitLogRequest } from \"@datadog/datadog-api-client/dist/packages/datadog-api-client-v2/apis/LogsApi\";\nimport { client, v2 } from \"@datadog/datadog-api-client\";\nimport pRetry from \"./vendor/p-retry\";\nimport exitHook from \"./vendor/exit-hook\";\nimport { LogStorage } from \"./LogStorage\";\nimport type { DDTransportOptions, SendLogOpts } from \"./types\";\n\n// Define constants for various limits and intervals\nconst LOGS_PAYLOAD_SIZE_LIMIT = 5138022;\nconst LOG_SIZE_LIMIT = 996147;\nconst FORCE_SEND_MS = 3000;\nconst MAX_LOG_ITEMS = 995;\n\nexport class DataDogTransport {\n  /**\n   * Batch storage for logs\n   */\n  private logStorage: LogStorage;\n  /**\n   * Timer for sending log batches at specific intervals\n   */\n  private timer: ReturnType<typeof setInterval> | null = null;\n\n  /**\n   * Datadog Logs API v2 instance\n   * @private\n   */\n  private apiInstance: v2.LogsApi;\n\n  /**\n   * Configuration options\n   * @private\n   */\n  private config: DDTransportOptions;\n\n  constructor(options: DDTransportOptions) {\n    this.logStorage = new LogStorage();\n    this.config = options;\n\n    if (options.onInit) {\n      options.onInit();\n    }\n\n    const configuration = client.createConfiguration(options.ddClientConf);\n\n    configuration.setServerVariables(options?.ddServerConf || {});\n    this.apiInstance = new v2.LogsApi(configuration);\n\n    this.setupRegularSend();\n    this.setupExitHook();\n  }\n\n  /**\n   * Performs the actual sending of logs to datadog\n   * @private\n   */\n  private sendLogs({ logsToSend, bucketName }: Omit<SendLogOpts, \"apiInstance\" | \"options\">) {\n    pRetry(\n      async () => {\n        const params: LogsApiSubmitLogRequest = {\n          body: logsToSend, // Logs to send\n          contentEncoding: \"gzip\", // Encoding type\n        };\n\n        // Attempt to send logs via API\n        const result = await this.apiInstance.submitLog(params);\n        if (this.config.onDebug) {\n          this.config.onDebug(`(${bucketName}) Sending ${logsToSend.length} logs to Datadog completed`);\n        }\n\n        return result;\n      },\n      { retries: this.config.retries ?? 5 },\n    ).catch((err) => {\n      if (this.config.onError) {\n        this.config.onError(err, logsToSend);\n      }\n    });\n  }\n\n  /**\n   * Sets up interval timer for sending logs periodically\n   */\n  private setupRegularSend() {\n    if (!this.config.sendImmediate) {\n      if (this.config.onDebug) {\n        this.config.onDebug(`Configured to send logs every ${this.config.sendIntervalMs || FORCE_SEND_MS}ms`);\n      }\n\n      this.timer = setInterval(() => {\n        const logCount = this.logStorage.getLogCount();\n        const currentBucket = this.logStorage.currentBucket;\n\n        if (logCount > 0) {\n          if (this.config.onDebug) {\n            this.config.onDebug(`(${currentBucket}) Sending ${logCount} logs to Datadog on timer`);\n          }\n\n          this.sendLogs({\n            logsToSend: this.logStorage.finishLogBatch(),\n            bucketName: currentBucket,\n          });\n        }\n      }, this.config.sendIntervalMs || FORCE_SEND_MS);\n    }\n  }\n\n  /**\n   * Sets up a hook to send any remaining logs on application exit\n   */\n  private setupExitHook() {\n    if (!this.config.sendImmediate) {\n      if (this.config.onDebug) {\n        this.config.onDebug(\"Configuring exit hook\");\n      }\n\n      exitHook(() => {\n        if (this.logStorage.getLogCount() > 0) {\n          if (this.config.onDebug) {\n            this.config.onDebug(\"Shutdown detected. Attempting to send remaining logs to Datadog\");\n          }\n          if (this.timer) {\n            clearInterval(this.timer);\n          }\n\n          const currentBucket = this.logStorage.currentBucket;\n\n          this.sendLogs({\n            logsToSend: this.logStorage.finishLogBatch(),\n            bucketName: currentBucket,\n          });\n        }\n      });\n    }\n  }\n\n  /**\n   * Submits log data to be queued or sent to datadog\n   */\n  processLog(data: Record<string, any>) {\n    const logItem: HTTPLogItem = {\n      message: JSON.stringify(data),\n    };\n\n    if (this.config.ddsource) {\n      logItem.ddsource = this.config.ddsource;\n    }\n\n    if (this.config.ddtags) {\n      logItem.ddtags = this.config.ddtags;\n    }\n\n    if (this.config.service) {\n      logItem.service = this.config.service;\n    }\n\n    const logEntryLength =\n      logItem.message.length +\n      (logItem.ddsource?.length || 0) +\n      (logItem.ddtags?.length || 0) +\n      (logItem.hostname?.length || 0) +\n      (logItem.service?.length || 0);\n\n    if (logEntryLength > LOG_SIZE_LIMIT) {\n      if (this.config.onError) {\n        this.config.onError(new Error(`Log entry exceeds size limit of ${LOG_SIZE_LIMIT} bytes: ${logEntryLength}`), [\n          logItem,\n        ]);\n      }\n    }\n\n    // If the logs are to be sent right away\n    if (this.config.sendImmediate) {\n      if (this.config.onDebug) {\n        this.config.onDebug(\"(send-immediate) Sending log to Datadog\");\n      }\n\n      this.sendLogs({\n        logsToSend: [logItem],\n        bucketName: \"send-immediate\",\n      });\n\n      return;\n    }\n\n    // Logs are not to be sent right away, queue them\n    this.logStorage.addLog(logItem, logEntryLength);\n\n    // Check if logs should be sent based on size or count\n    const logCount = this.logStorage.getLogCount();\n    const shouldSend = this.logStorage.getLogBucketByteSize() > LOGS_PAYLOAD_SIZE_LIMIT || logCount > MAX_LOG_ITEMS;\n\n    if (shouldSend) {\n      const currentBucket = this.logStorage.currentBucket;\n\n      if (this.config.onDebug) {\n        this.config.onDebug(`(${currentBucket}) Sending ${logCount} logs to Datadog`);\n      }\n\n      this.sendLogs({\n        logsToSend: this.logStorage.finishLogBatch(),\n        bucketName: currentBucket,\n      });\n    }\n  }\n}\n","import retry from 'retry';\nimport isNetworkError from '../is-network-error';\n\nexport class AbortError extends Error {\n\tconstructor(message) {\n\t\tsuper();\n\n\t\tif (message instanceof Error) {\n\t\t\tthis.originalError = message;\n\t\t\t({message} = message);\n\t\t} else {\n\t\t\tthis.originalError = new Error(message);\n\t\t\tthis.originalError.stack = this.stack;\n\t\t}\n\n\t\tthis.name = 'AbortError';\n\t\tthis.message = message;\n\t}\n}\n\nconst decorateErrorWithCounts = (error, attemptNumber, options) => {\n\t// Minus 1 from attemptNumber because the first attempt does not count as a retry\n\tconst retriesLeft = options.retries - (attemptNumber - 1);\n\n\terror.attemptNumber = attemptNumber;\n\terror.retriesLeft = retriesLeft;\n\treturn error;\n};\n\nexport default async function pRetry(input, options) {\n\treturn new Promise((resolve, reject) => {\n\t\toptions = {\n\t\t\tonFailedAttempt() {},\n\t\t\tretries: 10,\n\t\t\tshouldRetry: () => true,\n\t\t\t...options,\n\t\t};\n\n\t\tconst operation = retry.operation(options);\n\n\t\tconst abortHandler = () => {\n\t\t\toperation.stop();\n\t\t\treject(options.signal?.reason);\n\t\t};\n\n\t\tif (options.signal && !options.signal.aborted) {\n\t\t\toptions.signal.addEventListener('abort', abortHandler, {once: true});\n\t\t}\n\n\t\tconst cleanUp = () => {\n\t\t\toptions.signal?.removeEventListener('abort', abortHandler);\n\t\t\toperation.stop();\n\t\t};\n\n\t\toperation.attempt(async attemptNumber => {\n\t\t\ttry {\n\t\t\t\tconst result = await input(attemptNumber);\n\t\t\t\tcleanUp();\n\t\t\t\tresolve(result);\n\t\t\t} catch (error) {\n\t\t\t\ttry {\n\t\t\t\t\tif (!(error instanceof Error)) {\n\t\t\t\t\t\tthrow new TypeError(`Non-error was thrown: \"${error}\". You should only throw errors.`);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (error instanceof AbortError) {\n\t\t\t\t\t\tthrow error.originalError;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (error instanceof TypeError && !isNetworkError(error)) {\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\n\t\t\t\t\tdecorateErrorWithCounts(error, attemptNumber, options);\n\n\t\t\t\t\tif (!(await options.shouldRetry(error))) {\n\t\t\t\t\t\toperation.stop();\n\t\t\t\t\t\treject(error);\n\t\t\t\t\t}\n\n\t\t\t\t\tawait options.onFailedAttempt(error);\n\n\t\t\t\t\tif (!operation.retry(error)) {\n\t\t\t\t\t\tthrow operation.mainError();\n\t\t\t\t\t}\n\t\t\t\t} catch (finalError) {\n\t\t\t\t\tdecorateErrorWithCounts(finalError, attemptNumber, options);\n\t\t\t\t\tcleanUp();\n\t\t\t\t\treject(finalError);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t});\n}\n","const objectToString = Object.prototype.toString;\n\nconst isError = value => objectToString.call(value) === '[object Error]';\n\nconst errorMessages = new Set([\n\t'network error', // Chrome\n\t'Failed to fetch', // Chrome\n\t'NetworkError when attempting to fetch resource.', // Firefox\n\t'The Internet connection appears to be offline.', // Safari 16\n\t'Load failed', // Safari 17+\n\t'Network request failed', // `cross-fetch`\n\t'fetch failed', // Undici (Node.js)\n\t'terminated', // Undici (Node.js)\n]);\n\nexport default function isNetworkError(error) {\n\tconst isValid = error\n\t\t&& isError(error)\n\t\t&& error.name === 'TypeError'\n\t\t&& typeof error.message === 'string';\n\n\tif (!isValid) {\n\t\treturn false;\n\t}\n\n\t// We do an extra check for Safari 17+ as it has a very generic error message.\n\t// Network errors in Safari have no stack.\n\tif (error.message === 'Load failed') {\n\t\treturn error.stack === undefined;\n\t}\n\n\treturn errorMessages.has(error.message);\n}\n","import process from 'node:process';\n\nconst asyncCallbacks = new Set();\nconst callbacks = new Set();\n\nlet isCalled = false;\nlet isRegistered = false;\n\nasync function exit(shouldManuallyExit, isSynchronous, signal) {\n\tif (isCalled) {\n\t\treturn;\n\t}\n\n\tisCalled = true;\n\n\tif (asyncCallbacks.size > 0 && isSynchronous) {\n\t\tconsole.error([\n\t\t\t'SYNCHRONOUS TERMINATION NOTICE:',\n\t\t\t'When explicitly exiting the process via process.exit or via a parent process,',\n\t\t\t'asynchronous tasks in your exitHooks will not run. Either remove these tasks,',\n\t\t\t'use gracefulExit() instead of process.exit(), or ensure your parent process',\n\t\t\t'sends a SIGINT to the process running this code.',\n\t\t].join(' '));\n\t}\n\n\tconst exitCode = 128 + signal;\n\n\tconst done = (force = false) => {\n\t\tif (force === true || shouldManuallyExit === true) {\n\t\t\tprocess.exit(exitCode); // eslint-disable-line unicorn/no-process-exit\n\t\t}\n\t};\n\n\tfor (const callback of callbacks) {\n\t\tcallback(exitCode);\n\t}\n\n\tif (isSynchronous) {\n\t\tdone();\n\t\treturn;\n\t}\n\n\tconst promises = [];\n\tlet forceAfter = 0;\n\tfor (const [callback, wait] of asyncCallbacks) {\n\t\tforceAfter = Math.max(forceAfter, wait);\n\t\tpromises.push(Promise.resolve(callback(exitCode)));\n\t}\n\n\t// Force exit if we exceeded our wait value\n\tconst asyncTimer = setTimeout(() => {\n\t\tdone(true);\n\t}, forceAfter);\n\n\tawait Promise.all(promises);\n\tclearTimeout(asyncTimer);\n\tdone();\n}\n\nfunction addHook(options) {\n\tconst {onExit, wait, isSynchronous} = options;\n\tconst asyncCallbackConfig = [onExit, wait];\n\n\tif (isSynchronous) {\n\t\tcallbacks.add(onExit);\n\t} else {\n\t\tasyncCallbacks.add(asyncCallbackConfig);\n\t}\n\n\tif (!isRegistered) {\n\t\tisRegistered = true;\n\n\t\t// Exit cases that support asynchronous handling\n\t\tprocess.once('beforeExit', exit.bind(undefined, true, false, -128));\n\t\tprocess.once('SIGINT', exit.bind(undefined, true, false, 2));\n\t\tprocess.once('SIGTERM', exit.bind(undefined, true, false, 15));\n\n\t\t// Explicit exit events. Calling will force an immediate exit and run all\n\t\t// synchronous hooks. Explicit exits must not extend the node process\n\t\t// artificially. Will log errors if asynchronous calls exist.\n\t\tprocess.once('exit', exit.bind(undefined, false, true, 0));\n\n\t\t// PM2 Cluster shutdown message. Caught to support async handlers with pm2,\n\t\t// needed because explicitly calling process.exit() doesn't trigger the\n\t\t// beforeExit event, and the exit event cannot support async handlers,\n\t\t// since the event loop is never called after it.\n\t\tprocess.on('message', message => {\n\t\t\tif (message === 'shutdown') {\n\t\t\t\texit(true, true, -128);\n\t\t\t}\n\t\t});\n\t}\n\n\treturn () => {\n\t\tif (isSynchronous) {\n\t\t\tcallbacks.delete(onExit);\n\t\t} else {\n\t\t\tasyncCallbacks.delete(asyncCallbackConfig);\n\t\t}\n\t};\n}\n\nexport default function exitHook(onExit) {\n\tif (typeof onExit !== 'function') {\n\t\tthrow new TypeError('onExit must be a function');\n\t}\n\n\treturn addHook({\n\t\tonExit,\n\t\tisSynchronous: true,\n\t});\n}\n\nexport function asyncExitHook(onExit, options = {}) {\n\tif (typeof onExit !== 'function') {\n\t\tthrow new TypeError('onExit must be a function');\n\t}\n\n\tif (!(typeof options.wait === 'number' && options.wait > 0)) {\n\t\tthrow new TypeError('wait must be set to a positive numeric value');\n\t}\n\n\treturn addHook({\n\t\tonExit,\n\t\twait: options.wait,\n\t\tisSynchronous: false,\n\t});\n}\n\nexport function gracefulExit(signal = 0) {\n\texit(true, false, -128 + signal);\n}\n","import type { HTTPLogItem } from \"@datadog/datadog-api-client/dist/packages/datadog-api-client-v2/models/HTTPLogItem\";\n\nfunction generateCurrentPointer() {\n  return `${Date.now()}_${Math.floor(Math.random() * 1000)}`;\n}\n\ninterface LogBucketData {\n  /**\n   * Size of the items in bytes\n   */\n  size: number;\n  logItems: Array<HTTPLogItem>;\n}\n\n/**\n * Manages storage of log data into buckets.\n */\nexport class LogStorage {\n  /**\n   * Identifier for the current log bucket.\n   * @type {string}\n   */\n  // @ts-ignore\n  currentBucket: string;\n\n  /**\n   * Stores the log data buckets by their identifiers.\n   * @type {Record<string, LogBucketData>}\n   * @private\n   */\n  private logBucket: Record<string, LogBucketData>;\n\n  /**\n   * Initializes the log storage and creates the first log bucket.\n   */\n  constructor() {\n    this.logBucket = {};\n    this.newLogBucket();\n  }\n\n  /**\n   * Creates a new log bucket, deleting the current one if it exists.\n   * @private\n   */\n  private newLogBucket() {\n    if (this.currentBucket) {\n      delete this.logBucket[this.currentBucket];\n    }\n\n    this.currentBucket = generateCurrentPointer();\n    this.logBucket[this.currentBucket] = {\n      size: 0,\n      logItems: [],\n    };\n  }\n\n  /**\n   * Retrieves the byte size of the current log bucket.\n   * @returns {number} The size of the current log bucket in bytes.\n   */\n  getLogBucketByteSize(): number {\n    return this.logBucket[this.currentBucket].size;\n  }\n\n  /**\n   * Gets the count of logs in the current log bucket.\n   * @returns {number} The number of log items in the current bucket.\n   */\n  getLogCount(): number {\n    return this.logBucket[this.currentBucket].logItems.length;\n  }\n\n  /**\n   * Finishes the current log batch, returning its logs and creating a new log bucket.\n   * @returns {Array<HTTPLogItem>} The log items from the finished log bucket.\n   */\n  finishLogBatch(): Array<HTTPLogItem> {\n    const logs = this.logBucket[this.currentBucket].logItems;\n\n    this.newLogBucket();\n\n    return logs;\n  }\n\n  /**\n   * Adds a log item to the current log bucket.\n   * @param {HTTPLogItem} log - The log item to be added.\n   * @param {number} logByteSize - The size of the log item in bytes.\n   */\n  addLog(log: HTTPLogItem, logByteSize: number) {\n    this.logBucket[this.currentBucket].size += logByteSize;\n    this.logBucket[this.currentBucket].logItems.push(log);\n  }\n}\n"],"mappings":";AAEA,SAAS,QAAQ,UAAU;;;ACF3B,OAAO,WAAW;;;ACAlB,IAAM,iBAAiB,OAAO,UAAU;AAExC,IAAM,UAAU,WAAS,eAAe,KAAK,KAAK,MAAM;AAExD,IAAM,gBAAgB,oBAAI,IAAI;AAAA,EAC7B;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AACD,CAAC;AAEc,SAAR,eAAgC,OAAO;AAC7C,QAAM,UAAU,SACZ,QAAQ,KAAK,KACb,MAAM,SAAS,eACf,OAAO,MAAM,YAAY;AAE7B,MAAI,CAAC,SAAS;AACb,WAAO;AAAA,EACR;AAIA,MAAI,MAAM,YAAY,eAAe;AACpC,WAAO,MAAM,UAAU;AAAA,EACxB;AAEA,SAAO,cAAc,IAAI,MAAM,OAAO;AACvC;;;AD7BO,IAAM,aAAN,cAAyB,MAAM;AAAA,EACrC,YAAY,SAAS;AACpB,UAAM;AAEN,QAAI,mBAAmB,OAAO;AAC7B,WAAK,gBAAgB;AACrB,OAAC,EAAC,QAAO,IAAI;AAAA,IACd,OAAO;AACN,WAAK,gBAAgB,IAAI,MAA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