Skip to content

fixed json encoding of melt send --dump data #371

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

Merged
merged 1 commit into from
May 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions platform/melt/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
metrics "go.opentelemetry.io/proto/otlp/metrics/v1"
resource "go.opentelemetry.io/proto/otlp/resource/v1"
spans "go.opentelemetry.io/proto/otlp/trace/v1"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/encoding/prototext"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/reflect/protoreflect"
Expand Down Expand Up @@ -538,11 +539,12 @@ func dumpPayload(m proto.Message, format string, writer func(string)) {
case DumpFormatHuman:
s = prototext.Format(m)
case DumpFormatText:
b, err = prototext.Marshal(m)
b, err = prototext.Marshal(m) // untagged field names will go to lowerCamelCase
case DumpFormatJson:
b, err = json.MarshalIndent(m, "", output.JsonIndent)
// nb: protojson is required for marshalling proto3 messages; it also defaults to lowerCamelCase field name encoding
b, err = protojson.MarshalOptions{Multiline: true, Indent: output.JsonIndent}.Marshal(m)
case DumpFormatYaml:
b, err = yaml.Marshal(m)
b, err = yaml.Marshal(m) // untagged field names will go to lowerCamelCase
case DumpFormatHex:
b, err = proto.Marshal(m)
if err == nil {
Expand Down
Loading