Skip to content

Commit

Permalink
Ensure JSON status descriptions are strings
Browse files Browse the repository at this point in the history
  • Loading branch information
jjatria committed May 2, 2024
1 parent b1d975c commit 6ffd710
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Revision history for OpenTelemetry-Exporter-OTLP
{{$NEXT}}

* Bump OTLP Protobuf files to v1.2.0
* Ensure JSON encoder encodes status messages as strings.

0.015 2023-11-26 16:19:58+00:00 Europe/London

Expand Down
2 changes: 1 addition & 1 deletion lib/OpenTelemetry/Exporter/OTLP/Encoder/JSON.pm
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class OpenTelemetry::Exporter::OTLP::Encoder::JSON {
method encode_status ( $status ) {
{
code => $status->code,
message => $status->description,
message => '' . $status->description,
};
}

Expand Down
8 changes: 6 additions & 2 deletions t/OpenTelemetry/Exporter/OTLP/Encoder/JSON.t
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ my $span_mock = mock 'Local::Span' => add => [
trace_state => sub { shift->{context}->trace_state },
];

is decode_json(CLASS->new->encode([
my $encoded = CLASS->new->encode([
Local::Span->new(
scope => $a_scope,
name => 'A-A',
Expand All @@ -80,7 +80,11 @@ is decode_json(CLASS->new->encode([
name => 'B-B',
resource => $b_resource,
),
])), {
]);

like $encoded, qr/"message":"[^"]*?"/, "Status description is a string";

is decode_json($encoded), {
resourceSpans => array {
prop size => 2;
all_items {
Expand Down

0 comments on commit 6ffd710

Please sign in to comment.