Skip to content

Commit

Permalink
feat(semcov): add metadata (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeldking committed Feb 8, 2024
1 parent c12c19c commit 8edb011
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
5 changes: 5 additions & 0 deletions js/.changeset/cuddly-shoes-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@arizeai/openinference-semantic-conventions": minor
---

Add metadata and tag semantic conventions
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export const SemanticAttributePrefixes = {
embedding: "embedding",
tool: "tool",
tool_call: "tool_call",
metadata: "metadata",
tag: "tag",
openinference: "openinference",
} as const;

Expand Down Expand Up @@ -78,6 +80,10 @@ export const DocumentAttributePostfixes = {
metadata: "metadata",
} as const;

export const TagAttributePostfixes = {
tags: "tags",
} as const;

/**
* The input to any span
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ class SpanAttributes:

RETRIEVAL_DOCUMENTS = "retrieval.documents"

METADATA = "metadata"
"""
Metadata attributes are used to store user-defined key-value pairs.
For example, LangChain uses metadata to store user-defined attributes for a chain.
"""

TAG_TAGS = "tag.tags"
"""
Custom categorical tags for the span.
"""

OPENINFERENCE_SPAN_KIND = "openinference.span.kind"


Expand Down
4 changes: 3 additions & 1 deletion spec/semantic_conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ operations used by applications. These conventions are used to populate the `att
The following attributes are reserved and MUST be supported by all OpenInference Tracing SDKs:

| Attribute | Type | Example | Description |
|----------------------------------------|-----------------|----------------------------------------------------------------------------|------------------------------------------------------------------|
| -------------------------------------- | --------------- | -------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| `openinference.span.kind` | String | `"CHAIN"` | The kind of span (e.g., `CHAIN`, `LLM`, `RETRIEVER`, `RERANKER`) |
| `exception.type` | String | `"NullPointerException"` | The type of exception that was thrown |
| `exception.message` | String | `"Null value encountered"` | Detailed message describing the exception |
Expand Down Expand Up @@ -53,5 +53,7 @@ The following attributes are reserved and MUST be supported by all OpenInference
| `reranker.query` | String | `"How to format timestamp?"` | Query parameter of the reranker |
| `reranker.model_name` | String | `"cross-encoder/ms-marco-MiniLM-L-12-v2"` | Model name of the reranker |
| `reranker.top_k` | Integer | 3 | Top K parameter of the reranker |
| `tag.tags` | List of strings | ["shopping", "travel"] | List of tags to give the span a category |
| `metadata.*` | Any | Any OTEL-compatible value | User-defined metadata for a chain or other span kind |

Note: the `object` type refers to a set of key-value pairs also known as a `struct`, `mapping`, `dictionary`, etc.

0 comments on commit 8edb011

Please sign in to comment.