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

rework tags #25

Open
willkg opened this issue Nov 11, 2017 · 2 comments
Open

rework tags #25

willkg opened this issue Nov 11, 2017 · 2 comments

Comments

@willkg
Copy link
Owner

willkg commented Nov 11, 2017

The Datadog and logging backends support tags, but the API for doing tags is a little weird and there's nothing that sanitizes tag keys and values.

This issue covers rethinking that a bit.

@willkg
Copy link
Owner Author

willkg commented Nov 11, 2017

Right now, Markus supports something like this:

metrics.incr('somekey', 1, tags=['key:val', 'key2:val'])

That format for tags is weird if we think of tags as always having a key and a value. Datadog doesn't require that, though.

The datadog backend has restrictions on keys and values:

Tags must start with a letter, and after that may contain alphanumerics, underscores, minuses, colons, periods and slashes. Other characters will get converted to underscores. Tags can be up to 200 characters long and support unicode. Tags will be converted to lowercase.

For optimal functionality, we recommend constructing tags that use the key:value syntax. Examples of commonly used metric tag keys are env, instance, name, and role. Note that device, host, and source are "reserved" tag keys and cannot be specified in the standard way.

We store one time series per host + metric + tag combination on our backend, thus we cannot support infinitely bounded tags. Please don't include endlessly growing tags in your metrics, like timestamps or user ids. Please limit each metric to 1000 tags.
(https://help.datadoghq.com/hc/en-us/articles/204312749-Getting-started-with-tags)

First, we should fix the Markus docs regarding tags to make those restrictions clearer.

After that, seems prudent to clean up tags somewhere.

Maybe Markus should clean up tags before sending them to backends? Then all backends get the same tags.

Maybe the backends themselves should clean up tags if they need to? Then we don't clean up tags that don't need cleaning up.

Maybe we do a bit of both?

Maybe we do a utility function that cleans up tags and takes either a list or a dict and returns a list of tags?

@willkg
Copy link
Owner Author

willkg commented Nov 13, 2017

I decided not to do anything backend specific or to add automatic tag generation to the .incr() and related functions. Instead I wrote a .generate_tag() utility function. That's in pr #26.

People can use this as they so desire. If they have other requirements, they can do that (hashing values is an interesting one). Seems like the most flexible and least intrusive first step. We can adjust as we go along and after people have used it.

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

No branches or pull requests

1 participant