Stalker Getting started Docs GitLab Hub

SlopKit Stalker

See what your running service did, without changing its code

Stalker watches a service while it runs and records its traces, logs and CPU profiles. It can also record which functions ran for a given request. Everything goes to rat, which stores it and answers queries about it.

No published release yet. You run Stalker from a checkout of the public repository. Cloning needs no account.

Function Coverage per Request Key
$ PORT=8080 STALKER_COVERAGE=1 node \
    --require ./packages/node/register.cjs \
    examples/node-server.cjs
listening 8080

$ curl -H 'baggage: hunt.scenario=signup,hunt.step=1' \
    localhost:8080/path-a
$ curl -H 'baggage: hunt.scenario=signup,hunt.step=2' \
    localhost:8080/path-b
{"path":"a"}{"path":"b"}

$ curl -s 'localhost:7410/v1/coverage?scenario=signup&step=1' \
    | jq ...
{"name":"onlyInA","line":18,"count":1}
$ curl -s 'localhost:7410/v1/coverage?scenario=signup&step=2' \
    | jq ...
{"name":"onlyInB","line":21,"count":1}

Real output from Getting started, shortened. The server file has no Stalker code.

What you get

A Sensor loads next to your product, or watches it from the kernel, and sends what it sees to rat.

No change to your code

A Node or Bun service loads one preload module. The Rust Sensor needs one line and a special build. The Kernel Sensors need neither.

Requests you can follow

Stalker passes traceparent and baggage along on every outgoing HTTP call made while serving a request. A request tagged with a Scenario and Step stays tagged across services.

The functions a request ran

With Function Coverage on, you ask rat which functions ran for one Scenario and Step. Hunt uses this for its Mapping Runs.

Logs in context

console.log, info, warn, error and debug are also sent as log records inside the active trace. Your console output stays as it was.

Safe to leave on

If rat is down, Stalker prints one error to stderr and drops the data. The product keeps running.

One place to read it back

Stalker has no database and no query API. Every Sensor sends to rat, so every Signal is read back from rat.

The Sensors

Each Sensor watches one kind of running software. Pick by runtime, or watch the whole node from the kernel.

Node and Bun

One Node or Bun process. Traces, logs and Function Coverage.

Your product needs: nothing. Load one preload module.

node --require @slopkit/stalker/register app.js

Rust

One Rust service. Function Coverage.

Your product needs: an Instrumented Build and one line that adds a layer to your server.

.layer(coverage.layer())

Kernel Sensors

OBI and the eBPF profiler. Every process on a node, in any language. Spans and CPU profiles.

Your product needs: nothing. Runs as a Kubernetes DaemonSet, or as local processes with root.

kubectl apply -k deploy/kubernetes

A Kernel Sensor sees requests as bytes only, so it cannot read your product's own context. It reads the Request Key from the first request that carries it, and the rest of that trace is found by trace id.

One request, followed

The Request Key rides in the baggage header. Every Sensor files what it records under that key.

A request with a Request Key

baggage: hunt.scenario=signup,hunt.step=3, from Hunt or from curl.

Your service, with a Sensor

Spans, log records and Function Coverage carry hunt.scenario and hunt.step.

rat

Stores every Signal and answers GET /v1/coverage?scenario=signup&step=3.

Start rat first. Then load the Node Sensor from a checkout of the repository and run the example server:

PORT=8080 STALKER_COVERAGE=1 node --require ./packages/node/register.cjs examples/node-server.cjs

Send a request that carries a Request Key:

curl -H 'traceparent: 00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01' \
     -H 'baggage: hunt.scenario=signup,hunt.step=3' localhost:8080/work

The server span, its outgoing call and the log records arrive in rat with hunt.scenario and hunt.step as attributes. Because STALKER_COVERAGE=1 is set, rat also files the functions that ran under that Request Key. The full steps, with output, are on Getting started.

Limits

Read these before you rely on it.

Works with the rest of SlopKit

More at slopkit.dev.

Words used on this site

Sensor
The part of Stalker that watches one kind of running software and produces data from it without code changes. There is one for Node and Bun, one for Rust, and two Kernel Sensors that watch every process on a machine.
Signal
One kind of data a Sensor produces: traces, logs, continuous CPU profiles, or Function Coverage.
Function Coverage
Which functions, and in which files, ran while serving one request or a group of requests that share a Request Key.
Request Key
The identity Stalker files a request's Signals under. It comes from the request's traceparent and baggage headers, for example a Hunt Scenario and Step.
rat
The SlopKit collector and store that every Signal goes to. Stalker stores and queries nothing itself.

Load Stalker into a Node server and read back what ran.

Getting started runs rat and the Node Sensor from source and reads Function Coverage per Request Key. Settings for every Sensor are in Docs.