Skip to content

[opentelemetry-php-contrib] Doctrine connection spans not appearing in New Relic #1578

Open
open-telemetry/opentelemetry-php-contrib
#374
@Ardenexal

Description

@Ardenexal

Describe your environment
PHP 8.3.20

Composer

    "doctrine/doctrine-bundle": "^2.10",
    "doctrine/doctrine-migrations-bundle": "^3.2",
    "doctrine/orm": "^2.15",
    "open-telemetry/exporter-otlp": "^1.1.0",
    "open-telemetry/opentelemetry-auto-doctrine": "^0.2.0",
    "open-telemetry/opentelemetry-auto-psr3": "^0.1.0",
    "open-telemetry/opentelemetry-auto-psr14": "^0.0.4",
    "open-telemetry/opentelemetry-auto-psr16": "^0.0.4",
    "open-telemetry/opentelemetry-auto-psr18": "^1.1.0",
    "open-telemetry/opentelemetry-auto-symfony": "^1.0.0",

Steps to reproduce
I've been trying out the new doctrine auto instrumentation and liking it so far but in New relic it not displaying as i would except.

The SELECT atc does not show in the database tab
Image

But in the individual trace it does show correctly
Image

What is the expected behavior?
I should be able to see the Database statements in the database tab of New Relic.

What is the actual behavior?
Currently they only seem to be shown in the Spans

Additional context

Looking a https://github.com/open-telemetry/opentelemetry-php-contrib/blob/main/src/Instrumentation/Doctrine/src/DoctrineInstrumentation.php I believe the issue is that the database attributes are not on the Connection::class spans

      ->setAttribute(TraceAttributes::SERVER_ADDRESS, AttributesResolver::get(TraceAttributes::SERVER_ADDRESS, func_get_args()))
                ->setAttribute(TraceAttributes::SERVER_PORT, AttributesResolver::get(TraceAttributes::SERVER_PORT, func_get_args()))
                ->setAttribute(TraceAttributes::DB_SYSTEM, AttributesResolver::get(TraceAttributes::DB_SYSTEM, func_get_args()))
                ->setAttribute(TraceAttributes::DB_NAMESPACE, AttributesResolver::get(TraceAttributes::DB_NAMESPACE, func_get_args()));

I'm guessing it's because there is some sort of Span link that is being used to link the connect span with the connection span but New Relic currently doesn't support link spans.

Could we add the following attributes to the Connection::class hooks db.system Additionally, I think we can add the following db.sql.table and db.operation for better UX in applications like New Relic.

Here is the documentation from New Relic if that's useful https://docs.newrelic.com/docs/opentelemetry/get-started/apm-monitoring/opentelemetry-apm-ui/#databases-page

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