Span attributes are key-value pairs attached to a span that provide descriptive metadata about the operation it represents, such as HTTP method, URL, database query, or custom business data. They are the primary mechanism for enriching raw timing data with semantic context, transforming a simple duration measurement into a queryable, analyzable record. In standards like OpenTelemetry, attributes are defined with specific data types and are essential for filtering, aggregating, and diagnosing issues within distributed tracing systems.
Glossary
Span Attributes

What are Span Attributes?
Span attributes are the descriptive metadata attached to a span in a distributed trace, providing essential context about the operation it represents.
Attributes are categorized into two primary types: semantic conventions, which are standardized keys for common operations (e.g., http.method, db.system), and custom attributes for application-specific context (e.g., user.id, shopping_cart.total). They enable powerful analytics, such as calculating the p95 latency for all POST requests to a specific endpoint or identifying all traces where a particular error code occurred. Effective use of attributes is critical for achieving observability, allowing engineers to ask arbitrary questions about system behavior without pre-instrumenting specific metrics.
Key Characteristics of Span Attributes
Span attributes are key-value pairs attached to a span that provide descriptive metadata about the operation it represents. They are the primary mechanism for enriching traces with contextual, diagnostic, and business data.
Semantic Conventions
Semantic Conventions are standardized, pre-defined attribute keys and values established by the OpenTelemetry project to ensure consistency across instrumentation. They define common attributes for well-known operations, such as:
http.method: The HTTP request method (e.g.,GET,POST).db.system: The database management system (e.g.,postgresql,redis).rpc.service: The name of the RPC service being called. Using these conventions ensures traces from different libraries and services can be aggregated and queried uniformly, which is critical for automated analysis and dashboarding.
Attribute Value Types
Span attributes support a constrained set of primitive value types to ensure efficient serialization, storage, and querying. The allowed types are:
- String: For textual data (e.g.,
user.id="abc123"). - Integer: For whole numbers (e.g.,
http.status_code=404). - Double: For floating-point numbers (e.g.,
duration.ms=152.7). - Boolean: For true/false values (e.g.,
error=true). - Array of primitives: For lists of uniform values (e.g.,
http.request.header="["content-type", "authorization"]"). Complex objects must be flattened into key-value pairs or serialized as a string.
Cardinality and Cost
Attribute cardinality—the number of unique key-value combinations—directly impacts storage cost and query performance. High-cardinality attributes, like unique user IDs or request IDs, can cause exponential data growth. Best practices include:
- Using low-cardinality attributes for grouping and filtering (e.g.,
service.name,deployment.environment). - Being judicious with high-cardinality data; consider logging it separately or using span events.
- Implementing attribute limits in SDKs (e.g., OpenTelemetry's default limit of 128 attributes per span) to prevent accidental data explosions.
Enrichment Points
Attributes can be added at multiple stages in a trace's lifecycle, known as enrichment points:
- At Span Creation: Core attributes (e.g.,
http.method) are set by the auto-instrumentation or manual SDK call. - During Processing: Attributes can be added by an OpenTelemetry Collector using processors. For example, the
attributesprocessor can addcloud.region="us-east-1"to all spans. - In the Backend: Tracing backends can enrich spans at ingest time using contextual data (e.g., mapping a
service.nameto a team owner from a CMDB). This layered approach separates operational instrumentation from business context.
Business and Domain Context
Beyond technical metadata, attributes are the primary vector for injecting business context into observability data. This transforms generic traces into actionable, domain-specific insights. Examples include:
shopping.cart.id: To trace the performance of cart-related operations.payment.transaction.type: To segment traces by "refund" vs. "purchase".workflow.execution.id: To correlate all spans related to a specific long-running business process. This enables SREs and business analysts to answer questions like "What is the 95th percentile latency for checkout requests from premium users?"
Queryability and Analysis
The ultimate value of attributes is realized through queryability. In tracing backends like Jaeger, Tempo, or commercial APMs, attributes become the primary filter dimensions. Effective attribute design enables:
- Precise Filtering:
http.status_code=500 AND deployment.environment="prod" - Aggregation and Grouping: Group trace latency by
service.versionto validate a new release. - Statistical Analysis: Calculate error rates for specific
customer.tier. Poorly named or inconsistent attributes render traces unsearchable, negating their diagnostic value.
Common Span Attribute Examples by Category
A reference of typical key-value pairs attached to spans, categorized by their primary use case in observability and debugging.
| Attribute Category | Example Key | Example Value | Semantic Convention Source |
|---|---|---|---|
HTTP Request | http.method | "GET" | OpenTelemetry |
HTTP Request | http.url | OpenTelemetry | |
HTTP Request | http.status_code | 200 | OpenTelemetry |
Database Operation | db.system | "postgresql" | OpenTelemetry |
Database Operation | db.statement | "SELECT * FROM users WHERE id = ?" | OpenTelemetry |
Database Operation | db.operation | "find" | OpenTelemetry |
Messaging System | messaging.system | "kafka" | OpenTelemetry |
Messaging System | messaging.destination | "orders-topic" | OpenTelemetry |
Messaging System | messaging.operation | "publish" | OpenTelemetry |
Error & Status | error | OpenTelemetry | |
Error & Status | exception.type | "ValueError" | OpenTelemetry |
Error & Status | exception.message | "Invalid user ID provided" | OpenTelemetry |
Agentic Context | agent.workflow.id | "wf_order_fulfillment_abc123" | Custom |
Agentic Context | agent.decision.step | 3 | Custom |
Agentic Context | agent.tool.called | "sql_query_executor" | Custom |
Business Context | user.id | "user_789" | Custom |
Business Context | order.id | "order_456" | Custom |
Business Context | business.tier | "premium" | Custom |
Performance | process.runtime.memory.usage | 1542887424 | OpenTelemetry |
Performance | thread.name | "main" | OpenTelemetry |
How Span Attributes Work in Practice
Span attributes are the descriptive metadata that transform a raw timing measurement into a rich, queryable record of system behavior.
In practice, span attributes are key-value pairs attached to a span at instrumentation time. Common attributes include http.method, db.system, url.path, and custom business keys like user.id. These attributes are immutable after the span ends, ensuring a consistent historical record. They are the primary data used for filtering, aggregating, and diagnosing issues in trace analysis tools, making them the semantic core of a trace.
Attributes are typically set via the OpenTelemetry API using a span's set_attribute method. For efficiency, they should be added during the span's lifecycle, not after. Auto-instrumentation libraries automatically add standard attributes for common frameworks. In a trace pipeline, attributes can be further enriched or filtered by an OpenTelemetry Collector before being exported to a backend for storage and analysis, enabling centralized governance of telemetry semantics.
Frequently Asked Questions
Span attributes are the descriptive metadata that make distributed traces actionable. This FAQ addresses common questions about their purpose, structure, and best practices for SREs and DevOps engineers implementing observability.
Span attributes are key-value pairs of metadata attached to a span that describe the specific operation it represents. They provide the contextual details necessary to understand what happened during the execution of a service, such as the HTTP method (http.method=GET), database query string (db.statement="SELECT * FROM users"), URL endpoint (http.url="/api/v1/orders"), error codes, or custom business data like a user ID or transaction amount. Unlike the structural data of a trace (IDs, timing, parent-child relationships), attributes supply the semantic content, turning a generic timing diagram into a rich, queryable record of system behavior for debugging and analysis.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Span attributes are a core component of distributed tracing. To fully understand their role, it's essential to know the related concepts that define, propagate, and visualize trace data.
Span
A span is the fundamental unit of work in distributed tracing, representing a named, timed operation for a contiguous segment of work within a service. It is the container to which span attributes are attached.
- Structure: Contains a start/end timestamp, operation name, and status.
- Purpose: Represents operations like a database query, an HTTP handler, or a function call.
- Relationship: Spans are nested to form parent-child relationships, creating a call graph. The attributes on a span provide the descriptive metadata for this unit of work.
Trace
A trace is a collection of spans that represents the end-to-end path of a single request as it propagates through a distributed system. It visualizes the causal relationships between spans.
- Graph Structure: Forms a directed acyclic graph (DAG) where spans are nodes.
- Correlation: All spans in a trace share a unique Trace ID.
- Context: The complete trace provides the macro-view; the span attributes on individual spans provide the micro-details necessary to understand each step's context (e.g.,
http.urlfor a client call,db.statementfor a query).
Span Context
Span context is the immutable, portable state that must be propagated across process boundaries to link spans together into a trace. It is distinct from the mutable span attributes.
- Core Components: Contains the Trace ID, Span ID, trace flags (e.g., sampling decision), and trace state.
- Propagation: This context is injected into carrier formats (like HTTP headers) and extracted by downstream services.
- Differentiation: While context is for correlation, attributes are for annotation. Context answers "which trace is this?"; attributes answer "what exactly happened in this operation?".
Instrumentation
Instrumentation is the process of adding observability code to an application to generate telemetry data like spans, metrics, and logs. It is how span attributes are created and attached.
- Methods: Can be manual (developer-added code) or automatic (via auto-instrumentation agents/SDKs).
- Attribute Creation: Instrumentation libraries automatically add standard attributes (e.g.,
http.method) and provide APIs for developers to add custom business attributes (e.g.,user.id). - Goal: To create meaningful, well-attributed spans without excessive manual coding overhead.
OpenTelemetry (OTel)
OpenTelemetry (OTel) is the vendor-neutral, open-source observability framework that provides standardized APIs, SDKs, and tools for generating and managing telemetry, including span attributes.
- Semantic Conventions: OTel defines standardized attribute names and values (e.g.,
http.status_code) to ensure consistency across different services and tracing backends. - API: Provides a uniform
set_attribute(key, value)method across all supported programming languages. - Ecosystem: As the de facto standard, using OTel ensures your span attributes are portable across different analysis tools (Jaeger, Zipkin, commercial APMs).
Trace Enrichment
Trace enrichment is the process of adding or modifying contextual metadata on spans after they are generated, often within a processing pipeline like the OpenTelemetry Collector. It works hand-in-hand with initial span attribute instrumentation.
- Use Case: Adding environment-level tags (e.g.,
deployment.environment=production), sensitive data redaction, or business context derived from other systems. - Separation of Concerns: Allows developers to instrument core application logic, while platform/SRE teams can add operational context post-hoc.
- Pipeline Stage: A common step in a trace pipeline before data is exported to a backend for storage and analysis.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us