({ body, metadata, signal })
| 219 | const url = buildEndpoint(config.site) |
| 220 | return { |
| 221 | async deliver({ body, metadata, signal }) { |
| 222 | const rows = parseNdjsonObjects(body) |
| 223 | const entries = buildEntries(rows, config, metadata) |
| 224 | if (entries.length > MAX_ENTRIES_PER_REQUEST) { |
| 225 | throw new Error( |
| 226 | `Datadog chunk has ${entries.length} entries, exceeds the ${MAX_ENTRIES_PER_REQUEST} per-request limit` |
| 227 | ) |
| 228 | } |
| 229 | for (let i = 0; i < entries.length; i++) { |
| 230 | const entryBytes = Buffer.byteLength(JSON.stringify(entries[i]), 'utf8') |
| 231 | if (entryBytes > MAX_ENTRY_BYTES) { |
| 232 | throw new Error( |
| 233 | `Datadog entry at index ${i} is ${entryBytes} bytes, exceeds the ${MAX_ENTRY_BYTES}-byte per-entry limit` |
| 234 | ) |
| 235 | } |
| 236 | } |
| 237 | const payload = JSON.stringify(entries) |
| 238 | const prepared = buildRequestBody(payload, credentials.apiKey) |
| 239 | if (prepared.rawBytes > MAX_UNCOMPRESSED_BYTES) { |
| 240 | throw new Error( |
| 241 | `Datadog payload is ${prepared.rawBytes} bytes uncompressed, exceeds the ${MAX_UNCOMPRESSED_BYTES}-byte per-request limit` |
| 242 | ) |
| 243 | } |
| 244 | if (prepared.wireBytes > MAX_WIRE_BYTES) { |
| 245 | throw new Error( |
| 246 | `Datadog payload is ${prepared.wireBytes} bytes on the wire, exceeds the ${MAX_WIRE_BYTES}-byte defensive wire-size cap` |
| 247 | ) |
| 248 | } |
| 249 | const response = await postWithRetries({ |
| 250 | url, |
| 251 | prepared, |
| 252 | signal, |
| 253 | }) |
| 254 | const requestId = response.headers.get('dd-request-id') ?? null |
| 255 | logger.debug('Datadog chunk delivered', { |
| 256 | site: config.site, |
| 257 | rows: entries.length, |
| 258 | rawBytes: prepared.rawBytes, |
| 259 | wireBytes: prepared.wireBytes, |
| 260 | }) |
| 261 | return { |
| 262 | locator: requestId |
| 263 | ? `datadog://${config.site}#${metadata.runId}-${metadata.sequence}@${requestId}` |
| 264 | : `datadog://${config.site}#${metadata.runId}-${metadata.sequence}`, |
| 265 | } |
| 266 | }, |
| 267 | async close() {}, |
| 268 | } |
| 269 | }, |
nothing calls this directly
no test coverage detected