Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flatten Metrics Tags for Objects #3789

Closed
daniel-johns-99 opened this issue Apr 29, 2024 · 4 comments
Closed

Flatten Metrics Tags for Objects #3789

daniel-johns-99 opened this issue Apr 29, 2024 · 4 comments

Comments

@daniel-johns-99
Copy link

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

@krystofwoldrich
Copy link
Member

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,
  },
});

@krystofwoldrich
Copy link
Member

In case the previous responses have not solved the issue, please feel free to comment here or open a new issue.

@daniel-johns-99
Copy link
Author

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.

@daniel-johns-99
Copy link
Author

@krystofwoldrich Could we reopen? Its not solved yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Archived in project
Development

No branches or pull requests

2 participants