Skip to content

Commit

Permalink
add missing unit test, fix inconsistency in reported error
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
  • Loading branch information
codeboten committed Mar 4, 2024
1 parent 9e41dfc commit 2d2a5b1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion config/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func periodicExporter(ctx context.Context, exporter MetricExporter, opts ...sdkm
case protocolProtobufGRPC:
exp, err = otlpGRPCMetricExporter(ctx, exporter.OTLP)
default:
return nil, fmt.Errorf("unsupported protocol %s", exporter.OTLP.Protocol)
return nil, fmt.Errorf("unsupported protocol %q", exporter.OTLP.Protocol)
}
if err != nil {
return nil, err
Expand Down
13 changes: 13 additions & 0 deletions config/metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,19 @@ func TestReader(t *testing.T) {
},
wantReader: readerWithServer{promExporter, nil},
},
{
name: "periodic/otlp-exporter-invalid-protocol",
reader: MetricReader{
Periodic: &PeriodicMetricReader{
Exporter: MetricExporter{
OTLP: &OTLPMetric{
Protocol: "http/invalid",
},
},
},
},
wantErr: errors.New("unsupported protocol \"http/invalid\""),
},
{
name: "periodic/otlp-grpc-exporter",
reader: MetricReader{
Expand Down
2 changes: 1 addition & 1 deletion config/trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func TestSpanProcessor(t *testing.T) {
ScheduleDelay: ptr(0),
Exporter: SpanExporter{
OTLP: &OTLP{
Protocol: *ptr("http/invalid"),
Protocol: "http/invalid",
},
},
},
Expand Down

0 comments on commit 2d2a5b1

Please sign in to comment.