Skip to content

Allow DBM <> APM trace comments in SQLCommenter to be appended instead of forcing prepend #9230

@DeniseApollo

Description

@DeniseApollo

Tracer Version(s)

1.51.2

Java Version(s)

21.0.8

JVM Vendor

Oracle JDK

Bug Report

After enabling DBM, the Datadog Java agent prepends comments to each SQL query to enable the integration between DBM and APM. Datadog's comments are always prepended, unless certain query conditions are met (MySQL callable statements, Postgres/MySQL stored procedures, and when pg_hint_plan comments exist).

We manually append a comment to our queries with custom tag values, following the sqlcommenter spec. This is as directed by your documentation and the tags appear in our explain plans and query samples in Datadog.

However, now that the DBM comment is being injected at the start of the SQL query, our integration with GCP Query Insights is broken - the tags are no longer appearing there. We have tested multiple formats and appending instead of prepending the DBM comment appears to resolve the issue.

We would therefore like the ability to force Datadog's comments to be appended to our SQL queries, via an environment variable.

This functionality was added to the Ruby agent in 2024, due to a similar conflict with AWS Performance Insights: DataDog/dd-trace-rb#3601

If users can choose to append instead of prepend the comments, this may also reduce the number of future exceptions that need to be added directly to the codebase (eg the recent addition of the pg_hint_plan exception).

Expected Behavior

We expect to be able to choose if the DBM <> APM SQL query propagation comment is appended or prepended to our queries, so that it doesn't break other integrations (eg GCP Query Insights or AWS Performance Insights).

Reproduction Code

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions