Skip to content

[Bug]: Cannot edit span->name and span->service in trace_method anymore #3261

@devantoine

Description

@devantoine

Bug report

Hello,

For a few weeks now (maybe a couple months?) we are not able to edit the span's name and span's service inside the \DDTrace\trace_method function.

We did not edit the code, it stopped working suddenly.

\DDTrace\trace_method(
    'App\Exceptions\Handler',
    'addErrorToDatadogTraceSpan',
    function (DDTrace\SpanData $span, $args, $ret, $exception): void {
        // Ok, all exception thrown into the addErrorToDatadogTraceSpan function will be logged as a trace error
        $span->name = 'error.handler';

        $e = $args[0] ?? null;
        if ($e instanceof Throwable) {
            $span->resource = $e->getMessage();
        } elseif (is_string($e)) {
            $span->resource = $e;
        }

        $sendToErrorTracking = $args[1] ?? false;
        if ($sendToErrorTracking) {
            $span->service = 'error.handler';
        }
    }
);

Debugging this snippet, I can tell it's still run (especially the $span->service = 'error.handler'; line), but errors listed in the error tracking page do not hold these data anymore.

We upgraded the dd-trace extension to the latest version (1.9.0) without any luck.

It is really a pain because we have a monitor filtering on span.name:error.handler connected to Slack, alerting us in case of a critical error.

Is there a way to get back this behavior?

PHP version

8.4.7

Tracer or profiler version

1.9.0

Installed extensions

[PHP Modules]
apcu
bcmath
Core
ctype
curl
datadog-profiling
date
ddappsec
ddtrace
dom
exif
fileinfo
filter
gd
hash
iconv
intl
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
random
readline
redis
Reflection
session
SimpleXML
sodium
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache
datadog-profiling
ddappsec
ddtrace

Output of phpinfo()

{
    "date": "2025-05-20T08:41:09Z",
    "os_name": "Linux ip-10-10-68-124.eu-west-3.compute.internal 5.10.235-227.919.amzn2.x86_64 #1 SMP Sat Apr 5 16:59:05 UTC 2025 x86_64",
    "os_version": "5.10.235-227.919.amzn2.x86_64",
    "version": "1.9.0",
    "lang": "php",
    "lang_version": "8.4.1",
    "env": "preprod",
    "enabled": true,
    "service": "web",
    "enabled_cli": true,
    "agent_url": "http:\/\/localhost:8126",
    "debug": false,
    "analytics_enabled": false,
    "sample_rate": -1,
    "sampling_rules": [],
    "tags": [],
    "service_mapping": [],
    "distributed_tracing_enabled": true,
    "dd_version": "2025-05-16-10-24-40-26-gec40bcf",
    "architecture": "x86_64",
    "instrumentation_telemetry_enabled": true,
    "sapi": "fpm-fcgi",
    "datadog.trace.sources_path": "\/opt\/datadog\/dd-library\/1.9.0\/dd-trace-sources\/src",
    "open_basedir_configured": false,
    "uri_fragment_regex": null,
    "uri_mapping_incoming": null,
    "uri_mapping_outgoing": null,
    "auto_flush_enabled": false,
    "generate_root_span": true,
    "http_client_split_by_domain": false,
    "measure_compile_time": true,
    "report_hostname_on_root_span": false,
    "traced_internal_functions": null,
    "enabled_from_env": true,
    "opcache.file_cache": null,
    "sidecar_trace_sender": true
}

Upgrading from

No response

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