-
Notifications
You must be signed in to change notification settings - Fork 212
Description
Describe your environment
PHP | 8.3.11
open-telemetry/api | 1.2.3
open-telemetry/context | 1.1.0
open-telemetry/exporter-otlp | 1.2.1
open-telemetry/gen-otlp-protobuf | 1.5.0
open-telemetry/opentelemetry-auto-curl | 0.0.3
open-telemetry/opentelemetry-auto-psr18 | 1.1.0
open-telemetry/opentelemetry-auto-slim | 1.1.0
open-telemetry/opentelemetry-auto-symfony | 1.0.0
open-telemetry/sdk | 1.2.2
open-telemetry/sem-conv | 1.30.0
Steps to reproduce
Describe exactly how to reproduce the error. Include a code sample if applicable.
Use a third party library that sets curl option verbose to 1. i.e. curl_setopt($curl, CURLOPT_VERBOSE, 1);
What is the expected behavior?
No warnings/exceptions
What is the actual behavior?
We get the following exception
Core Warning: curl_setopt(): OpenTelemetry: post hook threw exception, class=null function=curl_setopt message=Cannot assign int to property OpenTelemetry\Contrib\Instrumentation\Curl\CurlHandleMetadata::$verboseEnabled of type bool
Additional context
We are consuming some third party SDK libraries that seem to set curl option CURLOPT_VERBOSE to 1 instead of true. Example 1. Example 2. curl accepts the parameters fine however this causes an exception in opentelemetry-auto-curl.
One suggestion would be to update the line https://github.com/opentelemetry-php/contrib-auto-curl/blob/main/src/CurlHandleMetadata.php#L140
from
case CURLOPT_VERBOSE:
$this->verboseEnabled = $value;
to
case CURLOPT_VERBOSE:
$this->verboseEnabled = (bool) $value;
to ensure that $value is converted to a boolean before assignment. If this seems ok, I can try to put up a PR for that. Thanks!