otlp+json enums should be integers
The otel collector currently accepts the string values of ENUMs for json-encoded payloads, but this is now prohibited and will likely be removed in a future collector release:
- https://github.com/open-telemetry/opentelemetry-proto/issues/424
- https://github.com/open-telemetry/opentelemetry-specification/pull/2758
We currently use protobuf's serializeToJsonString() method to generate JSON payloads, which doesn't expose any options to represent enums as their integer values.
Possible solutions:
- submit an enhancement to protobuf PHP implementations (native + extension) to add/fix/expose the option to represent ENUMs as integers
- write a custom serializer for JSON
Additional context
Protobuf Ruby seems to support FormatEnumsAsIntegers There is a partial implementation in the protobuf php extension for FormatEnumsAsIntegers, but it is not exposed via any public interfaces (and not available in the native library)
Tasks:
- [x] update protobuf to allow enums as int
- [ ] update
ProtobufSerializerto send new flag(s) - [ ] wait for new version of protobuf to release
PR against google/protobuf to allow formatting enums as strings for JSON output: https://github.com/protocolbuffers/protobuf/pull/12707
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Note that this has been worked around via #1192 until protobuf changes are accepted.