Skip to main content
Openfuse
Concepts

Automatic Metrics

What the SDK collects and how it works

Every protect() call records execution metrics automatically. Use protect() and metrics appear on your Openfuse dashboard. No setup required.

What's collected

MetricDescription
Success countSuccessful protect() executions
Failure countExecutions that threw an error
Timeout countExecutions that exceeded the timeout
Latency (p50)Median execution time
Latency (p95)95th percentile execution time
Latency (p99)99th percentile execution time

Window-based aggregation

Metrics are grouped into time windows (default: 10 seconds). Within each window, the SDK accumulates counts and collects latency samples.

Periodic flush

Every 15 seconds (default), the SDK sends completed windows to Openfuse in a single batch. In-progress windows are kept until they complete.

Reservoir sampling

To keep memory bounded, the SDK uses reservoir sampling to maintain a fixed number of latency samples per window (default: 1,000). This gives accurate percentile estimates at thousands of requests per second.

Instance deduplication

Each SDK instance has a unique ID to prevent double-counting. The SDK auto-detects your platform:

PlatformSource
AWS LambdaAWS_LAMBDA_LOG_STREAM_NAME
ECSECS_CONTAINER_METADATA_URI_V4
KubernetesKUBERNETES_SERVICE_HOST + pod name
Google Cloud RunK_SERVICE + K_REVISION
Fly.ioFLY_ALLOC_ID
RailwayRAILWAY_REPLICA_ID
RenderRENDER_INSTANCE_ID
HerokuDYNO
Otherhostname-pid-random

Override this with a custom instanceId in the client constructor.

Configure metrics

Default settings come from the server. Override them locally:

const openfuse = new OpenfuseCloud({
  system: 'payments',
  clientId: 'YOUR_CLIENT_ID',
  clientSecret: 'YOUR_CLIENT_SECRET',
  metrics: {
    windowSizeMs: 10_000,
    flushIntervalMs: 15_000,
    maxLatencySamples: 1_000,
    enabled: true,
  },
})

See Production for tuning advice.

On this page