Labels
Attach key-value labels such as tenant, job or operation to recorded requests, understand merge order and automatic labels, and use them to filter in the app and with MCP.
Labels are string key-value pairs on a recorded request. They are how you find requests by what they belong to - a tenant, a job, an operation - rather than by URL alone. You can filter by labels in the app, in MCP and in the group-by and top-values summaries.
Setting labels
There are four places, and they merge per key. A later source wins over an earlier one for the same key:
- Automatic labels (below)
labelsof the inspector configuration- The context set around a block of code
- Labels of a single request
import { create_inspector, with_labels } from '@inspector-rest/sdk';
const inspector = create_inspector({ server_key, labels: { env: 'production' } }); // 2
await with_labels({ tenant: 'acme', job: 'sync' }, async () => { // 3
await axios.get(url); // tenant=acme, job=sync
await axios.get(url, { inspector_labels: { op: 'list' } }); // 4, plus 2 and 3
});use InspectorRest\Labels;
$inspector = new Inspector(['server_key' => $key, 'labels' => ['env' => 'production']]); // 2
Labels::with(['tenant' => 'acme', 'job' => 'sync'], function () use ($client) { // 3
$client->get($url); // tenant=acme, job=sync
$client->get($url, ['inspector_labels' => ['op' => 'list']]); // 4, plus 2 and 3
});Values are converted to strings, and empty values are dropped. Labels are resolved once per request, when the request starts.
Concurrency
In Node.js, with_labels uses AsyncLocalStorage (also on Cloudflare Workers with nodejs_compat). The labels follow the async call tree, so concurrent flows never see each other’s labels. Where AsyncLocalStorage is not available, with_labels applies to the synchronous part of the callback only.
In PHP the context is synchronous and applies to code that runs inside the callback.
Automatic labels
The SDKs add labels that describe where a request came from. In the app they carry an auto badge.
| Label | Value |
|---|---|
server_host | The host name of the machine. |
app_package | The name of the nearest package (package.json, or composer.json in PHP) above the code that created the inspector. |
app_commit | The 12-character commit of the same package: the repository’s HEAD, else the commit your package manager locked for a git dependency, else the GIT_COMMIT, COMMIT_SHA or SOURCE_VERSION environment variable. |
Automatic labels are resolved once at startup; nothing is read on the request path. Runtimes without a file system add none. app_commit lets you tell which deployment made a request.
Limits
A label key can have up to 128 characters and a value up to 512 characters. Keep values reasonably low in variety where you can: fields that take many different values (an id per request) are searched by prefix instead of listed.
Using labels
- App: every label key gets its own searchable filter in the filter panel. In the request details, clicking a label adds it as a filter.
- MCP: use
top_valueswithdimension: "label_keys"to discover keys,label:<key>to list values, thelabelsfilter (["tenant:acme"]) to filter andgroup_by: ["label:tenant"]to compare. See Shared filters. - Filter rule: values of the same key are OR, different keys are AND.
keyalone means “the label exists”.
Good label keys
tenant,customer,account: who the call was for.job,queue,task: which background work made the call.oporoperation: what the code was doing.releaseorregion, ifapp_commitandserver_hostare not enough.
Do not put secrets or personal data in labels: they are shown in lists and filters.