Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

JSON/HTTP support in OTLP receiver #1177

Closed
nilebox opened this issue Jun 24, 2020 · 9 comments
Closed

JSON/HTTP support in OTLP receiver #1177

nilebox opened this issue Jun 24, 2020 · 9 comments
Assignees
Labels
bug Something isn't working help wanted Good issue for contributors to OpenTelemetry Service to pick up

Comments

@nilebox
Copy link
Member

nilebox commented Jun 24, 2020

We need to decide if the currently supported JSON via gRPC Gateway should be made official, or whether we need to address the issue https://github.com/open-telemetry/opentelemetry-proto/issues/129 first.

Additional context
We still need to keep gRPC Gateway integration to support "Protobuf over HTTP" protocol introduced in #1021.
We just need to disable the default "wildcard" handler, which accepts JSON by default: https://github.com/grpc-ecosystem/grpc-gateway/blob/ee3ef70b7777cde4e61e4e224cb11e92beecee6a/runtime/marshaler_registry.go#L78

@nilebox nilebox added the bug Something isn't working label Jun 24, 2020
@tigrannajaryan
Copy link
Member

I fail to see the problem. This is how JSON encoding in grpc-gateway is supposed to work. Why do we not want to support it?

@nilebox
Copy link
Member Author

nilebox commented Jun 24, 2020

This is how JSON encoding in grpc-gateway is supposed to work.

Yes, but it has issue with encoding trace/span IDs and JSON is not officially supported yet AFAIK. See https://github.com/open-telemetry/opentelemetry-proto/issues/129
It's better to disable unsupported protocol to prevent clients from using it IMO? We can always enable back if we decide that https://github.com/open-telemetry/opentelemetry-proto/issues/129 doesn't need to be addressed, or implement a custom marshaler for it.

@tigrannajaryan see your own comment in the discussion thread https://github.com/open-telemetry/opentelemetry-proto/issues/129#issuecomment-622443175: JSON support is not documented by the spec.

@yurishkuro has previously shared that in Jaeger they use a custom serialization to solve the problem with base64 vs hex encoding.
Also see @bogdandrutu 's comment https://github.com/open-telemetry/opentelemetry-proto/issues/129#issuecomment-630413454

The consensus seems to be that JSON is not supported, but in fact it is technically supported by collector. We should either declare it as supported, or disable it to make the documentation and implementation consistent. Please correct me if I'm wrong.

@nilebox
Copy link
Member Author

nilebox commented Jun 25, 2020

@tigrannajaryan @bogdandrutu @yurishkuro Alternatively, if we all agree that supporting JSON is important, I can look into addressing https://github.com/open-telemetry/opentelemetry-proto/issues/129 via custom marshaler instead.

Most likely, this will require defining new (internal) Go types specifically for unmarshalling trace spans, or using gogo/protobuf's feature https://github.com/gogo/protobuf/blob/master/custom_types.md. It might be better to work on that once OTLP is considered stable with no planned breaking changes though.
Metrics don't have that issue AFAIK, so we could just use auto-generated types from opentelemetry-proto (i.e. keep current behavior).

@tigrannajaryan
Copy link
Member

@nilebox I am not convinced https://github.com/open-telemetry/opentelemetry-proto/issues/129 is a problem that needs a solution either :-) It seems to me base64 is an acceptable way to encode trace id and span id in JSON.

@yurishkuro
Copy link
Member

@tigrannajaryan I am personally conflicted about that. I often catch myself looking at raw trace data in JSON, maybe because UI doesn't show something, or there's some other information/correlation I am looking for. Having the IDs in JSON base64 encoded makes it difficult to correlate. The tracing UI could be smart to recognize both encodings, but if I tag my logs with trace/span IDs and that's done in hex encoding, then the user needs to jump through hoops to correlate the data (not everything can be solved via UI integrations). I tend to agree with @Oberon00 (https://github.com/open-telemetry/opentelemetry-proto/issues/129#issuecomment-599686909), it could be better if we always used base64 instead of hex, including log fields.

@nilebox
Copy link
Member Author

nilebox commented Jun 29, 2020

If we do want to support JSON and fine with base64 encoding, then no code changes are required (apart from making sure that we also use base64 in logs), but we need to document application/json as a supported OTLP protocol over HTTP, and then SDKs may start introducing support for it on the client side.

@nilebox nilebox changed the title Disable JSON/HTTP support in OTLP receiver JSON/HTTP support in OTLP receiver Jun 30, 2020
@nilebox
Copy link
Member Author

nilebox commented Jun 30, 2020

Rephrased the issue to discuss the path to official JSON support rather than just disabling it.

@flands flands added this to the GA 1.0 milestone Jul 27, 2020
@tigrannajaryan tigrannajaryan added the help wanted Good issue for contributors to OpenTelemetry Service to pick up label Sep 2, 2020
@tigrannajaryan
Copy link
Member

Spec was updated to require hex instead of base64 for trace id and span id: open-telemetry/opentelemetry-specification#911

