OpenTelemetry semantic conventions explained
A semantic dictionary is the agreement on what each piece of your telemetry is called and what it means. In OpenTelemetry that dictionary exists, it is public, and it is called semantic conventions. This guide explains how it is organized, which names changed, and how to add your own terms without breaking anything.
The problem it solves
Three teams record the response code of an HTTP request. One calls it status, another http_code and the third response.status. All three say the same thing, but no query, dashboard or alert works for all three at once.
With a shared dictionary, all three write http.response.status_code. One query covers every service, and any platform that knows the dictionary understands, without anyone explaining it, that this number is an HTTP code and that 500 is an error.
That is what semantic conventions are. They are not a format or a protocol. They are agreed names and meanings. And they are what makes telemetry truly portable: OTLP carries the data from one place to another, but conventions are what let you understand it when it arrives.
What the dictionary defines
- Attribute names, grouped by topic with a prefix:
http.*,db.*,k8s.*,messaging.*,gen_ai.*. - The type and the allowed values.
http.request.methodis a string and can beGET,POSTand the other known methods. - Metric names and units.
http.server.request.durationis measured in seconds, not milliseconds. - How a span is named and which attributes are required, recommended or optional in each case.
Two places an attribute can live
Resource attributes describe who is emitting: the service, the host, the pod. They are declared once and go along with everything that process sends. Data attributes describe what happened: this request, this query, this message.
- Resource:
service.name,service.version,deployment.environment.name,host.name,k8s.namespace.name,k8s.pod.name. - Data:
http.request.method,http.route,http.response.status_code,db.system.name,db.query.text,error.type.
Stable or in development
Each group in the dictionary has a maturity level. Stable ones don't change names, so you can build dashboards and alerts on them without worry. Ones that are in development can change between versions.
Today the HTTP and database conventions, among others, are stable. Messaging and generative AI (gen_ai.*) are still in development. You can use them, but note which version each library works with.
The names that changed
When several groups became stable, they changed names. If your services use libraries from different eras, you very likely have both sets of names living side by side, and half of your queries don't see the other half of the data.
| Old name | Current name |
|---|---|
http.method | http.request.method |
http.status_code | http.response.status_code |
http.url | url.full |
http.target | url.path and url.query |
net.peer.name | server.address |
net.peer.port | server.port |
db.system | db.system.name |
db.statement | db.query.text |
db.name | db.namespace |
deployment.environment | deployment.environment.name |
Instrumentation libraries offer an orderly transition with the OTEL_SEMCONV_STABILITY_OPT_IN variable. With the value http they emit only the current HTTP names. With http/dup they emit both sets at once, so you can migrate dashboards and alerts without a cutover. For databases the values are database and database/dup.
Normalize in the Collector
When you can't update an application, the Collector can translate old names on the way through. That way everything reaches the destination speaking the same language:
processors:
transform/semconv:
error_mode: ignore
trace_statements:
- context: span
statements:
# copies to the current name only if it doesn't exist yet, and deletes the old one
- set(attributes["http.request.method"], attributes["http.method"]) where attributes["http.request.method"] == nil and attributes["http.method"] != nil
- delete_key(attributes, "http.method")
- set(attributes["http.response.status_code"], attributes["http.status_code"]) where attributes["http.response.status_code"] == nil and attributes["http.status_code"] != nil
- delete_key(attributes, "http.status_code")
- set(attributes["db.system.name"], attributes["db.system"]) where attributes["db.system.name"] == nil and attributes["db.system"] != nil
- delete_key(attributes, "db.system")
- context: resource
statements:
- set(attributes["deployment.environment.name"], attributes["deployment.environment"]) where attributes["deployment.environment.name"] == nil and attributes["deployment.environment"] != nil
- delete_key(attributes, "deployment.environment")The == nil condition matters: if the application already sends the current name, it is not overwritten.
Your own dictionary
The conventions cover the technical side. What is specific to your business (a policy number, a sales channel, a customer type) is yours to define, and it is worth doing with the same rules:
- Use your own prefix, with your company or domain name:
acme.policy.id,acme.channel. Don't use OpenTelemetry's prefixes for your own attributes: a future version may define that same name with a different meaning. - One concept, one name. If
acme.customer.typealready exists, nobody createsacme.customer_type. - Write down the type, the values and an example. "String; one of
web,apporbranch" keepsWeb,WEBandonlinefrom showing up. - Lowercase, dots to separate levels, underscores inside a compound word. Same as the official dictionary.
- Keep it where the team can see it, in a repository and with review, like code.
The OpenTelemetry project publishes a tool, Weaver, to write your own dictionary in the same format as the official one, validate it and generate constants for your code from it.
Common mistakes
- Inventing a name for something that already has one. Before creating an attribute, search the official dictionary.
- Mixing old and current names without knowing it. It is the most common cause of dashboards that show less traffic than the real amount.
- Different units for the same metric. A duration in milliseconds next to another in seconds gives meaningless averages.
- Free-form values where there is a list.
production,prodandPRODare three environments to any query. - Putting the identifier inside the name. The attribute is
acme.customer.idwith the value4812, notacme.customer.4812.
With OneGlass
OneGlass is an OpenTelemetry-native observability platform, made in Argentina. It uses semantic conventions to build the topology and relate signals to each other, so with standard names you get more without configuring anything. The Settings › Semantic conventions screen shows how closely the telemetry you send follows them.