March Docs

Bastion.OpenTelemetry

lib/otel.march — Bastion.OpenTelemetry: OTLP HTTP/JSON span exporter.

Attaches to all Bastion telemetry events and POSTs spans to an OpenTelemetry collector in OTLP protobuf-JSON format.

── Usage ──────────────────────────────────────────────────────────────────────

-- At application startup:
Bastion.OpenTelemetry.start(
  Bastion.OpenTelemetry.default_config("my_app")
)

-- With a custom endpoint and auth header:
Bastion.OpenTelemetry.start({
  endpoint     = "https://otel.example.com/v1/traces",
  service_name = "my_app",
  headers      = [("Authorization", "Bearer <token>")],
})

Types

typeConfigConfig = {#

Functions

fndefault_configdefault_config(service_name : String) : Config#

Build a default OTLP config pointing at a local collector.

    let cfg = Bastion.OpenTelemetry.default_config("my_app")
fnexport_spanexport_span(#

Build an OTLP span payload and POST it to the collector asynchronously.

Errors from the HTTP call are silently ignored (fire-and-forget).

    Bastion.OpenTelemetry.export_span(config, event_name, 42, meta_json)
fnstartstart(config : Config)#

Attach an OTLP exporter to all Bastion telemetry events.

On "stop" events a span is built and POSTed asynchronously to the collector.
On "exception" events a span with error status is POSTed.

    Bastion.OpenTelemetry.start(config)