Skip to main content

Module observe

Module observe 

Source
Expand description

What a service logs about each request: a span with its method, path, request id, and whose it is (the campaign, once its token is checked, and the account, as the proxy says), in plain text or JSON lines, and as traces to an OpenTelemetry collector if there is one. Never a body, and never the query string, which may hold what someone typed.

Constants§

ACCOUNT
The account a request is for, set by the hosting’s proxy (from the address it came to). Believed only with TRUST_PROXY.
REQUEST_ID
The request’s id: the proxy’s, or one of the service’s own. Answered in the response too, so a user’s report can be found in the logs.

Functions§

flush
Sends the traces not sent yet, before the service stops.
requests
Logs router’s requests. With trust_proxy, the proxy’s request id and account are believed; without, a client’s are dropped.
subscriber
The subscriber init_logging installs, writing to writer: JSON lines when json, otherwise text for people; and with traces, sending each span on as a trace too.
traces
Sends spans as traces, as service, to the OpenTelemetry collector at OTEL_EXPORTER_OTLP_ENDPOINT (such as http://collector:4318), over HTTP; None without one.