The 11 BaSyx commands that expose HTTP APIs support optional OpenTelemetry tracing and PostgreSQL connection pool metrics. Telemetry is configured only with standard OpenTelemetry environment variables; it does not add a BaSyx YAML section.
basyxconfigurationservice and historyevidenceverifier do not expose HTTP
servers or traced operations, so they remain logging-only commands.
Tracing is disabled when OTEL_TRACES_EXPORTER is unset, empty, or none.
Metrics are independently disabled when OTEL_METRICS_EXPORTER is unset,
empty, or none. OTEL_SDK_DISABLED=true disables both signals regardless of
their exporters.
Use an OTLP Collector in deployed environments:
OTEL_TRACES_EXPORTER=otlp
OTEL_METRICS_EXPORTER=otlp
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318The console exporter is available independently for local diagnostics:
OTEL_TRACES_EXPORTER=console
OTEL_METRICS_EXPORTER=consoleUnsupported explicit values stop startup with an OTEL-CONFIG-* error. A
Collector outage after configuration does not stop the service or fail HTTP
requests. Export and shutdown failures are emitted as structured warnings
without logging configured endpoints or OTLP headers.
BaSyx supports these standard settings provided by the OpenTelemetry Go SDK and auto-exporter:
OTEL_TRACES_EXPORTER:otlp,console, ornoneOTEL_METRICS_EXPORTER:otlp,console, ornoneOTEL_SDK_DISABLEDOTEL_EXPORTER_OTLP_ENDPOINTandOTEL_EXPORTER_OTLP_TRACES_ENDPOINTOTEL_EXPORTER_OTLP_METRICS_ENDPOINTOTEL_EXPORTER_OTLP_PROTOCOLandOTEL_EXPORTER_OTLP_TRACES_PROTOCOLOTEL_EXPORTER_OTLP_METRICS_PROTOCOLOTEL_EXPORTER_OTLP_HEADERSandOTEL_EXPORTER_OTLP_TRACES_HEADERSOTEL_EXPORTER_OTLP_METRICS_HEADERSOTEL_EXPORTER_OTLP_COMPRESSIONandOTEL_EXPORTER_OTLP_TRACES_COMPRESSIONOTEL_EXPORTER_OTLP_METRICS_COMPRESSIONOTEL_EXPORTER_OTLP_TIMEOUTandOTEL_EXPORTER_OTLP_TRACES_TIMEOUTOTEL_EXPORTER_OTLP_METRICS_TIMEOUTOTEL_SERVICE_NAMEandOTEL_RESOURCE_ATTRIBUTESOTEL_TRACES_SAMPLERandOTEL_TRACES_SAMPLER_ARGOTEL_BSP_SCHEDULE_DELAY,OTEL_BSP_EXPORT_TIMEOUT,OTEL_BSP_MAX_QUEUE_SIZE, andOTEL_BSP_MAX_EXPORT_BATCH_SIZEOTEL_METRIC_EXPORT_INTERVALandOTEL_METRIC_EXPORT_TIMEOUTOTEL_PROPAGATORS
The default telemetry resource service.name is the lowercase command
directory name, such as aasenvironmentservice. OTEL_SERVICE_NAME overrides
it. BaSyx does not invent a service.version; operators can provide one
through OTEL_RESOURCE_ATTRIBUTES.
The default propagators are W3C Trace Context and Baggage. Supported
OTEL_PROPAGATORS values are tracecontext, baggage, and none.
See the OpenTelemetry environment variable specification and Go auto-exporter documentation for the detailed value formats.
Each service registers its single shared PostgreSQL writer pool once. The
metrics read database/sql.DBStats() during collection and do not execute
database queries.
| Metric | Type | DBStats source |
|---|---|---|
db.client.connection.max |
up/down counter | MaxOpenConnections |
db.client.connection.count with state=used |
up/down counter | InUse |
db.client.connection.count with state=idle |
up/down counter | Idle |
basyx.db.client.connection.waits |
cumulative counter | WaitCount |
basyx.db.client.connection.wait_time |
cumulative counter in seconds | WaitDuration |
basyx.db.client.connection.closed with reason=idle_limit |
cumulative counter | MaxIdleClosed |
basyx.db.client.connection.closed with reason=idle_time |
cumulative counter | MaxIdleTimeClosed |
basyx.db.client.connection.closed with reason=max_lifetime |
cumulative counter | MaxLifetimeClosed |
Open connections are the sum of the used and idle
db.client.connection.count points. Every point has
db.system.name=postgresql and
db.client.connection.pool.name=writer. The service.name resource attribute
identifies the BaSyx service. These values are bounded; database names, hosts,
users, DSNs, SQL text, AAS identifiers, and request data are not metric
attributes.
Use rates for the cumulative wait and closure counters. A rising wait rate
while used approaches max indicates that the service pool is constraining
concurrency. Low pool utilization with slow requests points elsewhere, such as
PostgreSQL query execution, server capacity, or storage latency.
The default sampler is parent-based and always-on. For sustained or high-volume traffic, configure an appropriate sampler instead of tracing every request. For example:
OTEL_TRACES_SAMPLER=parentbased_traceidratio
OTEL_TRACES_SAMPLER_ARG=0.1Completed spans are exported in batches. Metrics use the SDK export interval and timeout. When a service stops, BaSyx flushes and shuts down the enabled trace and metric providers with fresh bounded contexts after HTTP shutdown has completed.
Every HTTP request creates one SERVER span when tracing is enabled. A valid
inbound W3C traceparent and tracestate is extracted; otherwise BaSyx creates
a new trace. Matched spans are named <METHOD> <route>, while unmatched routes
use <METHOD>.
Server span attributes include:
http.request.methodurl.pathhttp.routewhen Chi resolves a routehttp.response.status_codehttp.response.body.sizerequest.idcorrelation.id
5xx responses and panics mark the span as an error. Panic spans contain only a generic marker, not the panic value.
Delegated submodel-operation calls create CLIENT spans and inject the active
W3C trace context. This instrumentation wraps the existing guarded transport;
its host allowlisting, DNS/IP checks, proxy restrictions, timeout, pinned
dialing, redirect checks, and authorization behavior remain unchanged.
Requests without an active span do not receive fabricated trace headers.
This release does not propagate trace context to OIDC endpoints or arbitrary third-party HTTP clients.
Trace spans never capture query strings, request or response bodies, authorization values, arbitrary headers, tokens, user agents, or client IP addresses. Delegated client spans contain only the method, scheme, hostname and port, path, response status, and a generic error marker. PostgreSQL metrics contain only the bounded attributes documented above.
Every slog event emitted with a valid active span context receives these
top-level fields:
trace_idspan_idtrace_flags
The IDs use lowercase hexadecimal values. trace_flags is 01 for sampled
contexts and 00 for unsampled contexts. Background logs remain unchanged.
The HTTP request completed access event is written before the server span
ends, so its identifiers match the span.
Logs still go to stderr. BaSyx does not export logs through OTLP or contain direct clients for Jaeger, Loki, Tempo, or Grafana.
The BaSyx observability example builds the BaSyx images from the current checkout and connects:
BaSyx --OTLP/HTTP--> Collector --OTLP/gRPC--> Jaeger
BaSyx --JSON stderr--> Alloy --Loki API--> Loki
Grafana --> Jaeger and Loki
Grafana is provisioned with links from log trace_id values to Jaeger and
from Jaeger traces back to Loki.
This telemetry foundation does not add OTLP log export, database query spans, SQL statement capture, AAS-domain spans, runtime reconfiguration, or custom exporter plugins.