Labeling from code
How to label spans from code
Sometimes you have some context prior to running a function and you want to label 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 labels are not the same as metadata. Metadata is additional information about a trace in a form of key-value pairs. Labels 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.
Label spans from code
This functionality is available from v0.5.0
.
Example 1. Labeling a span created with automatic instrumentation
Note that any spans created within the with_labels
block will inherit the labels,
including auto-instrumented spans or any calls to observe
d functions.
Example 2. Labeling a span created manually
Note that only the span created by this Laminar.start_as_current_span
call will have the labels.
This functionality is available from v0.5.0
.
Example 1. Labeling a span created with automatic instrumentation
Note that any spans created within the with_labels
block will inherit the labels,
including auto-instrumented spans or any calls to observe
d functions.
Example 2. Labeling a span created manually
Note that only the span created by this Laminar.start_as_current_span
call will have the labels.
This functionality is available from v0.5.0
.
Example 1. Labeling a span created with automatic instrumentation
Note that any spans created within the withLabels
function will inherit the labels,
including auto-instrumented spans or any calls to observe
d functions.
Example 2. Labeling a span created manually
Note that only the span created by this Laminar.startSpan
call will have the labels.
Every label must have a string key and a string value. They must exactly match the name and possible values of the label class.
3. Viewing labels
The labels will be visible in the Laminar UI, shown on each span as shields.