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

LevelMeaning
StableFrozen; no breaking changes
ExperimentalMay change; opt-in via schema_url
DeprecatedWill be removed

Resource Attributes

Resources represent the entity producing telemetry (service, container, host, cloud, etc.).

Service

AttributeTypeDescriptionExample
service.namestringRequired. Logical name of the service"auth-service"
service.namespacestringNamespace grouping services"payments"
service.versionstringVersion of the service"1.3.0"
service.instance.idstringUnique instance ID"instance-12"
service.language.namestringLanguage/runtime"java", "python"

Container

AttributeTypeDescription
container.namestringContainer name
container.idstringContainer runtime ID
container.image.namestringImage name
container.image.tagstringImage tag
container.runtimestringRuntime (docker, containerd, etc.)
container.commandstringCommand run in container

Kubernetes

AttributeTypeDescription
k8s.namespace.namestringNamespace
k8s.pod.namestringPod name
k8s.pod.uidstringPod UID
k8s.deployment.namestringDeployment name
k8s.statefulset.namestringStatefulSet name
k8s.daemonset.namestringDaemonSet name
k8s.job.namestringJob name
k8s.cronjob.namestringCronJob name
k8s.container.namestringContainer name
k8s.container.restart_countintRestart count
k8s.node.namestringNode name
k8s.node.uidstringNode UID

Cloud (AWS, GCP, Azure)

AWS:

AttributeTypeDescription
cloud.providerstringAlways "aws"
cloud.account.idstringAWS Account ID
cloud.regionstringRegion
cloud.availability_zonestringAZ
cloud.platformstring"aws_ec2", "aws_ecs", "aws_eks"
aws.ec2.instance.idstringEC2 instance ID
aws.ecs.cluster.arnstringECS cluster ARN
aws.ecs.service.namestringECS service name
aws.eks.cluster.arnstringEKS cluster ARN

GCP:

AttributeTypeDescription
cloud.providerstringAlways "gcp"
cloud.account.idstringProject ID
cloud.regionstringRegion
cloud.platformstring"gcp_gce", "gcp_gke", "gcp_cloud_run"
gcp.gce.instance.namestringGCE instance name
gcp.gke.cluster.namestringGKE cluster name

Azure:

AttributeTypeDescription
cloud.providerstringAlways "azure"
cloud.account.idstringSubscription ID
cloud.regionstringRegion
cloud.platformstring"azure_vm", "azure_container_instances", "azure_aks"
azure.vm.namestringVM name
azure.aks.cluster.namestringAKS cluster name

Host

AttributeTypeDescription
host.namestringHostname
host.idstringHost ID (machine UUID)
host.typestringMachine type
host.archstringArchitecture
host.image.namestringVM image name
host.image.idstringVM image ID

OS

AttributeTypeDescription
os.typestring"linux", "windows", "darwin"
os.namestringOS name
os.versionstringOS version
os.descriptionstringFull OS description

Telemetry SDK

AttributeTypeDescription
telemetry.sdk.namestringAlways "opentelemetry"
telemetry.sdk.versionstringOTel SDK version
telemetry.sdk.languagestring"python", "java", "go"

Span Attributes

General HTTP

AttributeTypeDescriptionExample
http.request.methodstringHTTP method"GET", "POST"
http.response.status_codeintHTTP status code200, 404, 500
http.urlstringFull URLhttps://api.example.com/users
http.schemestring"http" or "https"
http.hoststringHost header"api.example.com"
http.targetstringPath + query"/users?id=42"
http.user_agentstringUser-Agent header
http.request_content_lengthintRequest body size
http.response_content_lengthintResponse body size

Specific HTTP

AttributeTypeDescription
http.server_namestringServer name (virtual)
http.routestringMatched route pattern
http.client_ipstringClient IP address

Database

AttributeTypeDescriptionExample
db.systemstringDatabase type"postgresql", "redis"
db.namestringDatabase name"orders_db"
db.statementstringQuery statement"SELECT * FROM orders"
db.operationstringOperation name"SELECT", "INSERT"
db.sql.tablestringTable name"orders"
db.userstringUsername"app_user"
db.connection_stringstringConnection string
db.cursor.namestringCursor name
db.lock_timeoutintLock timeout (ms)
db.transaction_idstringTransaction ID

RPC (gRPC)

AttributeTypeDescriptionExample
rpc.systemstring"grpc", "jsonrpc", "connect"
rpc.servicestringFull service name"grpc.health.v1.Health"
rpc.methodstringMethod name"Check"
rpc.request.rpc_namestringRPC name (alias for service+method)
rpc.request.status_codeintgRPC status code
rpc.grpc.status_codeintNumeric gRPC status

Messaging

AttributeTypeDescriptionExample
messaging.systemstringSystem"kafka", "rabbitmq", "sqs"
messaging.destinationstringQueue/topic name"orders"
messaging.operationstring"publish", "receive", "process"
messaging.message_idstringMessage ID
messaging.conversation_idstringConversation/session ID
messaging.message.payload_size_bytesintPayload size
messaging.destination_kindstring"queue" or "topic"

FaaS (Serverless)

AttributeTypeDescription
faas.namestringFunction name
faas.versionstringFunction version
faas.instancestringFunction instance ID
faas.invocation_idstringInvocation/request ID
faas.triggerstringTrigger type

Events

AttributeTypeDescription
event.namestringEvent name
event.idstringEvent ID
event.domainstring"domain" (e.g., "browser")

Exceptions

AttributeTypeDescription
exception.typestringException type
exception.messagestringException message
exception.stacktracestringFull stack trace
exception.escapedboolWhether exception escaped the span

Network Attributes

AttributeTypeDescriptionExample
network.transportstring"tcp", "udp", "pipe"
network.protocolstringProtocol name"http", "amqp"
network.protocol_versionstringProtocol version"1.2"
network.typestring"ipv4", "ipv6"
network.local.addressstringLocal address"10.0.0.1"
network.local.portintLocal port8080
network.remote.addressstringRemote address"54.23.0.1"
network.remote.portintRemote port443

User-Agent

Parsed from http.user_agent:

AttributeTypeDescription
user_agent.originalstringFull User-Agent string
user_agent.namestringBrowser name
user_agent.versionstringBrowser version
user_agent.os.namestringOS name
user_agent.os.versionstringOS version
user_agent.device.archstringDevice architecture

URL Attributes

AttributeTypeDescription
url.schemestringScheme (http, https)
url.domainstringDomain name
url.portintPort
url.pathstringPath
url.querystringQuery string
url.fragmentstringFragment

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 VersionSchema URL
v1.23.0+https://opentelemetry.io/schemas/1.23.0
v1.22.0+https://opentelemetry.io/schemas/1.22.0
OlderNo schema URL or v1.21.0

SDKs and instrumentation libraries include the schema URL in exports so backends can parse correctly.