When you send data to our Trace API, you can add custom attributes to spans. For example, you might decide to add attributes like
user.id in order to help you analyze your trace data.
Some expected attribute values cause our distributed tracing UI to display some specific trace properties and details. For example, if a span has an attribute with an
error. prefix, the UI displays that span with an error. For another example, a span with an attribute that has a
db. prefix will be displayed as a datastore span in the UI, and will have its datastore query highlighted.
Decorating your spans to show specific properties in our UI can help you:
- Better understand the structure of your trace data.
- More easily troubleshoot problems.
This table explains how to get spans sent to the Trace API to show up with specific properties in the UI. For property descriptions, see span properties.
For more on how these span properties are determined and stored, see Trace structure.
Tips for adding attributes:
- You can add any attribute to a span. For example: you might add an attribute like
customer.idso that you could search traces globally for traces containing a specific customer.
- A span can be in multiple categories. For example,
externalis a more general category than is
datastore, so if a span is classified as both
datastore, it will be indicated as a datastore span in the UI.
Here are JSON examples showing how to use attributes to set span properties: