# Send OpenTelemetry logs and traces to Tailcove

If your services already speak OpenTelemetry, you don't need a Tailcove client. Tailcove takes OTLP over HTTP, so you
change the exporter's endpoint and add one header. Logs land next to the rest of your lines, spans land on the
source's **Traces** tab, and the trace id on each log line ties the two together.

This guide sets up one service, then shows where logs and traces meet.

## 1. Create a source

In Tailcove, choose **New source**, name it after the service (`checkout-production`) and pick **Other** as the
platform. Copy the ingest token from the last step: it's shown once.

The **Traces** tab shows on a source made for **Other** straight away. A source made for another platform gets the tab
as soon as its first span is stored, so nothing is lost if you picked something else.

> [!TIP]
> Logs and spans from the same service can share one source and one token. Correlate searches every source you can
> see, so splitting them later doesn't break the link between a trace and its logs.

## 2. Point your exporter at Tailcove

Every OpenTelemetry SDK reads the same standard settings. Set the base endpoint and the SDK adds `/v1/logs`,
`/v1/metrics` and `/v1/traces` itself:

```bash@macOS_/_Linux
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
export OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.tailcove.dev/api/v1/otlp
export OTEL_EXPORTER_OTLP_HEADERS="authorization=Bearer YOUR_SOURCE_TOKEN"
export OTEL_SERVICE_NAME=checkout
```

```powershell@Windows_(PowerShell)
$env:OTEL_EXPORTER_OTLP_PROTOCOL = "http/protobuf"
$env:OTEL_EXPORTER_OTLP_ENDPOINT = "https://ingest.tailcove.dev/api/v1/otlp"
$env:OTEL_EXPORTER_OTLP_HEADERS = "authorization=Bearer YOUR_SOURCE_TOKEN"
$env:OTEL_SERVICE_NAME = "checkout"
```

These last for the current terminal session. To keep them, add the `export` lines to `~/.zshrc` (macOS) or
`~/.bashrc` (Linux), or on Windows run `setx NAME "value"` once per variable and open a new terminal. In production, set
them wherever your app's environment lives: the service unit, container or deploy settings.

The protocol line matters. Tailcove accepts OTLP/HTTP in protobuf or JSON, with or without gzip. gRPC isn't
supported, so keep `http/protobuf` (or `http/json`) even if your SDK defaults to gRPC.

If you set one signal's endpoint on its own (`OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` and friends), give it the full URL:

| Signal | URL                                                      |
| ------ | -------------------------------------------------------- |
| Logs   | `POST https://ingest.tailcove.dev/api/v1/otlp/v1/logs`   |
| Traces | `POST https://ingest.tailcove.dev/api/v1/otlp/v1/traces` |

## 3. Start the service with auto-instrumentation

With the settings above in the environment, auto-instrumentation traces inbound requests, database calls and outgoing
HTTP calls without code changes. Pick your runtime:

```bash@Node.js
npm install @opentelemetry/auto-instrumentations-node @opentelemetry/api
node --require @opentelemetry/auto-instrumentations-node/register app.js
```

```bash@Python
pip install opentelemetry-distro opentelemetry-exporter-otlp-proto-http
opentelemetry-bootstrap -a install
opentelemetry-instrument python app.py
```

```bash@Java
java -javaagent:opentelemetry-javaagent.jar -jar app.jar
```

