Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.tracelit.io/llms.txt

Use this file to discover all available pages before exploring further.

Every Tracelit backend SDK ships a metrics API on top of OpenTelemetry. Create custom instruments in your code and the SDK collects automatic runtime metrics in the background — no separate metrics agent needed.

Instrument types

TypeUse when
CounterA value that only goes up — requests served, orders placed, emails sent
HistogramA distribution of values — request durations, payload sizes, queue wait time
GaugeA value that can go up or down — active connections, queue depth, cache size

Custom metrics

import Tracelit from "@tracelit/sdk";

// Counter
const ordersPlaced = Tracelit.metrics.counter("orders.placed", {
  description: "Total orders placed",
  unit: "{orders}",
});
ordersPlaced?.add(1, { currency: "USD", channel: "web" });

// Histogram
const apiLatency = Tracelit.metrics.histogram("external.api.duration", {
  description: "External API call duration",
  unit: "ms",
});
const start = Date.now();
await callExternalApi();
apiLatency?.record(Date.now() - start, { service: "stripe" });

// Gauge
const queueDepth = Tracelit.metrics.gauge("job_queue.depth", {
  description: "Number of pending background jobs",
  unit: "{jobs}",
});
queueDepth?.record(await queue.pendingCount(), { queue: "default" });

Observable gauges

Use an observable gauge when the value is expensive to compute and should only be read on each export interval:
Node.js
const queueGauge = Tracelit.metrics.observableGauge("message.queue.size", {
  description: "Estimated message queue size",
  unit: "{messages}",
});

queueGauge?.addCallback((result) => {
  result.observe(getQueueSize(), { queue: "events" });
});

Automatic metrics

Once the SDK starts, the following metrics are collected with no extra code:
MetricTypeDescriptionInterval
process.memory.rssGaugeProcess RSS memory (MB)60 s
process.event_loop.lagHistogramNode.js event loop lag (ms)30 s
http.server.request.countCounterTotal HTTP requests (with Express middleware)
http.server.request.durationHistogramRequest duration (ms)
http.server.error.countCounter5xx responses
Add the Express middleware to enable HTTP metrics:
app.use(Tracelit.expressMetricsMiddleware()); // add before routes

Viewing metrics

All metrics are available in the Metrics tab of your service in the Tracelit dashboard. You can:
  • Plot any metric by name with custom time ranges and aggregations
  • Overlay metrics from multiple services on a single chart
  • Set alert thresholds on any metric — see Incidents

Learn more

Distributed tracing

Traces and metrics share the same SDK — no extra setup.

Incidents

Metric anomalies and thresholds can trigger incidents automatically.