-
Notifications
You must be signed in to change notification settings - Fork 1.9k
out_opentelemetry: Add 'encoding' option for OTLP/HTTP JSON export #11844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -548,6 +548,44 @@ struct opentelemetry_context *flb_opentelemetry_context_create(struct flb_output | |
| } | ||
| } | ||
|
|
||
| ctx->use_json_encoding = FLB_FALSE; | ||
| tmp = flb_output_get_property("encoding", ins); | ||
| if (tmp) { | ||
| if (strcasecmp(tmp, "json") == 0) { | ||
| ctx->use_json_encoding = FLB_TRUE; | ||
| } | ||
|
Comment on lines
+554
to
+556
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Allowing Useful? React with 👍 / 👎. |
||
| else if (strcasecmp(tmp, "protobuf") != 0) { | ||
| flb_plg_error(ctx->ins, | ||
| "Unknown encoding value '%s'. " | ||
| "Accepted values: 'protobuf' (default) or 'json'", tmp); | ||
| flb_opentelemetry_context_destroy(ctx); | ||
| return NULL; | ||
| } | ||
| } | ||
|
|
||
| /* | ||
| * Per the OpenTelemetry specification, OTLP/gRPC exclusively uses protobuf | ||
| * encoding on the wire. Reject the combination early so the user gets a | ||
| * clear error rather than silent data corruption. | ||
| * Reference: https://opentelemetry.io/docs/specs/otlp/#otlpgrpc | ||
| */ | ||
| if (ctx->use_json_encoding && ctx->enable_grpc_flag) { | ||
| flb_plg_error(ctx->ins, | ||
| "encoding=json is incompatible with grpc=on. " | ||
| "OTLP/gRPC only supports protobuf encoding per the " | ||
| "OpenTelemetry specification. " | ||
| "Use encoding=json with HTTP transport (grpc=off) instead."); | ||
| flb_opentelemetry_context_destroy(ctx); | ||
| return NULL; | ||
| } | ||
|
|
||
| if (ctx->use_json_encoding) { | ||
| flb_plg_warn(ctx->ins, | ||
| "encoding=json does not apply to profiles: profiles " | ||
| "will always be exported as protobuf " | ||
| "(no JSON encoder exists for cprofiles)"); | ||
| } | ||
|
|
||
| ctx->ra_observed_timestamp_metadata = flb_ra_create((char*)ctx->logs_observed_timestamp_metadata_key, | ||
| FLB_FALSE); | ||
| if (ctx->ra_observed_timestamp_metadata == NULL) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This early return bypasses the existing metrics path that calls
append_labels(ctx, cmt)before encoding, so configuredadd_labelentries are silently dropped wheneverencoding=jsonis used. That changes exported metric content compared to protobuf mode and regresses a documented plugin option.Useful? React with 👍 / 👎.