Skip to content

[opentelemetry-php-contrib] OpenTelemetry: pre hook threw exception #1649

@MarcHagen

Description

@MarcHagen

Describe your environment

PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

PHP 8.3.20 (fpm-fcgi) (built: Apr 11 2025 17:02:03)
Copyright (c) The PHP Group
Zend Engine v4.3.20, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.20, Copyright (c), by Zend Technologies

open-telemetry/opentelemetry: v1.0.0
open-telemetry/opentelemetry-auto-curl: v0.0.5

Steps to reproduce
I'm not quite sure why this is a problem. It seems somehow the curl_init hook is not fired correctly sometimes resulting in the CurlHandle too not being set properly in the WeakMap.

What is the expected behavior?
No warnings, errors

What is the actual behavior?

PHP Warning:  curl_setopt(): OpenTelemetry: post hook threw exception, class=null function=curl_setopt message=Object CurlHandle#163 not contained in WeakMap in Unknown on line 0
PHP Warning:  curl_exec(): OpenTelemetry: pre hook threw exception, class=null function=curl_exec message=Object CurlHandle#163 not contained in WeakMap in Unknown on line 0

Additional context
Exceptions/warnings come from the not existing key check:
https://github.com/open-telemetry/opentelemetry-php-contrib/blob/e0c6ed6d2a001fb5a5433238b7aa80791672cf4a/src/Instrumentation/Curl/src/CurlInstrumentation.php#L71
https://github.com/open-telemetry/opentelemetry-php-contrib/blob/e0c6ed6d2a001fb5a5433238b7aa80791672cf4a/src/Instrumentation/Curl/src/CurlInstrumentation.php#L193

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions