open-telemetry / opentelemetry-collector-contrib

Contrib repository for the OpenTelemetry Collector
https://opentelemetry.io
Apache License 2.0
2.72k stars 2.16k forks source link

Add internal/grpcutil package #33688

Open jmacd opened 1 week ago

jmacd commented 1 week ago

Description: With utilities to encode and decode timeout in the syntax specified by gRPC. This will be used by the otelarrow components to encode and decode timeout values. In that sense, the new code could also be added into the pending internal/otelarrow package, see https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/33579

As this code is derived from gRPC-Go, some text is added in NOTICE according to the license. The code that this was derived from contained a TODO, which was largely addressed by eliminating very short timeouts from being encoded. This code will encode timeouts in milliseconds, seconds, hours, and days but it will not encode microsecond/nanosecond durations, these are rounded to 0m. The decoder will handle all durations that gRPC specifies, so that this logic can change in the future.

Link to tracking Issue: https://github.com/open-telemetry/otel-arrow/issues/227

Testing: Adds basic tests.