Skip to content

Commit

Permalink
[Datadog] Fix Graphql tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
damassi committed Jun 3, 2020
1 parent 8891510 commit 172e35a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/lib/datadog.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import ddTracer from "dd-trace"
import { Request } from "express"
import url from "url"

if (process.env.DD_APM_ENABLED) {
ddTracer.init({
Expand All @@ -10,6 +12,19 @@ if (process.env.DD_APM_ENABLED) {
// We want the root spans of MP to be labelled as just `service`
service: "force",
headers: ["User-Agent"],
// See: https://github.com/DataDog/dd-trace-js/issues/477#issuecomment-470299277
// @ts-ignore
hooks: {
request: (span, req: Request) => {
if (req.route.path.includes("*")) {
span.setTag(
"http.route",
// Remove query string, fragment and trailing slash
url.parse(req.originalUrl).pathname.replace(/\/$/, "")
)
}
},
},
})
ddTracer.use("http", {
service: `force.http-client`,
Expand Down

0 comments on commit 172e35a

Please sign in to comment.