Semantic Conventions
Reserved span attributes that can show up on the platform in different ways
Last updated
Reserved span attributes that can show up on the platform in different ways
Last updated
Copyright © 2023 Arize AI, Inc
Semantic Convention Link: https://github.com/Arize-ai/openinference/blob/main/spec/semantic_conventions.md
When sending traces, you may want to set your own custom attributes on each span. Semantic conventions are special attribute keys or values that may take on special meaning. In Arize, certain attribute keys are displayed in more prominent ways, in addition to showing up the in the attributes tab like keys.
Span
Message
Document
Reranker
Embedding
Tool Call
For a complete guide to Python semantic conventions, refer to the following resource on GitHub: OpenInference Python Semantic Conventions.
You can also see example values for each attribute below. and our Readme for our semantic conventions.
Attribute | Type | Example | Description |
---|---|---|---|
| String |
| The content of a retrieved document |
| String/Integer |
| Unique identifier for a document |
| JSON String |
| Metadata associated with a document |
| Float |
| Score representing the relevance of a document |
| List of objects† |
| List of embedding objects including text and vector data |
| String |
| Name of the embedding model used |
| String |
| The text represented in the embedding |
| List of floats |
| The embedding vector consisting of a list of floats |
| Boolean |
| Indicator if the exception has escaped the span's scope |
| String |
| Detailed message describing the exception |
| String |
| The stack trace of the exception |
| String |
| The type of exception that was thrown |
| String |
| MIME type representing the format of |
| String |
| The input value to an operation |
| JSON String |
| Object recording details of a function call in models or APIs |
| List of objects† |
| List of messages sent to the LLM in a chat API request |
| JSON string |
| Parameters used during the invocation of an LLM or API |
| String |
| The name of the language model being utilized |
| List of objects† |
| List of messages received from the LLM in a chat API request |
| String |
| Template used to generate prompts as Python f-strings |
| JSON String |
| JSON of key value pairs applied to the prompt template |
| String |
| The version of the prompt template |
| Integer |
| The number of tokens in the completion |
| Integer |
| The number of tokens in the prompt |
| Integer |
| Total number of tokens, including prompt and completion |
| String |
| The content of a message in a chat |
| JSON String |
| The arguments to the function call in JSON |
| String |
| Function call function name |
| String |
| Role of the entity in a message (e.g., user, system) |
| List of objects† |
| List of tool calls (e.g. function calls) generated by the LLM |
| JSON String |
| Metadata associated with a span |
| String |
| The kind of span (e.g., |
| String |
| MIME type representing the format of |
| String |
| The output value of an operation |
| List of objects† |
| List of documents as input to the reranker |
| String |
| Model name of the reranker |
| List of objects† |
| List of documents outputted by the reranker |
| String |
| Query parameter of the reranker |
| Integer | 3 | Top K parameter of the reranker |
| List of objects† |
| List of retrieved documents |
| String |
| Unique identifier for a session |
| List of strings | ["shopping", "travel"] | List of tags to give the span a category |
| String |
| Description of the tool's purpose and functionality |
| String |
| The name of the tool being utilized |
| JSON string |
| The parameters definition for invoking the tool |
| JSON string |
| The arguments for the function being invoked by a tool call |
| String |
| The name of the function being invoked by a tool call |
| String |
| Unique identifier for a user |
Here is an example implementation of a semantic convention. Simply treat them as a string when setting an attribute on a span:
To get a list of objects exported as OpenTelemetry span attributes, flattening of the list is necessary.
If the objects are further nested, flattening should continue until the attribute values are either simple values, i.e. bool
, str
, bytes
, int
, float
or simple lists, i.e. List[bool]
, List[str]
, List[bytes]
, List[int]
, List[float]
.
You can use the example code below to do so.
Adding Span Kind Attributes
Adding Input Attributes
Adding Output Attributes
Adding Tool Call Attributes