Using Tags

Introduction

Tags enable visualization and breakdown of operations, metrics, and resources. Tags can represent application versions, A/B test targets, departments, user IDs, session IDs, and so on. When auto-tracing APIs and libraries, Graphsignal automatically adds the following tags: project, model, operation, endpoint, and others depending on the library.

Adding tags

See the Quick Start for instructions on installing and configuring the Graphsignal tracer.

Python

Set a tag at application level:

graphsignal.configure(api_key='my-api-key', tags={'my_app_version', '1.0'})
graphsignal.set_tag('my_app_version', '1.0')

Set a tag on every request, e.g. in a request handler. This will set a Python contextvar and will be picked up by all traces of the current context.

graphsignal.set_context_tag('user_id', current_user_id)

You can also set tags directly, when tracing manually:

with graphsignal.trace('generate', tags=dict(user_id=my_user_id)):
    ...
CLI

When adding Graphsignal at command line, you can set tags in an environment variable.

env GRAPHSIGNAL_TAG_APP_VERSION="1.0" python -m graphsignal <script>