# Semantic conventions

> Every OTLP attribute the Sypnia server SDKs set and the engine reads, with its type, when it is required and an example, and how server spans and browser events become one trace.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://telemetry.docs.sypnia.com/reference/semantic-conventions/

For agents: Read this to know exactly which OpenTelemetry and sypnia.* attributes a span needs for Sypnia (environment, release, route, session, person, account, partial requests, errors), and how the engine joins a browser request and server spans into one trace.

The server SDKs ([`@sypnia/telemetry/node`](https://telemetry.docs.sypnia.com/sdks/node), [`@sypnia/telemetry/next`](https://telemetry.docs.sypnia.com/sdks/nextjs)) and the bridge ([`@sypnia/telemetry/otel`](https://telemetry.docs.sypnia.com/sdks/otel-bridge)) send traces in the OpenTelemetry protocol: OTLP/HTTP, in protobuf, to [`POST /v1/otlp/v1/traces`](https://telemetry.docs.sypnia.com/api/otlp). Any other OpenTelemetry exporter can send to the same endpoint. This page lists the attributes that matter to Sypnia, for both kinds of sender. It is the same for the open-source engine and for Sypnia Cloud.

The rule behind it: **where OpenTelemetry has a name for something, Sypnia uses that name, as OpenTelemetry defines it.** A `sypnia.*` attribute exists only where OpenTelemetry has none: the account, the use case, a request exported before it ended, a database reached through an HTTP API, how an error was caught. There is no project attribute: the project comes from the ingest key, as for every other sender.

It is generated from `spec/otlp-conventions.yaml` in the docs repository. When this page and that file disagree, the file is right. The browser's own events are in the [event schema](https://telemetry.docs.sypnia.com/reference/event-schema).

> **In plain words**
>
> A trace is sent in a standard format that many tools understand. This page is the list of labels Sypnia reads on it, so the request someone made in the browser and the work your server did for it show up as one story.

## The attributes

«Sent by» says who sets the attribute: `SDK` is `@sypnia/telemetry/node` and `@sypnia/telemetry/next`, `bridge` is `@sypnia/telemetry/otel`, `any exporter` means the engine reads it from any OpenTelemetry sender that sets it.

### Resource attributes

Once per `ResourceSpans`: they describe the service that sent the spans.

| Name                          | Origin        | Type   | Required | Sent by                   | Meaning                                                                                                                                                                                                       | Example                  |
| ----------------------------- | ------------- | ------ | -------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------ |
| `service.name`                | OpenTelemetry | string | always   | SDK, bridge, any exporter | The service, as set in `init` (`service`). Up to 80 characters. The engine uses `unknown_service` when it is missing, as OpenTelemetry does.                                                                  | `shop-api`               |
| `deployment.environment.name` | OpenTelemetry | string | optional | SDK, bridge, any exporter | The environment, 1 to 40 characters. The older `deployment.environment` is read when this one is missing. `production` when both are missing. Counts toward the project's 20 environment names.               | `production`             |
| `service.version`             | OpenTelemetry | string | optional | SDK, bridge, any exporter | The release, up to 40 characters: the short git commit. It is how a problem can say «since yesterday's change» and how a server stack finds its source maps.                                                  | `4f2a91c`                |
| `telemetry.sdk.name`          | OpenTelemetry | string | optional | SDK, bridge, any exporter | Which library built the spans. The Sypnia SDKs write their package name; with the bridge it is OpenTelemetry's own value. Shown in `sypnia doctor` and in the ingest counters, never used to decide anything. | `@sypnia/telemetry/node` |
| `telemetry.sdk.version`       | OpenTelemetry | string | optional | SDK, bridge, any exporter | The version of that library.                                                                                                                                                                                  | `0.1.0`                  |

### The request your service received

On the span of kind `SPAN_KIND_SERVER` that a service opens for each request it handles. It is the root of that service's part of the trace.

| Name                        | Origin        | Type    | Required                                                                                                     | Sent by                   | Meaning                                                                                                                                                                                                                                                                                                                                                                                                            | Example                            |
| --------------------------- | ------------- | ------- | ------------------------------------------------------------------------------------------------------------ | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------- |
| `http.request.method`       | OpenTelemetry | string  | always                                                                                                       | SDK, bridge, any exporter | The HTTP method, upper case.                                                                                                                                                                                                                                                                                                                                                                                       | `POST`                             |
| `http.route`                | OpenTelemetry | string  | always                                                                                                       | SDK, bridge, any exporter | The route template: the path with ids replaced, `/orders/:id`. The SDK takes the framework's pattern when it can read it (Express, Fastify, the Next.js file route) and otherwise applies the same rule as the browser. A server span without it is stored, shown in its trace, and left out of Performance.                                                                                                       | `/api/checkout`                    |
| `url.path`                  | OpenTelemetry | string  | optional                                                                                                     | SDK, bridge, any exporter | The path that was called, up to 500 characters. Never the query string: the SDK never sends `url.query` or `url.full`, and the engine drops both.                                                                                                                                                                                                                                                                  | `/api/checkout`                    |
| `http.response.status_code` | OpenTelemetry | int     | when: The answer was sent. Missing on a partial span.                                                        | SDK, bridge, any exporter | The HTTP status the service answered. `500` or above makes the request a failure.                                                                                                                                                                                                                                                                                                                                  | `400`                              |
| `session.id`                | OpenTelemetry | string  | when: The request came from a page that runs the browser SDK.                                                | SDK, bridge               | The browser session, copied from the `x-sypnia-session` request header: 32 lowercase hex characters. It puts the request in that session's timeline and gives the trace the session's person. Any other value is dropped. Other exporters can set it the same way.                                                                                                                                                 | `8f3a6c1e9b2d4f07a5c3e1b8d6f4a2c0` |
| `user.id`                   | OpenTelemetry | string  | when: The app called `identify()` on the server during this request.                                         | SDK, bridge               | The person the request belongs to, the id given to `identify()`, up to 128 characters. Only the id: names and e-mail addresses are never sent as attributes. Without it the trace takes the person of its session.                                                                                                                                                                                                 | `u_1042`                           |
| `sypnia.account.id`         | Sypnia        | string  | when: `identify()` on the server named an account.                                                           | SDK, bridge               | The account the person belongs to in your app (a team, a company, a club), up to 128 characters. OpenTelemetry has no name for it.                                                                                                                                                                                                                                                                                 | `acc_77`                           |
| `sypnia.case`               | Sypnia        | string  | when: The request or job serves a use case. On a scheduled job or a listener, set it on the job's root span. | SDK, bridge, any exporter | The id of the use case this work serves, as it is on the map, up to 128 characters (`place-order`). Sypnorm and Sypnia Run set it for the cases they run; other code sets it with `setSpanAttributes()` of `@sypnia/telemetry` or the OpenTelemetry API. The trace takes the case of its first span that carries one. See [Use cases and places](https://telemetry.docs.sypnia.com/concepts/use-cases-and-places). | `place-order`                      |
| `sypnia.case.outcome`       | Sypnia        | string  | when: The span carries `sypnia.case` and the case ended.                                                     | SDK, bridge, any exporter | The name of the outcome or failure the case ended in, up to 80 characters (`OrderPlaced`, `OutOfStock`). A declared failure is counted as an outcome, not as an error. When the work throws before the case can end, it is `error` (Sypnorm and the Cases runtime set it); a span with `sypnia.case` and no outcome is counted as an error too.                                                                    | `OrderPlaced`                      |
| `faas.coldstart`            | OpenTelemetry | boolean | optional                                                                                                     | SDK, any exporter         | `true` on the first request of a new process: a cold start on serverless. Sent only when true.                                                                                                                                                                                                                                                                                                                     | `true`                             |
| `sypnia.partial`            | Sypnia        | boolean | when: The request was still running after `slowRequestMs` (20,000 ms by default).                            | SDK                       | This span was exported while the request was still running, with its end time set to the moment of export. If the request finishes, the SDK exports the same span id again without this attribute, and the full span replaces the partial one. If the platform kills the request, the partial span is what remains, and the engine reports it as a timeout.                                                        | `true`                             |
| `sypnia.dropped_spans`      | Sypnia        | int     | when: The request had more than 200 spans.                                                                   | SDK                       | How many spans of this request the SDK did not send. It keeps the first 200 of each request.                                                                                                                                                                                                                                                                                                                       | `0`                                |

### A call to another service

On a span of kind `SPAN_KIND_CLIENT` for an outgoing HTTP call (`fetch`, `http.request`, `https.request`).

| Name                        | Origin        | Type   | Required                 | Sent by                   | Meaning                                                                                                                                       | Example                |
| --------------------------- | ------------- | ------ | ------------------------ | ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- |
| `http.request.method`       | OpenTelemetry | string | always                   | SDK, bridge, any exporter | The method. Its presence makes the span a call (kind `http`) unless it also has `db.system.name`.                                             | `POST`                 |
| `server.address`            | OpenTelemetry | string | always                   | SDK, bridge, any exporter | The host that was called.                                                                                                                     | `api.payments.example` |
| `url.path`                  | OpenTelemetry | string | optional                 | SDK, bridge, any exporter | The path that was called, with ids replaced by `:id`. Never the query.                                                                        | `/v1/payments`         |
| `http.response.status_code` | OpenTelemetry | int    | when: An answer arrived. | SDK, bridge, any exporter | The status of the answer. No answer, `400`, or `500` and above make the call a failure; other answers, such as `401`, `404` or `409`, do not. | `400`                  |
| `error.type`                | OpenTelemetry | string | when: The call failed.   | SDK, bridge, any exporter | Why it failed: the status as text (`400`), or the error's class when there was no answer (`ECONNRESET`, `TimeoutError`).                      | `400`                  |

### A database call

On a span of kind `SPAN_KIND_CLIENT` for a query: a `pg` query, or a Supabase or PostgREST call recognized by its path (`/rest/v1/…`).

| Name                      | Origin        | Type   | Required                                                                                                               | Sent by                   | Meaning                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | Example                                                                                                                     |
| ------------------------- | ------------- | ------ | ---------------------------------------------------------------------------------------------------------------------- | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| `db.system.name`          | OpenTelemetry | string | always                                                                                                                 | SDK, bridge, any exporter | The database. Its presence makes the span a database call (kind `db`). The older `db.system` is read when this one is missing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | `postgresql`                                                                                                                |
| `db.operation.name`       | OpenTelemetry | string | always                                                                                                                 | SDK, bridge, any exporter | The operation: `SELECT`, `INSERT`, `UPDATE`, `DELETE`, or `CALL` for a PostgREST function. A PostgREST `PUT`, an upsert, is `INSERT`. With the table it is the span's name, `SELECT carts`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | `SELECT`                                                                                                                    |
| `db.collection.name`      | OpenTelemetry | string | when: The SDK could read the table from the statement or the PostgREST path.                                           | SDK, bridge, any exporter | The table, or the function for a PostgREST `CALL`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | `carts`                                                                                                                     |
| `db.namespace`            | OpenTelemetry | string | optional                                                                                                               | SDK, bridge, any exporter | The database name, from the connection. Not sent for PostgREST calls.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | `shop`                                                                                                                      |
| `server.address`          | OpenTelemetry | string | optional                                                                                                               | SDK, bridge, any exporter | The host of the database, or of the PostgREST API.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | `db.shop.internal`                                                                                                          |
| `db.response.status_code` | OpenTelemetry | string | when: The query failed, or a PostgREST call answered 400 or above.                                                     | SDK, bridge, any exporter | The database's error code: the Postgres SQLSTATE, or PostgREST's own code (`PGRST116`), read from the answer of a PostgREST call. With `captureDbErrors: false` a PostgREST call is not read and carries its HTTP status instead; a `pg` error keeps its SQLSTATE, which holds no value. On a database span the engine takes this code before `http.response.status_code` as the failed call's code, so a PostgREST call that answered HTTP 400 is `DB 23505`, not `DB 400`.                                                                                                                                                                                                                          | `23505`                                                                                                                     |
| `sypnia.db.message`       | Sypnia        | string | when: A `pg` query threw, or a PostgREST call answered 400 or above, and the app did not set `captureDbErrors: false`. | SDK                       | The database's message, as the database wrote it, values included, up to 2,000 characters: PostgREST's `message`, then its `details` and `hint` on lines of their own (`message\nDetail: …\nHint: …`), read from the first 4 KB of the answer, or the message of the `pg` error with its `detail` and `hint` joined the same way. The values are in it: the detail is where the database writes them. It can hold personal data the database put in it. When the call failed (`400`, `500`+, or a `pg` error) it is also the span's status message; an answer such as `404` or `409` keeps status `OK` and carries it as an attribute. The engine keeps it as sent. OpenTelemetry has no name for it. | `duplicate key value violates unique constraint "users_email_key"\nDetail: Key (email)=(maria@example.com) already exists.` |
| `sypnia.db.via`           | Sypnia        | string | when: The query went through an HTTP API instead of a database connection.                                             | SDK                       | `postgrest` for Supabase and PostgREST calls. The span keeps its HTTP attributes too. OpenTelemetry has no name for it.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | `postgrest`                                                                                                                 |

### An error

On a span event named `exception`, on the span where the error happened. Span events with any other name are dropped.

| Name                       | Origin        | Type   | Required | Sent by                   | Meaning                                                                                                                                                                                                                                | Example                                                                                                   |
| -------------------------- | ------------- | ------ | -------- | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| `exception.type`           | OpenTelemetry | string | always   | SDK, bridge, any exporter | The error's name or class, up to 100 characters: `TypeError`. `console.error` when a logged value was not an Error.                                                                                                                    | `PaymentError`                                                                                            |
| `exception.message`        | OpenTelemetry | string | always   | SDK, bridge, any exporter | The message, up to 500 characters.                                                                                                                                                                                                     | `amount is required (POST /v1/payments)`                                                                  |
| `exception.stacktrace`     | OpenTelemetry | string | optional | SDK, bridge, any exporter | The stack as the runtime wrote it, up to 4,000 characters. The engine translates it with the release's source maps.                                                                                                                    | `PaymentError: amount is required (POST /v1/payments)     at createCharge (/app/dist/payments.js:1:2380)` |
| `sypnia.error.source`      | Sypnia        | string | optional | SDK                       | How the SDK learned of it: `uncaught` (nobody caught it), `log` (`console.error` during a request) or `manual` (`reportError()`). `uncaught` when missing, which is what an exception from any other exporter is.                      | `uncaught`                                                                                                |
| `sypnia.error.fingerprint` | Sypnia        | string | optional | SDK                       | 16 hex characters: the fingerprint the SDK computed, which it also uses to send one error per fingerprint per request. When missing, the engine computes it with the same algorithm. Errors with the same fingerprint are one problem. | `3b9e0d1c7a2f4e58`                                                                                        |
| `sypnia.error.digest`      | Sypnia        | string | optional | SDK                       | The id a framework gave the error (the Next.js digest), up to 100 characters. The browser's `error` for the same failure carries the same digest, so the two are joined.                                                               | `2716153340`                                                                                              |

### Span status and errors outside a request

On any span.

| Name                      | Origin        | Type    | Required                                                                                | Sent by                   | Meaning                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | Example              |
| ------------------------- | ------------- | ------- | --------------------------------------------------------------------------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- |
| `status.code`             | OpenTelemetry | int     | optional                                                                                | SDK, bridge, any exporter | The span's status, a field of the span rather than an attribute. `STATUS_CODE_ERROR` (2) marks a failed call or a request that threw. The engine also marks a span failed from the rules above (no answer, `400`, `500`+) when an exporter left the status unset.                                                                                                                                                                                                                                                                                                                                                                           | `2`                  |
| `status.message`          | OpenTelemetry | string  | optional                                                                                | SDK, bridge, any exporter | For a failed call, its message. A failed database call's message, from the Sypnia SDKs, is the database's own, as written, values included, up to 2,000 characters: the same text as `sypnia.db.message`, and the engine keeps it as sent when the span carries that attribute. Any other message is up to 500 characters, and the Sypnia SDKs redact it before it leaves your server: e-mail addresses, URLs, UUIDs, quoted values, long tokens and every run of digits are replaced. Other exporters send what they send; the engine applies the same redaction on arrival to every status message of a span without `sypnia.db.message`. | `amount is required` |
| `sypnia.error.standalone` | Sypnia        | boolean | when: An error happened outside any request: at startup, in a timer, in a queue worker. | SDK                       | The span exists only to carry the error: one span of kind `SPAN_KIND_INTERNAL`, named `uncaught`, with the `exception` event. The engine records the error and lists no trace for it.                                                                                                                                                                                                                                                                                                                                                                                                                                                       | `true`               |
| `sypnia.running`          | Sypnia        | boolean | when: The span was still running when a partial request was exported.                   | SDK                       | This call had not finished; its end time is the moment of export. Shown as `running` in the trace.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | `true`               |

## What kind of span it is

The engine gives every span one of five kinds. The [Traces API](https://telemetry.docs.sypnia.com/api/traces) returns them in `kind`.

| In OTLP                                                                           | Sypnia kind | What it is                                                                   |
| --------------------------------------------------------------------------------- | ----------- | ---------------------------------------------------------------------------- |
| SPAN_KIND_SERVER                                                                  | `server`    | A request a service handled. With `http.route`, one API call in Performance. |
| SPAN_KIND_CLIENT with `db.system.name`                                            | `db`        | A database call.                                                             |
| SPAN_KIND_CLIENT with `http.request.method`                                       | `http`      | A call to another service.                                                   |
| Any other span (INTERNAL, PRODUCER, CONSUMER, or CLIENT without either attribute) | `internal`  | A step, shown in the trace.                                                  |
| A browser `request` event (not OTLP)                                              | `browser`   | The call as the page saw it. Made by the engine, below.                      |

## The browser's part of the trace

The browser SDK does not speak OTLP: it sends its compact [`request`](https://telemetry.docs.sypnia.com/reference/event-schema#request) event. The engine turns each `request` event that has a trace id into a span of kind `browser`:

| Field of `request`                       | In the browser span                                                                                                              |
| ---------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `tid`                                    | The trace id.                                                                                                                    |
| `span`                                   | The span id. It is the parent id the SDK put in `traceparent`, so the server span whose `parentSpanId` equals it hangs under it. |
| (none)                                   | The parent: none. The browser span is the root of the trace.                                                                     |
| `method` and `path`                      | The name, `POST /api/checkout`, and the attributes `http.request.method` and `url.path`.                                         |
| `host`                                   | `server.address`. Missing for calls to the page's own origin.                                                                    |
| `ts` and `dur`                           | Start and duration.                                                                                                              |
| `status`, `code`, `msg`                  | `http.response.status_code`; the span failed on `0`, `400` or `500`+; `code` and `msg` as `error.type` and the status message.   |
| `sid`, `person`, `account`, `env`, `ver` | The trace's session, person, account, environment and release. The service is `browser`.                                         |

## How one trace is put together

1. One trace is one trace id. The browser SDK creates it for each recorded call, with a span id for the call, and sends both in `traceparent` (`00-<trace id>-<span id>-01`) to your own origin and to `traceTargets`.
2. The server SDK reads `traceparent`: its server span takes the trace id and uses the browser's span id as `parentSpanId`. Without the header it starts a new trace. On every outgoing call it sends `traceparent` with its own span id, so the next service continues the trace.
3. The engine makes one span of kind `browser` from each `request` event, as in the table above. It is the root. The server spans hang under it through `parentSpanId`.
4. A span whose parent is not in the trace (the parent was dropped, lost or sampled out) hangs under the root, so the tree never breaks.
5. The trace's session is the browser event's `sid`, else `session.id` on a server span. Its person is `user.id` on a server span, else the session's person.
6. Spans of one trace can arrive in different requests and from different services. Ingest stores each request as it comes; the roll-up joins everything with the same trace id when it builds the trace, within the 10 minutes of the freshness promise.
7. Times are kept as each sender's clock gave them. The engine does not shift one service's clock to fit another's, so a server span can look a few milliseconds outside its browser span.

The shop's checkout, in these terms: the page's `POST /api/checkout` is the browser span `0f1e2d3c4b5a6978`, 3,870 ms, answered `400`. The server span of `shop-api`, `a1b2c3d4e5f60718`, has that span as its parent and takes 3,842 ms. Under it, `SELECT carts` (`db`, 12 ms) and `POST /v1/payments` (`http`, 3,790 ms, `error.type` `400`, status message `amount is required`). One trace id, `7c2e9a4b1d8f4e6a9b3c5d7e1f2a4b6c`, joins the four. The full request body is in the [OTLP reference](https://telemetry.docs.sypnia.com/api/otlp).

## What the engine does not use

- Span events other than `exception`, span links, `tracestate` and baggage: dropped.
- `url.query`, `url.full`, `db.query.text` and any attribute whose name contains `authorization`, `cookie`, `password`, `secret` or `token`: dropped at ingest.
- Attributes beyond 64 on a span: dropped. Values beyond 256 characters: cut, except `exception.stacktrace` (4,000), `exception.message` and `status.message` (500), and `sypnia.db.message` and the status message of a span that carries it (2,000).
- The sampled flag in `traceparent`: not used. Sypnia stores what it receives.
- Any attribute not listed on this page: kept with the span and shown in the trace, never used to decide anything.

## Limits and constants

Part of the contract: the SDKs and the engine implement these values.

| Constant                         | Value     | Meaning                                                                                                                          |
| -------------------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `spans_per_request`              | 200       | Spans the server SDKs keep per request. The rest are counted in `sypnia.dropped_spans`.                                          |
| `span_attributes`                | 64        | Attributes kept per span.                                                                                                        |
| `span_attribute_chars`           | 256       | Characters kept per attribute value, with the exceptions above.                                                                  |
| `failures_per_request`           | 5         | `exception` events the server SDKs send per request, one per fingerprint.                                                        |
| `log_failures_per_request`       | 3         | Of those, at most this many from `console.error`.                                                                                |
| `slow_request_ms`                | 20,000    | When a request still running is exported as partial (`sypnia.partial`). The option `slowRequestMs` changes it; `0` turns it off. |
| `export_interval_ms`             | 2,000     | How long finished spans wait in memory before the server SDKs export them in one request.                                        |
| `export_max_spans`               | 512       | Spans in one export request from the server SDKs. A request's spans are never split across two exports.                          |
| `body_bytes_after_decompression` | 4,000,000 | The largest body the endpoint accepts, from any sender.                                                                          |
| `spans_per_export`               | 2,000     | The most spans the endpoint accepts in one request, from any sender.                                                             |
| `spans_per_trace`                | 500       | Spans the engine keeps per trace. The rest are counted in the trace's `dropped_spans`.                                           |
