Empty response from OTLP endpoint causes exception
davidwindell opened this issue · comments
Currently testing with Dynatrace, they don't send any body content back when a log is created (just a 200 success). This leads to the following error on the PHP side (log is successfully reported on the remote system):
PHP message: OpenTelemetry: [error] Export failure [exception] gzdecode(): data error [previous]
#0 [internal function]: OpenTelemetry\SDK\Common\Export\Http\PsrUtils::OpenTelemetry\SDK\Common\Export\Http\{closure}(2, 'gzdecode(): dat...', '/workspace/test...', 161)
#1 /workspace/test/vendor/open-telemetry/sdk/Common/Export/Http/PsrUtils.php(161): gzdecode('')
#2 /workspace/test/vendor/open-telemetry/sdk/Common/Export/Http/PsrUtils.php(101): OpenTelemetry\SDK\Common\Export\Http\PsrUtils::OpenTelemetry\SDK\Common\Export\Http\{closure}('')
#3 /workspace/test/vendor/open-telemetry/sdk/Common/Export/Http/PsrTransport.php(132): OpenTelemetry\SDK\Common\Export\Http\PsrUtils::decode('', Array)
#4 /workspace/test/vendor/open-telemetry/exporter-otlp/LogsExporter.php(45): OpenTelemetry\SDK\Common\Export\Http\PsrTransport->send('\n\xF2\x02\n\x84\x01\n\x1F\n\x11servi...', NULL)
#5 /workspace/test/vendor/open-telemetry/sdk/Logs/Processor/SimpleLogRecordProcessor.php(26): OpenTelemetry...PHP message: OpenTelemetry: [error] Export failure [exception] gzdecode(): data error [previous]
#0 [internal function]: OpenTelemetry\SDK\Common\Export\Http\PsrUtils::OpenTelemetry\SDK\Common\Export\Http\{closure}(2, 'gzdecode(): dat...', '/workspace/test...', 161)
#1 /workspace/test/vendor/open-telemetry/sdk/Common/Export/Http/PsrUtils.php(161): gzdecode('\n\xC9\x01\x12\xC6\x01The follo...')
#2 /workspace/test/vendor/open-telemetry/sdk/Common/Export/Http/PsrUtils.php(101): OpenTelemetry\SDK\Common\Export\Http\PsrUtils::OpenTelemetry\SDK\Common\Export\Http\{closure}('\n\xC9\x01\x12\xC6\x01The follo...')
#3 /workspace/test/vendor/open-telemetry/sdk/Common/Export/Http/PsrTransport.php(132): OpenTelemetry\SDK\Common\Export\Http\PsrUtils::decode('\n\xC9\x01\x12\xC6\x01The follo...', Array)
#4 /workspace/test/vendor/open-telemetry/exporter-otlp/LogsExporter.php(45): OpenTelemetry\SDK\Common\Export\Http\PsrTransport->send('\n\x9B+\n\x84
Steps to reproduce
Send a log to Dynatrace using OTLP
What is the expected behavior?
No exception thrown when the response is successful but has no body content.
From the error trace, it's failing to gzdecode an empty response.
According to my reading of the spec, it's valid to send an empty body as a protobuf payload (because that can be decoded):
The response body MUST be the appropriate serialized Protobuf message
However, I don't think that an empty string is a valid gzip payload, because it can't be decompressed (in PHP, or via the gzip
utility on my machine):
❌ PHP gzdecode
:
php > var_dump(gzdecode(''));
Warning: gzdecode(): data error in php shell code on line 1
bool(false)
❌ GNU gzip 1.10, decompress empty string:
$ echo "" | gzip -d
gzip: stdin: unexpected end of file
✅ GNU gzip 1.10, compress then decompress empty string:
$ echo "" | gzip -cf | gzip -d
$ echo $?
0
So @davidwindell just to confirm, you got an empty response, with a Content-Encoding: gzip
header?
We've not proceeded with this particular provider and our new provider doesn't appear to exhibit this issue so I'll go ahead and close this down for now.
Thanks for looking into it for us @brettmc !