Skip to content

Commit 6dfe294

Browse files
api-clients-generation-pipeline[bot]skarimoci.datadog-api-spec
authored
add compression methods to metric payloads (#775)
* add zstdCallback * Regenerate client from commit 0050c4a2 of spec repo Co-authored-by: Sherzod Karimov <[email protected]> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent dc8cd8d commit 6dfe294

File tree

11 files changed

+72
-8
lines changed

11 files changed

+72
-8
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.4",
7-
"regenerated": "2022-08-29 15:23:51.611403",
8-
"spec_repo_commit": "592474c8"
7+
"regenerated": "2022-08-29 17:43:12.262504",
8+
"spec_repo_commit": "0050c4a2"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.4",
12-
"regenerated": "2022-08-29 15:23:51.629022",
13-
"spec_repo_commit": "592474c8"
12+
"regenerated": "2022-08-29 17:43:12.275100",
13+
"spec_repo_commit": "0050c4a2"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5515,12 +5515,16 @@ components:
55155515
x-enum-varnames:
55165516
- USER_AGENT_PARSER
55175517
MetricContentEncoding:
5518+
default: deflate
55185519
description: HTTP header used to compress the media-type.
55195520
enum:
55205521
- deflate
5522+
- gzip
5523+
example: deflate
55215524
type: string
55225525
x-enum-varnames:
55235526
- DEFLATE
5527+
- GZIP
55245528
MetricMetadata:
55255529
description: Object with all metric related metadata.
55265530
properties:

.generator/schemas/v2/openapi.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4319,9 +4319,14 @@ components:
43194319
description: HTTP header used to compress the media-type.
43204320
enum:
43214321
- deflate
4322+
- zstd1
4323+
- gzip
4324+
example: deflate
43224325
type: string
43234326
x-enum-varnames:
43244327
- DEFLATE
4328+
- ZSTD1
4329+
- GZIP
43254330
MetricCustomAggregation:
43264331
description: A time and space aggregation combination for use in query.
43274332
example:
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Submit metrics with compression returns "Payload accepted" response
3+
*/
4+
5+
import { client, v2 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v2.MetricsApi(configuration);
9+
10+
const params: v2.MetricsApiSubmitMetricsRequest = {
11+
body: {
12+
series: [
13+
{
14+
metric: "system.load.1",
15+
type: 0,
16+
points: [
17+
{
18+
timestamp: Math.round(new Date().getTime() / 1000),
19+
value: 0.7,
20+
},
21+
],
22+
},
23+
],
24+
},
25+
contentEncoding: "zstd1",
26+
};
27+
28+
apiInstance
29+
.submitMetrics(params)
30+
.then((data: v2.IntakePayloadAccepted) => {
31+
console.log(
32+
"API called successfully. Returned data: " + JSON.stringify(data)
33+
);
34+
})
35+
.catch((error: any) => console.error(error));

features/step_definitions/request_steps.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import * as datadogApiClient from "../../index";
99
import fs from "fs";
1010
import path from "path";
1111

12+
import { compressSync } from "zstd.ts";
1213
import log from "loglevel";
1314
const logger = log.getLogger("testing")
1415
logger.setLevel(process.env.DEBUG ? logger.levels.DEBUG : logger.levels.INFO);
@@ -73,6 +74,7 @@ When("the request is sent", async function (this: World) {
7374
const configurationOpts = {
7475
authMethods: this.authMethods,
7576
httpConfig: { compress: false },
77+
zstdCompressorCallback: (body: string) => compressSync({input: Buffer.from(body, "utf8")}),
7678
};
7779
if (process.env.DD_TEST_SITE) {
7880
const serverConf = datadogApiClient.client.servers[2].getConfiguration();

features/support/vcr.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ Before(function (
132132
});
133133
});
134134

135+
// Disable PollyJS request interception when tests are in integration mode
136+
Before(async function (this: World) {
137+
if (this.polly?.mode == MODES.PASSTHROUGH) {
138+
this.polly.configure({adapters: []})
139+
}
140+
});
141+
135142
// The order of After functions is important. They are in reverse order
136143
// hence this.cleanup() must be defined after this.polly.stop().
137144

features/v2/metrics.feature

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,14 @@ Feature: Metrics
216216
When the request is sent
217217
Then the response status is 408 Request timeout
218218

219+
@integration-only @skip-terraform-config @skip-validation @team:DataDog/metrics-intake @team:DataDog/metrics-query
220+
Scenario: Submit metrics with compression returns "Payload accepted" response
221+
Given new "SubmitMetrics" request
222+
And body with value {"series": [{"metric": "system.load.1", "type": 0, "points": [{"timestamp": {{ timestamp('now') }}, "value": 0.7}]}]}
223+
And request contains "Content-Encoding" parameter with value "zstd1"
224+
When the request is sent
225+
Then the response status is 202 Payload accepted
226+
219227
@generated @skip @team:DataDog/points-aggregation
220228
Scenario: Tag Configuration Cardinality Estimator returns "API error response." response
221229
Given a valid "appKeyAuth" key in the system

packages/datadog-api-client-v1/models/MetricContentEncoding.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
* Copyright 2020-Present Datadog, Inc.
55
*/
66

7-
export type MetricContentEncoding = typeof DEFLATE;
7+
export type MetricContentEncoding = typeof DEFLATE | typeof GZIP;
88
export const DEFLATE = "deflate";
9+
export const GZIP = "gzip";

packages/datadog-api-client-v1/models/ObjectSerializer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ const enumsMap: { [key: string]: any[] } = {
708708
LogsTraceRemapperType: ["trace-id-remapper"],
709709
LogsURLParserType: ["url-parser"],
710710
LogsUserAgentParserType: ["user-agent-parser"],
711-
MetricContentEncoding: ["deflate"],
711+
MetricContentEncoding: ["deflate", "gzip"],
712712
MonitorDeviceID: [
713713
"laptop_large",
714714
"tablet",

packages/datadog-api-client-v2/models/MetricContentEncoding.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@
44
* Copyright 2020-Present Datadog, Inc.
55
*/
66

7-
export type MetricContentEncoding = typeof DEFLATE;
7+
export type MetricContentEncoding = typeof DEFLATE | typeof ZSTD1 | typeof GZIP;
88
export const DEFLATE = "deflate";
9+
export const ZSTD1 = "zstd1";
10+
export const GZIP = "gzip";

0 commit comments

Comments
 (0)