Skip to content

Commit d3ef34e

Browse files
authored
chore(graphql): only stringify graphql error extension attributes in span event if not a native type (#5212)
* only stringify graphql error extension value if the value is not a number or bool * fix reviewer comments
1 parent ca855f8 commit d3ef34e

File tree

1 file changed

+8
-1
lines changed
  • packages/datadog-plugin-graphql/src

1 file changed

+8
-1
lines changed

packages/datadog-plugin-graphql/src/utils.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,14 @@ function extractErrorIntoSpanEvent (config, span, exc) {
2727
if (config.graphqlErrorExtensions) {
2828
for (const ext of config.graphqlErrorExtensions) {
2929
if (exc.extensions?.[ext]) {
30-
attributes[`extensions.${ext}`] = exc.extensions[ext].toString()
30+
const value = exc.extensions[ext]
31+
32+
// We should only stringify the value if it is not of type number or boolean
33+
if (typeof value === 'number' || typeof value === 'boolean') {
34+
attributes[`extensions.${ext}`] = value
35+
} else {
36+
attributes[`extensions.${ext}`] = String(value)
37+
}
3138
}
3239
}
3340
}

0 commit comments

Comments
 (0)