Closed daniel-johns-99 closed 3 weeks ago
Hi, could you share a code snippet how you pass the tags object to the metrics functions?
The following snippet add tags from an object.
const moreTags = { appName: "Test" };
const myTags = { browser: "Firefox", app_version: "1.0.0" };
Sentry.metrics.increment("button_click", 1, {
tags: {
...moreTags,
...myTags,
},
});
This won't work (result will be [Object object]
):
const myTags = { browser: "Firefox", app_version: "1.0.0" };
Sentry.metrics.increment("button_click", 1, {
tags: {
myTags,
},
});
In case the previous responses have not solved the issue, please feel free to comment here or open a new issue.
Hi @krystofwoldrich,
You are correct
const myTags = { browser: "Firefox", app_version: "1.0.0" };
Sentry.metrics.increment("button_click", 1, {
tags: {
myTags,
},
});
Does not work and it would be nice to work so this is a feature request to flatten a JSON object.
I mentioned this works on Python: https://github.com/getsentry/sentry-python/blob/master/sentry_sdk/metrics.py#L692
The SDK develop page mentions that if the SDK has a way to support sending non-string values it can be sent https://develop.sentry.dev/sdk/metrics/#aggregator-behavior and being able to flatten a JSON object to key value should be achievable.
@krystofwoldrich Could we reopen? Its not solved yet.
Currently if you send a JSON object as a tag to Sentry Metrics, it appears on sentry as [Object object].
It would be nice to flatten the tag so that all values of the object are sent as individual tags.
The Python SDK does this already https://github.com/getsentry/sentry-python/blob/master/sentry_sdk/metrics.py#L692