tigrannajaryan added a commit that referenced this issue Sep 15, 2020
The TraceID type uses custom data type so that JSON serialization
is in hex format instead of base64 (which is the default Protobuf JSON
format). Hex format is required by OTLP spec:
https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/protocol/otlp.md#request
SpanID must be also modified similarly. Will be done in a future PR
to avoid creating a huge PR.

TraceID data is not yet used in the codebase. This is just an introductory
commit that adds the type and tests but does not yet use them for actual
serialization of OTLP messages. It will be done in a future PR.

Contributes to #1177
tigrannajaryan pushed a commit to tigrannajaryan/opentelemetry-collector that referenced this issue Sep 23, 2020
Contributes to open-telemetry#1177

1. The TraceID type uses custom data type so that JSON serialization
is in hex format instead of base64 (which is the default Protobuf JSON
format). Hex format is required by OTLP spec:
https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/protocol/otlp.md#request
SpanID must be also modified similarly. Will be done in a future PR
to avoid creating a huge PR.

2. Moved pdata.TraceID to its own file. Note that there is pdata.TraceID which
is different from otlp TraceID custom data type. Due to the way packages are
structured we need both to keep OTLP generated data types decoupled from pdata
data types.

The majority of the changes in this commit are simply type changes from
[]byte to TraceID.
tigrannajaryan added a commit that referenced this issue Sep 24, 2020
Contributes to #1177

1. The TraceID type uses custom data type so that JSON serialization
is in hex format instead of base64 (which is the default Protobuf JSON
format). Hex format is required by OTLP spec:
https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/protocol/otlp.md#request
SpanID must be also modified similarly. Will be done in a future PR
to avoid creating a huge PR.

2. Moved pdata.TraceID to its own file. Note that there is pdata.TraceID which
is different from otlp TraceID custom data type. Due to the way packages are
structured we need both to keep OTLP generated data types decoupled from pdata
data types.

The majority of the changes in this commit are simply type changes from
[]byte to TraceID.
tigrannajaryan pushed a commit to tigrannajaryan/opentelemetry-collector that referenced this issue Sep 25, 2020
In preparation to SpanID type that is very similar to TraceID
I extracted bytesID as a separate that implements the common
functionality.

Contribytes to open-telemetry#1177
tigrannajaryan pushed a commit to tigrannajaryan/opentelemetry-collector that referenced this issue Sep 25, 2020
This is step 2 in adding SpanID custom data type. This only introduces the
type but does not yet use it in Protobuf messages. It will added in a future PR.

Contributes to open-telemetry#1177
tigrannajaryan pushed a commit to tigrannajaryan/opentelemetry-collector that referenced this issue Sep 25, 2020
This enables usage of SpanID data type. Now span id is hex encoded
as it is required by OTLP specification.

Contributes to: open-telemetry#1177
bogdandrutu pushed a commit that referenced this issue Sep 28, 2020
In preparation to SpanID type that is very similar to TraceID
I extracted bytesID as a separate that implements the common
functionality.

Contribytes to #1177
tigrannajaryan pushed a commit to tigrannajaryan/opentelemetry-collector that referenced this issue Sep 29, 2020
This is step 2 in adding SpanID custom data type. This only introduces the
type but does not yet use it in Protobuf messages. It will added in a future PR.

Contributes to open-telemetry#1177
tigrannajaryan pushed a commit to tigrannajaryan/opentelemetry-collector that referenced this issue Sep 29, 2020
This enables usage of SpanID data type. Now span id is hex encoded
as it is required by OTLP specification.

Contributes to: open-telemetry#1177
bogdandrutu pushed a commit that referenced this issue Sep 29, 2020
This is step 2 in adding SpanID custom data type. This only introduces the
type but does not yet use it in Protobuf messages. It will added in a future PR.

Contributes to #1177
tigrannajaryan pushed a commit to tigrannajaryan/opentelemetry-collector that referenced this issue Sep 29, 2020
This enables usage of SpanID data type. Now span id is hex encoded
as it is required by OTLP specification.

Contributes to: open-telemetry#1177
tigrannajaryan pushed a commit to tigrannajaryan/opentelemetry-collector that referenced this issue Sep 29, 2020
This enables usage of SpanID data type. Now span id is hex encoded
as it is required by OTLP specification.

Contributes to: open-telemetry#1177
tigrannajaryan pushed a commit to tigrannajaryan/opentelemetry-collector that referenced this issue Oct 1, 2020
This enables usage of SpanID data type. Now span id is hex encoded
as it is required by OTLP specification.

Contributes to: open-telemetry#1177
tigrannajaryan added a commit that referenced this issue Oct 1, 2020
This enables usage of SpanID data type. Now span id is hex encoded
as it is required by OTLP specification.

Contributes to: #1177
@tigrannajaryan
Copy link
Member

This is now done and should confirm to OTLP/JSON spec. Closing. Submit separate bugs if any problems are found.

hughesjj pushed a commit to hughesjj/opentelemetry-collector that referenced this issue Apr 27, 2023
Troels51 pushed a commit to Troels51/opentelemetry-collector that referenced this issue Jul 5, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working help wanted Good issue for contributors to OpenTelemetry Service to pick up
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants