From 4b4fdd1160f844920518d4e3215e604b3be0842f Mon Sep 17 00:00:00 2001 From: Ferdy Moon Soo Beekmans Date: Mon, 3 Nov 2025 17:06:01 +0000 Subject: [PATCH] GZIP body --- lib/reporters.js | 6 ++++-- package.json | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/reporters.js b/lib/reporters.js index ebde40f..7be568e 100644 --- a/lib/reporters.js +++ b/lib/reporters.js @@ -2,6 +2,7 @@ const { fetch } = require('cross-fetch'); const { AuthorizationError, DatadogMetricsError, HttpError } = require('./errors'); const { logDebug, logDeprecation } = require('./logging'); +const {gzip} = require("pako"); const RETRYABLE_ERROR_CODES = new Set([ 'ECONNREFUSED', @@ -274,9 +275,10 @@ class DatadogReporter { method: 'POST', headers: { 'DD-API-KEY': datadogApiKeys.get(this), - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', + 'Content-Encoding': 'gzip' }, - body: JSON.stringify(options.body) + body: gzip(JSON.stringify(options.body)) }; return await this.httpApi.send(url, fetchOptions); } diff --git a/package.json b/package.json index 3c44beb..e69a0e1 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ }, "dependencies": { "cross-fetch": "^4.0.0", - "debug": "^4.1.0" + "debug": "^4.1.0", + "pako": "^2.1.0" }, "engines": { "node": ">=14.0.0"