Overview
Tags are string identifiers that you can attach to spans. They are used to categorize and filter spans. You can either add tags to a span when it is created, or post-hoc after a span has been created.1. Adding tags to a span when it is created
Sometimes you have some context prior to running a function and you want to tag it at creation time. For example, you may want to tag a span with the model provider endpoint that you use, or the test dataset that you used to run the request. Note that tags are not the same as metadata. Metadata is additional information about a trace in a form of key-value pairs. Tags are used to categorize and filter spans, and they must be created in the Laminar UI in advance. See metadata for a more detailed comparison.Example. Tagging a manual span
This is a dynamic way to tag a span, i.e. you can create tags at runtime.Laminar.startSpan
call will have the tags.Example. Tagging an observe
d function
This is a static way to tag a span, i.e. the observe
d function will always have the same set of tags.
Example. Tagging any span from within its context
Note that for adding span tags to work, you must call it inside a span context. This is why we useobserve
here.
2. Adding tags to a span once it is created
This is useful to incorporate user feedback into the trace for further analysis.2.1. Tagging in the Laminar UI
Once you’ve created and sent a trace to Laminar, you can add tags to the spans in the Laminar UI.
2.2. Tagging in the Laminar SDK
You can also add tags to a span in the Laminar SDK. You will need to save the trace ID and then add tags to the root span of that trace usingLaminarClient.tags.tag
.
Make sure to call
Laminar.getTraceId
inside a span context, e.g.
inside an observe
d function. Otherwise, it will return null
.Viewing tags
The tags will be visible in the Laminar UI, shown on each span as shields.
Filtering by span tags
In the traces view and the spans view, you can filter by span tags. Simply add a “Tags” filter and type the name of the tag you want to include.
