Skip to content

Commit fbe2afd

Browse files
committed
out_opentelemetry: set proper content encoding for HTTP/1.x
Signed-off-by: Eduardo Silva <[email protected]>
1 parent 316959e commit fbe2afd

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

plugins/out_opentelemetry/opentelemetry.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,17 @@ int opentelemetry_legacy_post(struct opentelemetry_context *ctx,
9090
flb_plg_error(ctx->ins, "cannot gzip payload, disabling compression");
9191
}
9292
}
93+
else if (ctx->compress_zstd) {
94+
ret = flb_zstd_compress((void *) body, body_len,
95+
&final_body, &final_body_len);
96+
97+
if (ret == 0) {
98+
compressed = FLB_TRUE;
99+
}
100+
else {
101+
flb_plg_error(ctx->ins, "cannot zstd payload, disabling compression");
102+
}
103+
}
93104
else {
94105
final_body = (void *) body;
95106
final_body_len = body_len;
@@ -151,9 +162,17 @@ int opentelemetry_legacy_post(struct opentelemetry_context *ctx,
151162
}
152163

153164
if (compressed) {
154-
flb_http_set_content_encoding_gzip(c);
165+
if (ctx->compress_gzip) {
166+
flb_http_set_content_encoding_gzip(c);
167+
}
168+
else if (ctx->compress_zstd) {
169+
flb_http_set_content_encoding_zstd(c);
170+
}
155171
}
156172

173+
/* Map debug callbacks */
174+
flb_http_client_debug(c, ctx->ins->callback);
175+
157176
ret = flb_http_do(c, &b_sent);
158177

159178
if (ret == 0) {
@@ -760,6 +779,12 @@ static int cb_opentelemetry_init(struct flb_output_instance *ins,
760779

761780
flb_output_set_context(ins, ctx);
762781

782+
/*
783+
* This plugin instance uses the HTTP client interface, let's register
784+
* it debugging callbacks.
785+
*/
786+
flb_output_set_http_debug_callbacks(ins);
787+
763788
return 0;
764789
}
765790

0 commit comments

Comments
 (0)