GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Allow DBM <> APM trace comments in SQLCommenter to be appended instead of forcing prepend · Issue #9230 · DataDog/dd-trace-java

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

New issue
Copy link
New issue
Copy link
Closed
Closed
Allow DBM <> APM trace comments in SQLCommenter to be appended instead of forcing prepend#9230
Copy link
Labels
comp: databaseDatabase Monitoringtype: bug reportBug report

Description

@DeniseApollo
DeniseApollo
opened on Jul 23, 2025
Issue body actions

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

Reacted by Simon DeMartini and Christian Gati

Activity

  1. DeniseApollo
    added
    type: bug fixBug fix
    on Jul 23, 2025
  2. PerfectSlayer
    added
    comp: databaseDatabase Monitoring
    on Jul 24, 2025
  3. na-ji commented on Dec 3, 2025

    @na-ji
    na-ji
    on Dec 3, 2025
    Member
    More actions

    Hi @DeniseApollo,

    This feature is now available in the version 1.56.0 thank to #9798 (and #9915).
    To use it, you need to set the environment variable DD_DBM_ALWAYS_APPEND_SQL_COMMENT to true.

    Thank you.

    Reacted by DeniseU
    Reacted by DeniseU
  4. na-ji
    closed this as completedon Dec 3, 2025
  5. PerfectSlayer
    added
    type: bug reportBug report
    and removed
    type: bug fixBug fix
    on Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    comp: databaseDatabase Monitoringtype: bug reportBug report

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.