status of the inconsistency between otlp http json format and protocol specification #1924
Closed
Description
Description
For httpjson format, the specification states that trace_id and span_id should not use base64 encoding and should use case insensitive hex encoding. However the current implementation seems to use default protobuf json encoding (which base64-ed trace_id and span_id).
I see http json is experimental currently so is the specification about this part subject to change? or should we fix the json encoding part? Currently the sdk encode trace_id/span_id using base64 so it actually can not send span to the otlp receiver.
Environment
- OS: Linux
- Architecture: amd64
- Go Version: go 1.16.3
- opentelemetry-go version: master
Steps To Reproduce
- modify
example/otel-collector/main.go
to useotlphttp
instead ofotlpgrpc
, remove grpc specific option, add marshal json option - run a collector, run the compiled binary of step 1
Expected behavior
span send successfully
Actual behavior
log shows status 400, manually check reveals that its because of "invald length for ID".
patch
patch of the modified example file:
diff --git a/example/otel-collector/main.go b/example/otel-collector/main.go
index 2560c04a..05b7524b 100644
--- a/example/otel-collector/main.go
+++ b/example/otel-collector/main.go
@@ -23,12 +23,10 @@ import (
"log"
"time"
- "google.golang.org/grpc"
-
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/exporters/otlp"
- "go.opentelemetry.io/otel/exporters/otlp/otlpgrpc"
+ "go.opentelemetry.io/otel/exporters/otlp/otlphttp"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/global"
"go.opentelemetry.io/otel/propagation"
@@ -51,10 +49,10 @@ func initProvider() func() {
// `localhost:30080` endpoint. Otherwise, replace `localhost` with the
// endpoint of your cluster. If you run the app inside k8s, then you can
// probably connect directly to the service through dns
- driver := otlpgrpc.NewDriver(
- otlpgrpc.WithInsecure(),
- otlpgrpc.WithEndpoint("localhost:30080"),
- otlpgrpc.WithDialOption(grpc.WithBlock()), // useful for testing
+ driver := otlphttp.NewDriver(
+ otlphttp.WithInsecure(),
+ otlphttp.WithEndpoint("localhost:55681"),
+ otlphttp.WithMarshal(otlp.MarshalJSON),
)
exp, err := otlp.NewExporter(ctx, driver)
handleErr(err, "failed to create exporter")