.NET, PHP, Go and the Kubernetes operator are covered on the
[auto-instrumentation page](https://tailcove.dev/docs/opentelemetry/auto-instrumentation). In Kubernetes, keep the token in a Secret rather
than in the manifest.

> [!NOTE]
> Some SDKs send traces by default but need logs switched on. The standard setting is `OTEL_LOGS_EXPORTER=otlp`; your
> language's OpenTelemetry docs say whether it also needs a logging bridge.

## 4. Or send through the Collector

If your services already export to an OpenTelemetry Collector, add Tailcove as an `otlphttp` exporter and put it on the
`logs` and `traces` pipelines. The receiver and processor below are the usual ones; keep yours if you already have them.

```yaml@Collector
receivers:
    otlp:
        protocols:
            grpc:
            http:

processors:
    batch:
        send_batch_max_size: 1000

exporters:
    otlphttp/tailcove:
        endpoint: https://ingest.tailcove.dev/api/v1/otlp
        headers:
            authorization: Bearer YOUR_SOURCE_TOKEN

service:
    pipelines:
        logs:
            receivers: [otlp]
            processors: [batch]
            exporters: [otlphttp/tailcove]
        traces:
            receivers: [otlp]
            processors: [batch]
            exporters: [otlphttp/tailcove]
```

Your apps can keep talking gRPC to the Collector. Only the hop from the Collector to Tailcove has to be HTTP, and
`otlphttp` takes care of that.

> [!TIP]
> Capping the batch keeps each request under Tailcove's 5,000 records or spans per request. Add a `metrics` pipeline
> to the same exporter if you want metrics too ([OpenTelemetry overview](https://tailcove.dev/docs/opentelemetry/overview)).

## 5. Check the logs arrived

Open the source's **Live tail** and make the service do something. OTLP log records become ordinary log lines, so live
tail, search, issues and alerts work on them as they do on any other line. Here's how a record is read:

| OTLP                                                    | In Tailcove                            |
| ------------------------------------------------------- | -------------------------------------- |
| `timeUnixNano` (else `observedTimeUnixNano`)            | the line's time                        |
| `severityNumber` 1-8, 9-12, 13-16, 17-20, 21 and up     | `debug`, `info`, `warning`, `error`, `critical` |
| `severityText`, when there's no severity number         | the level                              |
| `body`                                                  | the message                            |
| `host.name` (else `service.instance.id`)                | the host                               |
| record attributes                                       | `attributes` in the line's context     |
| resource attributes                                     | `resource` in the line's context       |
| `traceId`, `spanId`                                     | `trace_id`, `span_id` in the context   |

`level:error` and `host:api-1` work straight away. Attributes are kept under `attributes` and `resource`, and the search
bar reaches top-level keys, so a value you want to filter on often is worth logging as its own top-level field.

## 6. Check the traces arrived

Open the source's **Traces** tab. It lists the newest traces in the time range by their root span, 100 at a time, with
filters for service, status, minimum duration and a name search. **Load older traces** fetches the next 100.

A trace shows up once its root span has arrived. If a request is still running, or the service that owns the root span
isn't sending yet, the trace isn't listed.

Open one to see every span as a waterfall. Select a span to read its attributes and events. The service on each span is
the resource's `service.name`, which is why setting `OTEL_SERVICE_NAME` in step 2 pays off.

## 7. Go from a trace to its logs, and back

Every OTLP log record written inside a span carries the span's trace id as `trace_id`. That one field is what links the
two views.

- **From a trace:** on the waterfall, press **Logs of this trace**. [Correlate](https://tailcove.dev/docs/correlate) opens with every line
  that carries the trace id, from every source you can see, as one timeline. For an OpenTelemetry trace id it also
  lists, per source, how many spans arrived, how long the trace ran, which services took part and how many spans
  failed, with a link back to the waterfall.
- **From a log line:** open the line in the log viewer. When its `trace_id` names a trace, the **View trace** button
  shows the trace's duration and span count. **Follow trace_id across sources** opens the same Correlate timeline.
- **From the search bar:** `trace_id:` followed by the id lists that trace's lines on one source. See the
  [query language](https://tailcove.dev/docs/query-language) for the rest of the syntax.

> [!NOTE]
> Lines sent with a Tailcove client or the HTTP API join a trace the same way, as long as they carry a top-level
> `trace_id`. An id nested inside another object (`{"trace": {"id": ...}}`) isn't found.

## 8. Know the limits

A request is at most 5 MB, compressed or not, and holds at most 5,000 log records or spans. A JSON body nests at most
32 levels.

Spans have a rate per plan:

| Plan     | Spans per minute |
| -------- | ---------------- |
| Free     | 1,000            |
| Pro      | 10,000           |
| Business | 50,000           |

Over that rate the request is refused with `429` and a `Retry-After` header, nothing is counted, and the exporter
retries on its own. OTLP logs count against your log quota like any other line. Spans count toward your plan's included
GB too, and once the team reaches its monthly ceiling they're refused with `429` (`quota_exceeded`).

What a span keeps has limits as well:

- A span without a valid, non-zero trace id and span id is skipped.
- Names are cut at 256 characters and status messages at 512.
- A span keeps at most 64 attributes, with values cut at 1,024 characters, and up to 16 events. If its attributes or
  its events would take more than 8 KB, they're dropped.
- A start time more than a day in the future, or before 2000, is replaced by the time the span arrived.
- Traces are kept for the source's retention, at most 90 days.

> [!WARNING]
> A mobile app shouldn't ship your source token. iOS and Android apps send OTLP logs and traces with the source's app
> key and app id headers instead; metrics stay token-only. See [native mobile apps](https://tailcove.dev/docs/sending-logs/mobile-native).

## If nothing arrives

| What you see                                   | What it means and what to do                                                                       |
| ---------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| The exporter tries port 4317 or speaks gRPC    | gRPC isn't supported. Set `OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf` and the base endpoint from step 2, or use `otlphttp` in the Collector. |
| `401`                                          | The token is missing or wrong. Check the header is `authorization=Bearer YOUR_SOURCE_TOKEN`.       |
| `404` from a per-signal endpoint               | A per-signal setting needs the full URL ending in `/v1/logs` or `/v1/traces`, not the base.        |
| `413`                                          | The body was over 5 MB, compressed or decompressed. Lower the batch size.                          |
| `415`                                          | The body wasn't protobuf or JSON. Use `http/protobuf` or `http/json`.                              |
| `422`                                          | Not valid OTLP, or more than 5,000 records or spans in one request. Lower the batch size.          |
| `429`                                          | Over the spans-per-minute rate, a rate limit or the monthly quota. The exporter retries after `Retry-After`; check usage on the Billing page. |
| `503`                                          | Our buffer is full for a moment. The exporter retries.                                             |
| No **Traces** tab on the source                | The source was made for a platform that doesn't send traces, and no span has been stored yet. The tab appears after the first span. |
| Spans arrive, but a trace isn't listed         | Its root span hasn't arrived. Check the service that starts the request is exporting too.          |
| Logs arrive without `trace_id`                 | They were written outside a span, or the logging bridge isn't reading the active span.             |

## Next steps

- Every OTLP setting and response on one page: [OpenTelemetry overview](https://tailcove.dev/docs/opentelemetry/overview).
- What the Traces tab stores and shows: [Traces](https://tailcove.dev/docs/opentelemetry/traces).
- Pod logs and container metrics beside your traces: the [Tailcove agent](https://tailcove.dev/docs/sending-logs/agent).
