From 8edb011412de3ef238c6f8f96aee1682bed535ad Mon Sep 17 00:00:00 2001 From: Mikyo King Date: Wed, 7 Feb 2024 17:20:30 -0700 Subject: [PATCH] feat(semcov): add metadata (#179) --- js/.changeset/cuddly-shoes-beg.md | 5 +++++ .../src/trace/SemanticConventions.ts | 6 ++++++ .../src/openinference/semconv/trace/__init__.py | 11 +++++++++++ spec/semantic_conventions.md | 4 +++- 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 js/.changeset/cuddly-shoes-beg.md diff --git a/js/.changeset/cuddly-shoes-beg.md b/js/.changeset/cuddly-shoes-beg.md new file mode 100644 index 000000000..9de0729b1 --- /dev/null +++ b/js/.changeset/cuddly-shoes-beg.md @@ -0,0 +1,5 @@ +--- +"@arizeai/openinference-semantic-conventions": minor +--- + +Add metadata and tag semantic conventions diff --git a/js/packages/openinference-semantic-conventions/src/trace/SemanticConventions.ts b/js/packages/openinference-semantic-conventions/src/trace/SemanticConventions.ts index 82f6f7fb4..a3a465f63 100644 --- a/js/packages/openinference-semantic-conventions/src/trace/SemanticConventions.ts +++ b/js/packages/openinference-semantic-conventions/src/trace/SemanticConventions.ts @@ -14,6 +14,8 @@ export const SemanticAttributePrefixes = { embedding: "embedding", tool: "tool", tool_call: "tool_call", + metadata: "metadata", + tag: "tag", openinference: "openinference", } as const; @@ -78,6 +80,10 @@ export const DocumentAttributePostfixes = { metadata: "metadata", } as const; +export const TagAttributePostfixes = { + tags: "tags", +} as const; + /** * The input to any span */ diff --git a/python/openinference-semantic-conventions/src/openinference/semconv/trace/__init__.py b/python/openinference-semantic-conventions/src/openinference/semconv/trace/__init__.py index b0ce2d7de..1918b85d6 100644 --- a/python/openinference-semantic-conventions/src/openinference/semconv/trace/__init__.py +++ b/python/openinference-semantic-conventions/src/openinference/semconv/trace/__init__.py @@ -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" diff --git a/spec/semantic_conventions.md b/spec/semantic_conventions.md index 9410f7d98..67d32efdb 100644 --- a/spec/semantic_conventions.md +++ b/spec/semantic_conventions.md @@ -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 | @@ -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.