Skip to content
This repository was archived by the owner on Aug 30, 2019. It is now read-only.
This repository was archived by the owner on Aug 30, 2019. It is now read-only.

cmd/trace-agent: resource replace rules get applied to "sql.query" tag too #462

Description

@mbyio

Moved from DataDog/dd-trace-go#274.

I work on a service that has to use complicated and varying WHERE expressions in its queries. There is no way to avoid this because, among other reasons, we have to use IN expressions with a varying number of arguments, and we can not convert the IN expressions into JOINs for performance reasons. This makes the Datadog APM UI harder to use because it results in a very high cardinality of resource names. The docs also indicate there is a hard limit to the allowed cardinality of a resource, and we don't want to lose data.

There are some things you could do automatically to try and group queries. But I think it might be better if you just let users customize it as an option, since there isn't really a way to cover every use case for every database. So, can you provide a hook so we can set our own function that normalizes resource names in queries? (And maybe you could provide a few examples that people can use if it fits their use case.)

Eg. I'd like to be able to write a function that automatically turns a query like this:

SELECT col1, col2, col3
FROM tablea JOIN tableb on tablea.col52 = tableb.col3
WHERE (tablea.col5 in (?, ?, ?, ?) AND tableb.col4 in (?, ?)) AND tablea.col76 = 5 AND tableb.col33 in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

into a query like SELECT col1, col2, col3 FROM tablea JOIN tableb ON tablea.col52 = tableb.col3 using a regular expression. Then the original query could be added as a tag so it can still be viewed for debugging.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ackIssue acknowledgedbug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions