Server telemetry
Send OpenTelemetry from servers, workers, CLIs and clusters you run to your organisation's OTLP edge, with an edge credential. The endpoint, the credential, the attributes every record should carry, and how to check it arrived.
Anything that speaks OTLP/HTTP can send to Lantern: an OpenTelemetry SDK in your service, a CLI, a batch job, or an OpenTelemetry Collector in front of a whole cluster. They all send to one endpoint, the OTLP edge, with one of your organisation's edge credentials.
Use the standard OpenTelemetry SDK for your language. Lantern adds three things to it:
- where to send: the edge's endpoint;
- how to authenticate: an edge credential, as an HTTP Basic header;
- what to say about the sender: a few resource attributes.
Already on OpenTelemetry? Add Lantern's add-on for your language. It sets
up the stock SDK and exporters with all three, from LNTRN_* variables:
| Language | Add-on | |
|---|---|---|
| Go | git.prod.wtf/xeonr/lantern/otel/go | lntrn.Setup(ctx, lntrn.Options{…}), see Go |
| Node.js | @lntrn/otel | node --import @lntrn/otel/register app.js, see Node.js |
Or leave the SDK as it is and set the standard OTEL_* variables below. Then
the same build sends to Lantern or anywhere else.
- Go: OpenTelemetry-Go in a server, worker or CLI.
- Node.js: OpenTelemetry for Node, with pino.
- Kubernetes: an agent on every node and one forwarder per cluster.
Before you start
- Your organisation's console,
https://<org>.lntrn.dev, and a sign-in there. - An admin of the organisation to create the edge credential. Editors and viewers can send with one, but cannot make one.
Create an edge credential
In the console, open Settings → Edge credentials → New edge credential and
name it after the sender (api servers, prod cluster). Or, with the
CLI:
lntrn --org <org> edge-credentials create --name "prod cluster"You get a username, <org>.<id>, and a password. The password is
shown once and Lantern keeps only a hash, so store it in your secret manager
now. The CLI also prints the SDK environment and a Collector exporter that
use it.
Make one credential per sender, or per group of senders you would revoke
together. Revoking one in the same page (or with
lntrn --org <org> edge-credentials revoke <id>) stops it working within
moments, and the others carry on.
The endpoint
| Endpoint | https://otlp.lntrn.dev |
| Paths | /v1/traces, /v1/metrics, /v1/logs |
| Protocol | OTLP/HTTP, protobuf (application/x-protobuf) or JSON (application/json); gzip accepted. There is no gRPC endpoint |
| Authentication | HTTP Basic: the edge credential's username and password |
The examples keep the credential in LNTRN_EDGE_USER (the username) and
LNTRN_EDGE_PASSWORD, the variables the add-ons read. With an add-on, they and
OTEL_SERVICE_NAME are all a process needs. Without one, every OpenTelemetry
SDK reads the standard exporter variables, so this is usually all the
configuration it needs:
export OTEL_EXPORTER_OTLP_ENDPOINT=https://otlp.lntrn.dev
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Basic%20$(printf '%s' "${LNTRN_EDGE_USER}:${LNTRN_EDGE_PASSWORD}" | base64 | tr -d '\n')"The space in the header value is written %20, because the SDKs
percent-decode OTEL_EXPORTER_OTLP_HEADERS. Set the endpoint without a path:
the SDK appends /v1/traces and the rest itself.
Every record that credential sends is filed in your organisation. What decides
it is the credential, not anything in the data: an org.id attribute you send
is overwritten.
What every record should carry
Set these as resource attributes, once per process, usually through
OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES:
| Attribute | ||
|---|---|---|
service.name | required | The service as Lantern lists it: checkout-api, billing-worker, deploy-cli. One name for every signal, and the same name in every environment |
service.version | recommended | The release, from your CI: an image tag or git SHA. Lantern compares versions on the service page |
service.namespace | recommended | The slug of the team (or sub-team) that owns the service (checkout). A record from an SDK without one is marked unnamespaced |
deployment.environment.name | recommended | prod, stage, dev. With none, Lantern files the record as prod |
export OTEL_SERVICE_NAME=checkout-api
export OTEL_RESOURCE_ATTRIBUTES=service.namespace=checkout,service.version=1.4.2,deployment.environment.name=prodLantern shows the environment under the older key, deployment.environment.
It copies deployment.environment.name into it, so either spelling works.
Don't set the two to different values.
In Kubernetes, the k8s.* keys (k8s.cluster.name, k8s.namespace.name,
k8s.pod.name, the workload) are the collector's to set, never the app's. See
Kubernetes. Off Kubernetes, leave them unset.
Records with no k8s.cluster.name currently show Lantern's own cluster name in
the cluster facet. That is being fixed; don't work around it by inventing
a cluster name for a service that has none.
Logs and severity
Lantern stores one severity per log line, from one vocabulary: trace,
debug, info, warn, error and fatal. It reads the OTLP severity
number first, then the text, and accepts the usual spellings (WARNING,
err, critical, pino's numbers). Keep the logger's level as the record's
severity, not as an attribute.
A log line belongs to its trace when it carries the trace and span ids:
- the OpenTelemetry log bridges for slog, pino, winston and the rest set them for you, from the active span;
- a line written to stdout and collected in Kubernetes needs
trace_idandspan_idas JSON fields.
Where logs go depends on where the process runs:
| Runs on | Logs |
|---|---|
| Kubernetes, with Lantern's agent | JSON on stdout, one object per line, with level, msg, time, trace_id and span_id. The agent reads every container's output, so panics and stderr are kept too. Don't also export them over OTLP, or you store each line twice |
| Anywhere else: a VM, a laptop, a CI job, a CLI | OTLP, through the SDK's log exporter |
What is never stored
Lantern drops these from spans, logs and resources wherever they appear, so don't send them:
- credentials: any key ending
token,secret,password,passwd,api_keyorapikey; - the
authorization,cookie,set-cookieandx-api-keyheaders, anddb.connection_string; - direct personal identifiers:
user.username,user.email,user.name,user.full_nameandenduser.*.
Identify a person by an opaque id instead.
On metrics, only the service, environment, host and k8s.* resource keys
become labels. Datapoint attributes are labels too, so keep them low-cardinality:
a status code, never a user id.
Limits
- Request rate: each credential may make 20 requests a second on average, with bursts to 100. An SDK's batching processor stays far below that.
- Many senders on one credential: a cluster's agents, say. Send through one collector that batches for all of them (the Kubernetes setup does).
- Over the limit: a request is refused with
429, and SDKs and the Collector retry it.
Verify
Check the credential on its own first:
curl -s -o /dev/null -w '%{http_code}\n' \
-u "${LNTRN_EDGE_USER}:${LNTRN_EDGE_PASSWORD}" \
-H 'content-type: application/json' -d '{"resourceSpans":[]}' \
https://otlp.lntrn.dev/v1/traces200: the credential is good.401: the username or password is wrong, or the credential was revoked.
Then send from your service and look for it, within a minute, in the console's
Traces and Logs filtered to service.name, or from a terminal:
lntrn --org <org> query traces 'service.name:checkout-api' --since 15m
lntrn --org <org> query logs 'service.name:checkout-api' --since 15m
lntrn --org <org> query metrics --agg rate --of traces_span_metrics_calls_total --group-by service.name --since 15m --tableLantern derives request rate, errors and duration from your spans
(traces_span_metrics_*) before it samples them, so a service with traces
has RED metrics without exporting any of its own. Metrics take up to a minute
longer than traces to appear.
Traces are tail-sampled once complete:
- every trace with an error, and every trace slower than 500 ms, is kept;
- the rest may be sampled.
So expect every error you send to be there, but not necessarily every fast success of a busy service.
Home
Lantern stores the traces, logs and metrics of your organisation's services, clusters, apps and devices, sent as OpenTelemetry, and lets you search, chart, alert on and probe them.
Go
Send traces, metrics and logs from a Go server, worker or CLI to Lantern with OpenTelemetry-Go and OTLP/HTTP, and choose between logging to stdout and exporting logs.