OpenTelemetry Semantic Conventions
Semantic conventions define standard names and values for attributes on resources and spans. They ensure consistent attribute naming across instrumentation libraries, SDKs, and backends.
Stability Levels
Level Meaning Stable Frozen; no breaking changes Experimental May change; opt-in via schema_url Deprecated Will be removed
Resource Attributes
Resources represent the entity producing telemetry (service, container, host, cloud, etc.).
Service
Attribute Type Description Example service.namestring Required. Logical name of the service"auth-service"service.namespacestring Namespace grouping services "payments"service.versionstring Version of the service "1.3.0"service.instance.idstring Unique instance ID "instance-12"service.language.namestring Language/runtime "java", "python"
Container
Attribute Type Description container.namestring Container name container.idstring Container runtime ID container.image.namestring Image name container.image.tagstring Image tag container.runtimestring Runtime (docker, containerd, etc.) container.commandstring Command run in container
Kubernetes
Attribute Type Description k8s.namespace.namestring Namespace k8s.pod.namestring Pod name k8s.pod.uidstring Pod UID k8s.deployment.namestring Deployment name k8s.statefulset.namestring StatefulSet name k8s.daemonset.namestring DaemonSet name k8s.job.namestring Job name k8s.cronjob.namestring CronJob name k8s.container.namestring Container name k8s.container.restart_countint Restart count k8s.node.namestring Node name k8s.node.uidstring Node UID
Cloud (AWS, GCP, Azure)
AWS:
Attribute Type Description cloud.providerstring Always "aws" cloud.account.idstring AWS Account ID cloud.regionstring Region cloud.availability_zonestring AZ cloud.platformstring "aws_ec2", "aws_ecs", "aws_eks"aws.ec2.instance.idstring EC2 instance ID aws.ecs.cluster.arnstring ECS cluster ARN aws.ecs.service.namestring ECS service name aws.eks.cluster.arnstring EKS cluster ARN
GCP:
Attribute Type Description cloud.providerstring Always "gcp" cloud.account.idstring Project ID cloud.regionstring Region cloud.platformstring "gcp_gce", "gcp_gke", "gcp_cloud_run"gcp.gce.instance.namestring GCE instance name gcp.gke.cluster.namestring GKE cluster name
Azure:
Attribute Type Description cloud.providerstring Always "azure" cloud.account.idstring Subscription ID cloud.regionstring Region cloud.platformstring "azure_vm", "azure_container_instances", "azure_aks"azure.vm.namestring VM name azure.aks.cluster.namestring AKS cluster name
Host
Attribute Type Description host.namestring Hostname host.idstring Host ID (machine UUID) host.typestring Machine type host.archstring Architecture host.image.namestring VM image name host.image.idstring VM image ID
OS
Attribute Type Description os.typestring "linux", "windows", "darwin"os.namestring OS name os.versionstring OS version os.descriptionstring Full OS description
Telemetry SDK
Attribute Type Description telemetry.sdk.namestring Always "opentelemetry" telemetry.sdk.versionstring OTel SDK version telemetry.sdk.languagestring "python", "java", "go"
Span Attributes
General HTTP
Attribute Type Description Example http.request.methodstring HTTP method "GET", "POST"http.response.status_codeint HTTP status code 200, 404, 500http.urlstring Full URL https://api.example.com/usershttp.schemestring "http" or "https"http.hoststring Host header "api.example.com"http.targetstring Path + query "/users?id=42"http.user_agentstring User-Agent header http.request_content_lengthint Request body size http.response_content_lengthint Response body size
Specific HTTP
Attribute Type Description http.server_namestring Server name (virtual) http.routestring Matched route pattern http.client_ipstring Client IP address
Database
Attribute Type Description Example db.systemstring Database type "postgresql", "redis"db.namestring Database name "orders_db"db.statementstring Query statement "SELECT * FROM orders"db.operationstring Operation name "SELECT", "INSERT"db.sql.tablestring Table name "orders"db.userstring Username "app_user"db.connection_stringstring Connection string db.cursor.namestring Cursor name db.lock_timeoutint Lock timeout (ms) db.transaction_idstring Transaction ID
RPC (gRPC)
Attribute Type Description Example rpc.systemstring "grpc", "jsonrpc", "connect"rpc.servicestring Full service name "grpc.health.v1.Health"rpc.methodstring Method name "Check"rpc.request.rpc_namestring RPC name (alias for service+method) rpc.request.status_codeint gRPC status code rpc.grpc.status_codeint Numeric gRPC status
Messaging
Attribute Type Description Example messaging.systemstring System "kafka", "rabbitmq", "sqs"messaging.destinationstring Queue/topic name "orders"messaging.operationstring "publish", "receive", "process"messaging.message_idstring Message ID messaging.conversation_idstring Conversation/session ID messaging.message.payload_size_bytesint Payload size messaging.destination_kindstring "queue" or "topic"
FaaS (Serverless)
Attribute Type Description faas.namestring Function name faas.versionstring Function version faas.instancestring Function instance ID faas.invocation_idstring Invocation/request ID faas.triggerstring Trigger type
Events
Attribute Type Description event.namestring Event name event.idstring Event ID event.domainstring "domain" (e.g., "browser")
Exceptions
Attribute Type Description exception.typestring Exception type exception.messagestring Exception message exception.stacktracestring Full stack trace exception.escapedbool Whether exception escaped the span
Network Attributes
Attribute Type Description Example network.transportstring "tcp", "udp", "pipe"network.protocolstring Protocol name "http", "amqp"network.protocol_versionstring Protocol version "1.2"network.typestring "ipv4", "ipv6"network.local.addressstring Local address "10.0.0.1"network.local.portint Local port 8080network.remote.addressstring Remote address "54.23.0.1"network.remote.portint Remote port 443
User-Agent
Parsed from http.user_agent:
Attribute Type Description user_agent.originalstring Full User-Agent string user_agent.namestring Browser name user_agent.versionstring Browser version user_agent.os.namestring OS name user_agent.os.versionstring OS version user_agent.device.archstring Device architecture
URL Attributes
Attribute Type Description url.schemestring Scheme (http, https) url.domainstring Domain name url.portint Port url.pathstring Path url.querystring Query string url.fragmentstring Fragment
Example: Setting Resource Attributes
Go
import " go.opentelemetry.io/otel/sdk/resource "
res, err := resource. New (ctx,
resource. WithAttributes (
attribute. String ( "service.name" , "auth-service" ),
attribute. String ( "service.version" , "1.2.3" ),
attribute. String ( "deployment.environment" , "production" ),
attribute. String ( "cloud.region" , "us-east-1" ),
attribute. String ( "cloud.provider" , "aws" ),
),
resource. WithHost (),
resource. WithOS (),
resource. WithContainer (),
)
tp := trace. NewTracerProvider (trace. WithResource (res))
Python
from opentelemetry.sdk.resources import Resource, SERVICE_NAME , SERVICE_VERSION
resource = Resource.create({
SERVICE_NAME : "auth-service" ,
SERVICE_VERSION : "1.2.3" ,
"deployment.environment" : "production" ,
"cloud.region" : "us-east-1" ,
"cloud.provider" : "aws" ,
})
provider = TracerProvider( resource = resource)
Kubernetes (via Collector k8sattributes processor)
processors :
k8sattributes :
extract :
metadata :
- k8s.namespace.name
- k8s.deployment.name
- k8s.pod.name
- k8s.container.name
Convention Compatibility
OTel spec versions map to schema URLs:
Spec Version Schema URL v1.23.0+ https://opentelemetry.io/schemas/1.23.0v1.22.0+ https://opentelemetry.io/schemas/1.22.0Older No schema URL or v1.21.0
SDKs and instrumentation libraries include the schema URL in exports so backends can parse correctly.