opentelemetry-cpp
opentelemetry-cpp copied to clipboard
[OTLP Exporter] Add gzip compression support for OTLP/HTTP and OTLP/gRPC exporter.
As documented in Specs - https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#opentelemetry-protocol-exporter
Compression: Compression key for supported compression types. Supported compression: gzip.
Default: No value [2]
Env vars: OTEL_EXPORTER_OTLP_COMPRESSION OTEL_EXPORTER_OTLP_TRACES_COMPRESSION OTEL_EXPORTER_OTLP_METRICS_COMPRESSION OTEL_EXPORTER_OTLP_LOGS_COMPRESSION
High level changes for OTLP HTTP Exporter:
- Add compression option (gzip/none) in OtlpHttpExporterOptions, OtlpHttpLogRecordExporterOptions, OtlpHttpMetricExporterOptions. Default is
none. - Modify ext::http::client::curl to
- If compression option is enabled,
- Make a HEAD request to server to validate if
gzipencoding is accepted. ( ? ) - If accepted, compress the data usingzlib, and setContent-Encoding: gzipheader. - If not accepted, send uncompressed data and log a warning
- Make a HEAD request to server to validate if
- If compression option is not enabled,
- send uncompressed data to server as done now.
- If compression option is enabled,
High level changes for OTLP gRPC Exporter:
- Add compression option (gzip/none) in OtlpGrpcExporterOptions. Default is
none. - Modify OtlpGrpcClient::MakeChannel to set the compression algorithm for the channel if enabled. Refer gRPC compression example here - https://github.com/grpc/grpc/blob/master/examples/cpp/compression/README.md#writing-a-client-and-a-server.
This issue is available for anyone to work on. Make sure to reference this issue in your pull request. :sparkles: Thank you for your contribution! :sparkles:
Hi @lalitb, I'm interested in working on this issue. It seems quite easy to add gzip compression to a grpc::Channel. However, I'm a little confused about the Http part. As far as I can understand, we have to send a curl request with the CURL_ACCEPT_ENCODING set to "gzip", and check the server's response for a Content-Encoding header. Do we have to do this once in OtlpHttpClient before Posting data or do we have to modify ext::http::client to send a HEAD request and wait for a response from the server before every POST request. I'm new to curl so I may have gotten some things incorrectly. Any help regarding this is appreciated.
Thanks
@perhapsmaple Thanks for volunteering for this. Although the check should be done once during startup, I feel we can ignore this step for now. It should be safe to assume that most of the HTTP servers in modern web infrastructure would support gzip encoding. We can revisit it later if there are exceptions. Have assigned it to you, feel free to ask any further questions.
This issue was marked as stale due to lack of activity.