# Auto-instrumentation

Tailcove does not run an eBPF agent. Kernel-level tracing needs privileged access to
every node, which a log and metrics product should not ask for, and it sees
requests but not what your code meant by them. OpenTelemetry auto-instrumentation
gets you the same result, traces of every inbound request, database call and
outgoing HTTP call, from inside the process, with no change to your code and
nothing privileged on the host.

Pair it with the [Tailcove agent](https://tailcove.dev/docs/sending-logs/agent#kubernetes): the agent
brings the pod's logs, CPU and memory; auto-instrumentation brings its traces and
application metrics. Both go to the same source, so a trace's logs and the pod's
resource use sit side by side.

## Send to Tailcove

Every language below reads the same standard settings:

```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.

gRPC is not supported: keep `http/protobuf` (or `http/json`). See
[Logs & Metrics](https://tailcove.dev/docs/opentelemetry/overview) and [Traces](https://tailcove.dev/docs/opentelemetry/traces).

## Language by language

**Java**: download the agent jar and attach it. No code changes.

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

**Node.js**:

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

**Python**:

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

**.NET**: install the OpenTelemetry .NET automatic instrumentation and load its
`instrument.sh` before starting the app.

**PHP and Go**: PHP has an extension (`opentelemetry`) plus the contrib packages for
frameworks; Go has no in-process auto-instrumentation, so use the instrumented
libraries for `net/http` and your database driver.

## In Kubernetes: the operator

The OpenTelemetry Operator injects the instrumentation into pods without rebuilding
images. After installing the operator, create an `Instrumentation` that points at
Tailcove, and annotate the workloads:

```yaml
apiVersion: opentelemetry.io/v1alpha1
kind: Instrumentation
metadata:
    name: tailcove
spec:
    exporter:
        endpoint: https://ingest.tailcove.dev/api/v1/otlp
    propagators: [tracecontext, baggage]
    env:
        - name: OTEL_EXPORTER_OTLP_PROTOCOL
          value: http/protobuf
        - name: OTEL_EXPORTER_OTLP_HEADERS
          valueFrom:
              secretKeyRef:
                  name: tailcove-otlp
                  key: headers # authorization=Bearer YOUR_SOURCE_TOKEN
```

```yaml
# on the Deployment's pod template
metadata:
    annotations:
        instrumentation.opentelemetry.io/inject-java: 'true' # or inject-nodejs, inject-python, inject-dotnet
```

Keep the token in a Secret, not in the manifest.

## What you give up compared to eBPF

Services you cannot restart or whose runtime has no auto-instrumentation (a C++ or
Rust binary, a vendor's appliance) are not covered; for them the agent's pod logs and
container metrics are still there. If you need kernel-level tracing, run an eBPF tool
of your choice and send its OTLP output to the endpoint above.
