Skip to main content

Overview

The III SDK includes built-in OpenTelemetry support for traces, metrics, and logs. All telemetry data is exported to the III Engine via a shared WebSocket connection using OTLP JSON format.
OpenTelemetry is enabled by default. To disable, set OTEL_ENABLED=false or { otel: { enabled: false } } in init options.

Quick Start

Configuration

Service Identity

Environment Variables

You can also configure OpenTelemetry via environment variables:

Distributed Tracing

Automatic Tracing

All function invocations are automatically traced with parent-child span relationships:

Custom Spans

Create custom spans for fine-grained tracing:

HTTP Client Tracing

HTTP requests are automatically instrumented:

Third-Party Instrumentations

Metrics

Automatic Metrics

The SDK automatically reports worker metrics:
  • iii.worker.cpu_usage - CPU usage percentage
  • iii.worker.memory_usage - Memory usage in bytes
  • iii.worker.active_invocations - Number of active function calls

Custom Metrics

Logs

See the Context-Aware Logging guide for details on using the Logger API.

Telemetry Export

Separate WebSocket Connection

Telemetry uses a dedicated WebSocket connection separate from the main III connection. This ensures telemetry export doesn’t interfere with function invocations.

OTLP JSON Format

Telemetry is exported using OTLP JSON over WebSocket with binary frame prefixes:
  • Traces: OTLP + JSON payload
  • Metrics: MTRC + JSON payload
  • Logs: LOGS + JSON payload

Shutdown

Best Practices

Observability Checklist:
  • ✅ Set meaningful serviceName and serviceVersion
  • ✅ Use serviceNamespace to differentiate environments (dev, staging, prod)
  • ✅ Add custom span attributes for business-critical operations
  • ✅ Use structured logging with context (see Context Logging)
  • ✅ Create custom metrics for domain-specific KPIs
  • ✅ Use semantic conventions for standard operations (HTTP, DB, etc.)
  • ✅ Configure separate reconnection for telemetry (less aggressive than main connection)
  • ✅ Always flush telemetry on shutdown (await iii.shutdown())