API Reference
TelemetryLane provides three core types — Collector, Router, and Exporter — along with global functions for agent lifecycle management.
Initialization
a, err := agent.Init(agent.Config{
ServiceName: "my-service", // Required: identifies the service
Exporter: "otlp", // Exporter backend
BufferSize: 4096, // Event buffer capacity
FlushInterval: 5 * time.Second, // Auto-flush interval
})
| Parameter |
Type |
Default |
Description |
ServiceName |
string |
"" |
Service identifier attached to all telemetry |
Exporter |
string |
"stdout" |
Exporter backend name |
BufferSize |
int |
2048 |
Internal event buffer capacity |
FlushInterval |
time.Duration |
10s |
Interval between automatic flushes |
Collector
The Collector receives telemetry data from instrumented code. It is the primary interface for emitting traces, logs, and metrics.
// Emit a trace span
ctx, span := a.Trace(ctx, "operation-name", agent.Tag("key", "value"))
defer span.End()
// Emit a log entry
a.Log(ctx, agent.Info, "user logged in", "user_id", "u-42")
// Record a metric value
a.Metric("queue_depth", 17, agent.Tag("queue", "orders"))
| Method |
Description |
a.Trace(ctx, name, ...opts) |
Start a new trace span. Returns child context and span handle. |
a.Log(ctx, level, msg, ...kvs) |
Emit a structured log entry. Automatically inherits trace context. |
a.Metric(name, value, ...opts) |
Record a numeric metric with optional tags. |
Router
The Router directs telemetry data to one or more exporters based on configurable rules. Routes can filter by signal type, severity, or custom predicates.
// Add a route that sends errors to a dedicated exporter
a.AddRoute(agent.Route{
Name: "errors-to-pagerduty",
Filter: agent.SeverityGte(agent.Error),
Target: "pagerduty",
})
// Fan-out traces to multiple backends
a.FanOut(agent.Traces, []string{"otlp", "jaeger"})
// Set a global filter to drop debug logs in production
a.SetFilter(agent.DropBelow(agent.Info))
| Method |
Description |
a.AddRoute(route) |
Register a routing rule for telemetry data |
a.SetFilter(filter) |
Set a global filter applied before routing |
a.FanOut(signal, targets) |
Send a signal type to multiple exporters simultaneously |
Exporter
Exporters send processed telemetry data to backend systems. TelemetryLane ships with built-in exporters for common backends.
| Exporter |
Protocol |
Signals |
otlp |
gRPC / HTTP |
Traces, Logs, Metrics |
jaeger |
Thrift / gRPC |
Traces |
zipkin |
HTTP JSON |
Traces |
file |
JSON Lines |
Traces, Logs, Metrics |
stdout |
Text |
Traces, Logs, Metrics |
Global Functions
| Function |
Description |
agent.Init(config) |
Initialize a TelemetryLane agent instance |
a.Flush(ctx) |
Force-export all buffered telemetry data |
a.Shutdown(ctx) |
Gracefully shutdown, flush remaining data, close connections |
a.Status() |
Return agent health status and pipeline statistics |