Get the first traces and metrics from a Node.js service into Sherlock in about ten minutes.
This page takes a Node.js service with no telemetry to first data in Sherlock. The full path, with the from-code start, deployment, and verification, is in End-to-end steps.
In Sherlock, open Settings and then Collector. The Collector Credentials card shows two values.
Endpoint. Click the copy button.
Bearer Token. Click Reveal, then copy it.
Decide the value of the env attribute for this service, prod or dev. Sherlock routes data into a source by this value; Environments lists the accepted values.
Settings → Collector → Collector Credentials
2
Install the package
npm install @sherlock-labs/otel
The package needs Node.js 20 or later, and 20.6 or later for ES modules. It brings its own OpenTelemetry dependencies. Do not add @opentelemetry/* packages yourself. Type definitions are included.
The SDK is in alpha. Until the package is on a public registry, Sherlock provides it as a tarball. Put the tarball in your repository, point the dependency at it, and run npm install again:
The SDK patches libraries at the moment they load, so it must load first. How depends on your module system.
ES modules
CommonJS
Your entry is .mjs, or package.json has "type": "module". A line-1 import is not enough here: static imports are linked before any code runs, so the patches would arrive too late. Register a loader hook with --import instead.Create otel.mjs next to your entrypoint:
// otel.mjsimport { register } from 'node:module';register('@opentelemetry/instrumentation/hook.mjs', import.meta.url);await import('@sherlock-labs/otel/register');
Run your app with it, and put the same command in your start script:
@opentelemetry/instrumentation is installed with the SDK. You do not add it. In a container, set NODE_OPTIONS="--import ./otel.mjs" instead of changing the command.
Your entry is .cjs, or package.json has no "type" field. TypeScript with module: NodeNext and no "type" emits CommonJS. Add one line as the first line of your entrypoint:
// index.js — line 1, alwaysrequire('@sherlock-labs/otel/register');const express = require('express');// the rest of your app
A library that loads before this line is never traced, and nothing warns you. If you bundle your app, check the built output.
Registering installs the patches. They record nothing until the pipelines start.
The register entry starts the pipelines on its own when it finds SHERLOCK_ACCESS_TOKEN and OTEL_SERVICE_NAME. There is no code to write.The SDK ships with a default endpoint. Compare it with the Endpoint on Settings → Collector, and set SHERLOCK_ENDPOINT to that value when they differ.
5
Send some requests
Hit a few routes of your service.
curl http://localhost:3000/hello
6
See the data in Sherlock
Traces. Open Traces. Your service name appears within about five seconds. Spans leave in batches, so keep the app running. A process that exits without stop() drops the pending batch. Open a trace to see the request and its spans.
Metrics. Open Metrics. http.server.request.duration appears after the first export interval, 30 seconds by default. The catalog refreshes every 60 seconds, so allow about a minute.
Logs. If your service logs with pino, each line written inside a request now carries trace_id, span_id, and trace_flags. The SDK does not ship logs. Ship and correlate logs shows the two ways to send them.
This Express app is the quickstart plus one custom histogram with an exemplar and a clean shutdown. Save it as app.mjs next to the otel.mjs preload from step 3 and run node --import ./otel.mjs app.mjs.
// app.mjs — registered through --import ./otel.mjs, so no register import hereimport { defineMeter, stop } from '@sherlock-labs/otel';import { applyMetricsMiddleware } from '@sherlock-labs/otel/express';import express from 'express';const m = defineMeter('app');const workDuration = m.histogram('app.work.duration'); // unit s, seconds bucketsconst app = express();app.use(applyMetricsMiddleware()); // app.http.server.count / .errors / .durationapp.get('/hello', (_req, res) => { res.json({ hello: 'world' });});app.get('/work', async (_req, res) => { const jobId = `job-${Math.round(Math.random() * 1e6)}`; const startedAt = performance.now(); await new Promise((resolve) => setTimeout(resolve, 100 + Math.random() * 200)); const seconds = (performance.now() - startedAt) / 1000; // 2nd argument: low-cardinality metric attributes. // 3rd argument: high-cardinality exemplar attributes. workDuration.recordWithExemplar(seconds, { kind: 'report' }, { jobId }); res.json({ jobId, seconds });});const server = app.listen(3000);process.on('SIGTERM', async () => { server.close(); await stop(); // flushes the last metric interval and the pending span batch process.exit(0);});
Look at the first lines of your process output. With no token, the SDK logs one line and stays off:
[otel] sherlock: no access token (SHERLOCK_ACCESS_TOKEN) — telemetry stays off
A rejected token shows at the default log level as an export failure whose message ends in Unauthorized. Compare the token with Settings → Collector. OTEL_LOG_LEVEL=debug shows every export attempt.
Bare GET spans, and no http.route on the HTTP metric
The app is an ES module and the SDK was registered with an import instead of the --import preload. Go back to step 3.
{"docsConfig":{"theme":"luma","$schema":"https://mintlify.com/docs.json","name":"Sherlock","description":"Sherlock documentation: send logs, traces, and metrics from your services and follow a spike from a chart to a trace to the logs.","colors":{"primary":"#262626","light":"#E5E5E5","dark":"#171717"},"logo":{"light":"https://mintcdn.com/sherlock-c8721ead/hBlHCz8EH4O7570h/logo/light.png?fit=max\u0026auto=format\u0026n=hBlHCz8EH4O7570h\u0026q=85\u0026s=ecd14ef37115e0f5fa60edc05bf7b8d8","dark":"https://mintcdn.com/sherlock-c8721ead/hBlHCz8EH4O7570h/logo/dark.png?fit=max\u0026auto=format\u0026n=hBlHCz8EH4O7570h\u0026q=85\u0026s=b735873e37d47094881a1a81b7dddeb2"},"favicon":"https://mintcdn.com/sherlock-c8721ead/BDX1k4Rk66uQbBT0/favicon.png?fit=max\u0026auto=format\u0026n=BDX1k4Rk66uQbBT0\u0026q=85\u0026s=8bd3274f8a200b1698e19aa7fc01b8eb","background":{"color":{"light":"#FFFFFF","dark":"#0A0A0A"}},"navbar":{"primary":{"type":"button","label":"Open Sherlock","href":"https://sherlocklabs.dev"}},"footer":{"socials":{"github":"https://github.com/sherlock-labs-dev"}},"fonts":{"family":"Geist"},"contextual":{"options":["copy","view","chatgpt","claude","perplexity","mcp","add-mcp","cursor","vscode"],"display":"header"},"markdown":{"instructions":["Sherlock documentation. In Node.js examples prefer the Sherlock SDK for Node.js (@sherlock-labs/otel).","In Go examples use the upstream OpenTelemetry Go SDK exactly as shown on /sdk/go/setup and /sdk/go/configuration; Sherlock has no Go distribution.","Two MCP servers exist. This documentation's search server is at https://docs.sherlocklabs.dev/mcp. Sherlock's data server, for a user's own logs, traces, and metrics, is at https://mcp.sherlocklabs.dev/mcp and is described at /explore/mcp."]},"styling":{"latex":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"sherlock-c8721ead","hasAudioNarration":false,"actualSubdomain":"sherlock-c8721ead","customDomains":["docs.sherlocklabs.dev"],"gitSource":{"type":"github","owner":"sherlock-labs-dev","repo":"docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"chroma":{"latestBuiltDeploymentHistoryId":"6adba9ff0713a593f0a87ab3","collectionId":"9509c3f3-9abd-4716-a636-1fd7b071fc6f","liveDeploymentHistoryId":"6adba9ff0713a593f0a87ab3","schemaVersion":"v3"},"entitlements":{"AI_CHAT":{"status":"DISABLED"}},"buildId":"6adba9ff0713a593f0a87ab3","clientVersion":"0.0.4067","searchFilterCounts":[{"language":"default","tag":"Node.js SDK","count":6},{"language":"default","tag":"Send data","count":6},{"language":"default","tag":"Go SDK","count":3}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":true},"customCss":[{"filePath":"style.css","content":"#navigation-items a[aria-current=\"page\"]{background-color:#f2f2f2;border-radius:0.5rem}#navigation-items a:not([aria-current=\"page\"]):hover{background-color:#f7f7f7;border-radius:0.5rem}html.dark #navigation-items a[aria-current=\"page\"],[data-theme=\"dark\"] #navigation-items a[aria-current=\"page\"]{background-color:#2a2a2a}html.dark #navigation-items a:not([aria-current=\"page\"]):hover,[data-theme=\"dark\"] #navigation-items a:not([aria-current=\"page\"]):hover{background-color:#1c1c1c}#navigation-items .sidebar-group-header{text-transform:none}@media (min-width: 1024px){#navbar div:has(>.topbar-right-container){position:relative}#navbar .topbar-right-container>div:has(>#search-bar-entry){position:absolute;left:50%;top:50%;transform:translate(-50%, -50%);flex:0 0 auto!important}#navbar #search-bar-entry{min-width:20rem;height:2.25rem;box-shadow:inset 0 0 0 1px rgba(0, 0, 0, 0.08)}html.dark #navbar #search-bar-entry,[data-theme=\"dark\"] #navbar #search-bar-entry{box-shadow:inset 0 0 0 1px rgba(255, 255, 255, 0.1)}#navbar #search-bar-entry>div{flex:1 1 auto;padding-left:0.875rem}#navbar #search-bar-entry .truncate{display:block}#navbar #search-bar-entry>span{display:inline-flex;margin-right:0.75rem}}@media (min-width: 1024px){#content-area{max-width:56rem;margin-left:auto;margin-right:auto}}@media (max-width: 1439px){#content-side-layout{display:none}}.tx{--tx-radius: 0.625rem;--tx-bg: oklch(1 0 0);--tx-fg: oklch(0.145 0 0);--tx-card: oklch(1 0 0);--tx-primary: oklch(0.205 0 0);--tx-primary-fg: oklch(0.985 0 0);--tx-muted-bg: oklch(0.97 0 0);--tx-muted: oklch(0.556 0 0);--tx-border: oklch(0.922 0 0);--tx-ring: oklch(0.708 0 0);--tx-bad: oklch(0.577 0.245 27.325);--tx-prose: oklch(0.3 0 0);--tx-grid: oklch(0.94 0 0);--tx-cumulative: oklch(0.398 0.07 227.392);--tx-delta: oklch(0.6 0.118 184.704);color:var(--tx-fg);font-size:14px;line-height:1.55}html.dark .tx,[data-theme=\"dark\"] .tx{--tx-bg: oklch(0.145 0 0);--tx-fg: oklch(0.985 0 0);--tx-card: oklch(0.205 0 0);--tx-primary: oklch(0.922 0 0);--tx-primary-fg: oklch(0.205 0 0);--tx-muted-bg: oklch(0.269 0 0);--tx-muted: oklch(0.708 0 0);--tx-border: oklch(1 0 0 / 10%);--tx-ring: oklch(0.556 0 0);--tx-bad: oklch(0.704 0.191 22.216);--tx-prose: oklch(0.85 0 0);--tx-grid: oklch(1 0 0 / 7%);--tx-cumulative: oklch(0.769 0.188 70.08);--tx-delta: oklch(0.696 0.17 162.48)}.tx *,.tx *::before,.tx *::after{box-sizing:border-box}.tx-mono,.tx-code,.tx-num{font-family:\"Geist Mono\", ui-monospace, SFMono-Regular, Menlo, monospace;font-variant-numeric:tabular-nums}.tx-svgtext{fill:var(--tx-muted);font-family:\"Geist Mono\", ui-monospace, monospace}.tx-svgtext-fg{fill:var(--tx-fg)}.tx-svgtext-bad{fill:var(--tx-bad)}.tx-svgsans{font-family:\"Geist\", ui-sans-serif, sans-serif}.tx-code{font-size:0.875em;background:var(--tx-muted-bg);border:1px solid var(--tx-border);border-radius:6px;padding:1px 5px;overflow-wrap:anywhere}.tx-muted{color:var(--tx-muted)}.tx-fig{border:1px solid var(--tx-border);border-radius:calc(var(--tx-radius) + 6px);background:var(--tx-card);padding:20px;margin:20px 0 12px}.tx-fig-head{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px 16px;margin-bottom:16px}.tx-fig-title,.tx [data-as=\"p\"].tx-fig-title{font-size:14px;font-weight:600;margin:0}.tx-caption{font-size:13px;line-height:1.55;color:var(--tx-muted);margin:12px 0 0}.tx-legend{display:flex;flex-wrap:wrap;gap:6px 16px;font-size:13px;color:var(--tx-muted)}.tx-legend span{display:inline-flex;align-items:center;gap:6px}.tx-sw{display:inline-block;width:10px;height:10px;border-radius:3px;flex:none}.tx-sw-cum{background:var(--tx-cumulative)}.tx-sw-del{background:var(--tx-delta)}.tx-sw-bad{background:var(--tx-bad)}.tx-tag{display:inline-flex;align-items:center;gap:6px;font-size:12px;font-weight:500;line-height:1;padding:5px 8px;border-radius:999px;border:1px solid var(--tx-border);background:var(--tx-bg);color:var(--tx-fg);white-space:nowrap}.tx-tag-bad{color:var(--tx-bad);border-color:color-mix(in oklch, var(--tx-bad) 35%, transparent);background:color-mix(in oklch, var(--tx-bad) 8%, transparent)}.tx-ico{width:14px;height:14px;flex:none;fill:none;stroke:currentColor;stroke-width:2.25;stroke-linecap:round;stroke-linejoin:round}.tx-controls{display:flex;flex-wrap:wrap;gap:8px}.tx-btn{font:inherit;font-size:13px;font-weight:500;line-height:1;height:32px;padding:0 12px;border-radius:calc(var(--tx-radius) - 2px);border:1px solid var(--tx-border);background:var(--tx-bg);color:var(--tx-fg);cursor:pointer;display:inline-flex;align-items:center;gap:6px}.tx-btn:hover{background:var(--tx-muted-bg)}.tx-btn-primary{background:var(--tx-primary);color:var(--tx-primary-fg);border-color:var(--tx-primary)}.tx-btn-primary:hover{background:color-mix(in oklch, var(--tx-primary) 90%, var(--tx-bg))}.tx-btn:focus-visible{outline:2px solid var(--tx-ring);outline-offset:2px}.tx-stream{display:grid;grid-template-columns:1fr auto;gap:12px;align-items:stretch}.tx-track{position:relative;overflow:hidden;min-height:64px;border:1px dashed var(--tx-border);border-radius:var(--tx-radius)}.tx-track::after{content:\"\";position:absolute;left:10px;right:10px;top:60%;border-top:1px solid var(--tx-grid)}.tx-track-label{position:absolute;left:10px;top:8px;font-size:12px;color:var(--tx-muted)}.tx-dot{position:absolute;left:-10px;width:8px;height:8px;border-radius:50%;background:var(--tx-fg);opacity:0.75;animation-duration:0.9s;animation-timing-function:linear;animation-fill-mode:forwards}@keyframes tx-travel-200{from{transform:translateX(0)}to{transform:translateX(200px)}}@keyframes tx-travel-300{from{transform:translateX(0)}to{transform:translateX(300px)}}@keyframes tx-travel-400{from{transform:translateX(0)}to{transform:translateX(400px)}}@keyframes tx-travel-500{from{transform:translateX(0)}to{transform:translateX(500px)}}@keyframes tx-travel-600{from{transform:translateX(0)}to{transform:translateX(600px)}}@keyframes tx-travel-700{from{transform:translateX(0)}to{transform:translateX(700px)}}@keyframes tx-travel-800{from{transform:translateX(0)}to{transform:translateX(800px)}}@keyframes tx-travel-900{from{transform:translateX(0)}to{transform:translateX(900px)}}@keyframes tx-travel-1000{from{transform:translateX(0)}to{transform:translateX(1000px)}}@keyframes tx-travel-1100{from{transform:translateX(0)}to{transform:translateX(1100px)}}@keyframes tx-travel-1200{from{transform:translateX(0)}to{transform:translateX(1200px)}}.tx-counter{min-width:170px;border:1px solid var(--tx-border);border-radius:var(--tx-radius);padding:10px 14px;background:var(--tx-bg)}.tx-k{font-size:12px;color:var(--tx-muted)}.tx-v{font-size:22px;font-weight:600;line-height:1.2}.tx-v2{font-size:14px;font-weight:500}.tx-intervals{display:grid;grid-template-columns:repeat(4, 1fr);gap:6px;margin:12px 0 16px}.tx-iv{font-size:12px;color:var(--tx-muted)}.tx-ivbar{height:6px;border-radius:3px;background:var(--tx-muted-bg);overflow:hidden;margin-bottom:4px}.tx-ivfill{height:100%;width:0;background:var(--tx-fg);opacity:0.55}.tx-pair{display:grid;grid-template-columns:1fr 1fr;gap:12px}.tx-panel{border:1px solid var(--tx-border);border-radius:var(--tx-radius);padding:14px;background:var(--tx-bg);min-width:0}.tx-panel-h{display:flex;align-items:center;gap:8px;font-weight:600;font-size:14px}.tx-panel-sub{font-size:13px;color:var(--tx-muted);margin:2px 0 10px}.tx-chips{display:flex;flex-wrap:wrap;align-items:center;gap:4px;min-height:30px;margin-bottom:6px}.tx-chipwrap{display:inline-flex;align-items:center;gap:4px}.tx-chip{font-family:\"Geist Mono\", monospace;font-variant-numeric:tabular-nums;font-size:13px;font-weight:500;padding:3px 8px;border-radius:6px;border:1px solid var(--tx-border);background:var(--tx-card)}.tx-chip-empty{color:var(--tx-muted);border-style:dashed;background:transparent}.tx-chip-new{box-shadow:0 0 0 2px var(--tx-ring)}.tx-arr{color:var(--tx-muted);font-size:12px}.tx-chart{width:100%}.tx-chart svg{display:block;overflow:visible}.tx-lanes{display:grid;gap:12px}.tx-lane{border:1px solid var(--tx-border);border-radius:var(--tx-radius);padding:14px;background:var(--tx-bg)}.tx-lane-h{font-size:14px;font-weight:600;margin-bottom:10px}.tx-flow{display:flex;flex-wrap:wrap;align-items:center;gap:8px}.tx-node{font-size:13px;padding:6px 10px;border-radius:8px;border:1px solid var(--tx-border);background:var(--tx-card);display:inline-flex;align-items:center;gap:6px;line-height:1.3}.tx-arrow{color:var(--tx-muted);display:inline-flex}.tx-fixrow{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin-top:10px;padding-top:10px;border-top:1px dashed var(--tx-border);font-size:13px}.tx-lbl{color:var(--tx-muted);min-width:52px}.tx-mem{display:grid;grid-template-columns:minmax(0, 1.6fr) repeat(3, minmax(0, 1fr));border:1px solid var(--tx-border);border-radius:var(--tx-radius);overflow:hidden;font-size:13px;background:var(--tx-bg)}.tx-mem>div{padding:8px 10px;border-bottom:1px solid var(--tx-border);min-width:0}.tx-mem-h{font-size:12px;color:var(--tx-muted);background:var(--tx-muted-bg)}.tx-mem-last{border-bottom:0!important}.tx-mem-series{overflow-wrap:anywhere;font-family:\"Geist Mono\", monospace;font-size:12px}.tx-mem-val{font-family:\"Geist Mono\", monospace;font-variant-numeric:tabular-nums;font-weight:500}.tx-math{display:block;font-size:11px;color:var(--tx-muted);font-weight:400}.tx-cols2{display:grid;grid-template-columns:1fr 1fr;gap:12px}.tx-lb{border:1px solid var(--tx-border);border-radius:var(--tx-radius);padding:14px;background:var(--tx-bg);min-width:0}.tx-lb-wrong{border-color:color-mix(in oklch, var(--tx-bad) 40%, var(--tx-border))}.tx-lb-h{display:flex;flex-wrap:wrap;justify-content:space-between;align-items:center;gap:6px;margin-bottom:10px}.tx-lb-h b{font-size:14px}.tx-rows{display:grid;grid-template-columns:auto auto 1fr 1fr;gap:6px 8px;align-items:center;font-size:13px}.tx-hd{font-size:11px;color:var(--tx-muted)}.tx-t{color:var(--tx-muted);font-family:\"Geist Mono\", monospace;font-size:12px}.tx-slot{border:1px solid var(--tx-border);border-radius:6px;padding:5px 7px;min-height:30px;font-family:\"Geist Mono\", monospace;font-size:12px;line-height:1.35;background:var(--tx-card)}.tx-slot-base{color:var(--tx-muted)}.tx-out{font-weight:600}.tx-out::before{content:\"\";display:inline-block;width:8px;height:8px;border-radius:2px;background:var(--tx-delta);margin-right:5px;vertical-align:0}.tx-total{display:flex;flex-wrap:wrap;align-items:baseline;justify-content:space-between;gap:4px 8px;margin-top:12px;padding-top:10px;border-top:1px solid var(--tx-border);font-size:13px}.tx-big{font-family:\"Geist Mono\", monospace;font-size:20px;font-weight:600}.tx-total-bad .tx-big{color:var(--tx-bad)}.tx-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}@media (max-width: 640px){.tx-fig{padding:14px}.tx-stream{grid-template-columns:1fr}.tx-counter{min-width:0;display:flex;gap:16px;align-items:baseline}.tx-pair,.tx-cols2{grid-template-columns:1fr}.tx-mem{grid-template-columns:repeat(3, minmax(0, 1fr))}.tx-mem-series-h{display:none}.tx-mem-series{grid-column:1 / -1;background:var(--tx-muted-bg)}}@media (prefers-reduced-motion: reduce){.tx-dot{animation:none;display:none}}"}],"page":{"pagePath":"sdk/nodejs/quickstart","slug":"/sdk/nodejs/quickstart","pageMetadata":{"title":"Quickstart","description":"Get the first traces and metrics from a Node.js service into Sherlock in about ten minutes.","icon":"rocket","href":"/sdk/nodejs/quickstart"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Get the first traces and metrics from a Node.js service into Sherlock in about ten minutes.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{Accordion,AccordionGroup,Card,CardGroup,CodeBlock,Frame,Heading,Note,OptimizedImage,Step,Steps,Tab,Tabs}=_components;if(!Accordion)_missingMdxReference(`Accordion`,true);if(!AccordionGroup)_missingMdxReference(`AccordionGroup`,true);if(!Card)_missingMdxReference(`Card`,true);if(!CardGroup)_missingMdxReference(`CardGroup`,true);if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Frame)_missingMdxReference(`Frame`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Note)_missingMdxReference(`Note`,true);if(!OptimizedImage)_missingMdxReference(`OptimizedImage`,true);if(!Step)_missingMdxReference(`Step`,true);if(!Steps)_missingMdxReference(`Steps`,true);if(!Tab)_missingMdxReference(`Tab`,true);if(!Tabs)_missingMdxReference(`Tabs`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`This page takes a Node.js service with no telemetry to first data in Sherlock. The full path, with the from-code start, deployment, and verification, is in `,_jsx(_components.a,{href:`/sdk/nodejs/add-telemetry`,children:`End-to-end steps`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`what-you’ll-learn`,children:`What you’ll learn`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`Where to find your collector credentials`}),`\n`,_jsx(_components.li,{children:`How to install and register the SDK`}),`\n`,_jsx(_components.li,{children:`The environment variables that start telemetry`}),`\n`,_jsx(_components.li,{children:`What first data looks like in Sherlock`}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`prerequisites`,children:`Prerequisites`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`A Sherlock organization, and access to `,_jsx(_components.strong,{children:`Settings → Collector`})]}),`\n`,_jsx(_components.li,{children:`A Node.js service on Node.js 20 or later, 20.6 or later for ES modules`}),`\n`,_jsx(_components.li,{children:`The SDK tarball, until the package is on a public registry`}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`steps`,children:`Steps`}),`\n`,_jsxs(Steps,{children:[_jsxs(Step,{title:`Get your credentials`,children:[_jsxs(_components.p,{children:[`In Sherlock, open `,_jsx(_components.strong,{children:`Settings`}),` and then `,_jsx(_components.strong,{children:`Collector`}),`. The `,_jsx(_components.strong,{children:`Collector Credentials`}),` card shows two values.`]}),_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Endpoint.`}),` Click the copy button.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Bearer Token.`}),` Click `,_jsx(_components.strong,{children:`Reveal`}),`, then copy it.`]}),`\n`]}),_jsxs(_components.p,{children:[`Decide the value of the `,_jsx(_components.code,{children:`env`}),` attribute for this service, `,_jsx(_components.code,{children:`prod`}),` or `,_jsx(_components.code,{children:`dev`}),`. Sherlock routes data into a source by this value; `,_jsx(_components.a,{href:`/send-data/environments`,children:`Environments`}),` lists the accepted values.`]}),_jsx(Frame,{caption:`Settings → Collector → Collector Credentials`,children:_jsx(OptimizedImage,{src:`https://mintcdn.com/sherlock-c8721ead/hBlHCz8EH4O7570h/images/collector-credentials.jpg?fit=max\u0026auto=format\u0026n=hBlHCz8EH4O7570h\u0026q=85\u0026s=2e34d023b4c516bbdfaeceb07f353565`,alt:`The Collector page, with the Endpoint field, a copy button, and the masked Bearer Token with a reveal button`,\"data-og-width\":`1407`,width:`1407`,\"data-og-height\":`840`,height:`840`,\"data-path\":`images/collector-credentials.jpg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/sherlock-c8721ead/hBlHCz8EH4O7570h/images/collector-credentials.jpg?w=280\u0026fit=max\u0026auto=format\u0026n=hBlHCz8EH4O7570h\u0026q=85\u0026s=eb385445a9ae6263ea5a1fde5cef4f0e 280w, https://mintcdn.com/sherlock-c8721ead/hBlHCz8EH4O7570h/images/collector-credentials.jpg?w=560\u0026fit=max\u0026auto=format\u0026n=hBlHCz8EH4O7570h\u0026q=85\u0026s=701e5583c777f62e48d102c1fe3a0d19 560w, https://mintcdn.com/sherlock-c8721ead/hBlHCz8EH4O7570h/images/collector-credentials.jpg?w=840\u0026fit=max\u0026auto=format\u0026n=hBlHCz8EH4O7570h\u0026q=85\u0026s=ac549efb830aa8b4e8271876947ee3c2 840w, https://mintcdn.com/sherlock-c8721ead/hBlHCz8EH4O7570h/images/collector-credentials.jpg?w=1100\u0026fit=max\u0026auto=format\u0026n=hBlHCz8EH4O7570h\u0026q=85\u0026s=a95a15b3c70f46893ca9c43e87f535ab 1100w, https://mintcdn.com/sherlock-c8721ead/hBlHCz8EH4O7570h/images/collector-credentials.jpg?w=1650\u0026fit=max\u0026auto=format\u0026n=hBlHCz8EH4O7570h\u0026q=85\u0026s=e85c7fbf9228879315ad4fee2ec8808c 1650w, https://mintcdn.com/sherlock-c8721ead/hBlHCz8EH4O7570h/images/collector-credentials.jpg?w=2500\u0026fit=max\u0026auto=format\u0026n=hBlHCz8EH4O7570h\u0026q=85\u0026s=55664e9c2626c7bcb9d11bf35c7088c7 2500w`})})]}),_jsxs(Step,{title:`Install the package`,children:[_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` @sherlock-labs/otel`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`The package needs Node.js 20 or later, and 20.6 or later for ES modules. It brings its own OpenTelemetry dependencies. Do not add `,_jsx(_components.code,{children:`@opentelemetry/*`}),` packages yourself. Type definitions are included.`]}),_jsxs(Note,{children:[_jsxs(_components.p,{children:[`The SDK is in alpha. Until the package is on a public registry, Sherlock provides it as a tarball. Put the tarball in your repository, point the dependency at it, and run `,_jsx(_components.code,{children:`npm install`}),` again:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"@sherlock-labs/otel\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"file:vendor/sherlock-labs-otel-0.2.6.tgz\"`})]}),`\n`]})})})]})]}),_jsxs(Step,{title:`Register the SDK before your app loads`,children:[_jsx(_components.p,{children:`The SDK patches libraries at the moment they load, so it must load first. How depends on your module system.`}),_jsxs(Tabs,{children:[_jsxs(Tab,{title:`ES modules`,id:`es-modules`,children:[_jsxs(_components.p,{children:[`Your entry is `,_jsx(_components.code,{children:`.mjs`}),`, or `,_jsx(_components.code,{children:`package.json`}),` has `,_jsx(_components.code,{children:`\"type\": \"module\"`}),`. A line-1 import is `,_jsx(_components.strong,{children:`not enough`}),` here: static imports are linked before any code runs, so the patches would arrive too late. Register a loader hook with `,_jsx(_components.code,{children:`--import`}),` instead.`]}),_jsxs(_components.p,{children:[`Create `,_jsx(_components.code,{children:`otel.mjs`}),` next to your entrypoint:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`4`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// otel.mjs`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`register`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'node:module'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`register`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'@opentelemetry/instrumentation/hook.mjs'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#9CDCFE`},children:`meta`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`url`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'@sherlock-labs/otel/register'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`Run your app with it, and put the same command in your `,_jsx(_components.code,{children:`start`}),` script:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`node`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --import`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` ./otel.mjs`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` index.js`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"scripts\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: { `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"start\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"node --import ./otel.mjs index.js\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})]}),`\n`]})})}),_jsxs(_components.p,{children:[_jsx(_components.code,{children:`@opentelemetry/instrumentation`}),` is installed with the SDK. You do not add it. In a container, set `,_jsx(_components.code,{children:`NODE_OPTIONS=\"--import ./otel.mjs\"`}),` instead of changing the command.`]})]}),_jsxs(Tab,{title:`CommonJS`,id:`commonjs`,children:[_jsxs(_components.p,{children:[`Your entry is `,_jsx(_components.code,{children:`.cjs`}),`, or `,_jsx(_components.code,{children:`package.json`}),` has no `,_jsx(_components.code,{children:`\"type\"`}),` field. TypeScript with `,_jsx(_components.code,{children:`module: NodeNext`}),` and no `,_jsx(_components.code,{children:`\"type\"`}),` emits CommonJS. Add one line as the `,_jsx(_components.strong,{children:`first line`}),` of your entrypoint:`]}),_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`5`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// index.js — line 1, always`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`require`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'@sherlock-labs/otel/register'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` express`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` require`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'express'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// the rest of your app`})}),`\n`]})})}),_jsx(_components.p,{children:`A library that loads before this line is never traced, and nothing warns you. If you bundle your app, check the built output.`})]})]}),_jsx(_components.p,{children:`Registering installs the patches. They record nothing until the pipelines start.`})]}),_jsxs(Step,{title:`Set three environment variables and run`,children:[_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` SHERLOCK_ACCESS_TOKEN`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=\u003c`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`the`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` bearer`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` token`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` OTEL_SERVICE_NAME`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`checkout-api`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`export`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` OTEL_RESOURCE_ATTRIBUTES`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`env`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`prod`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`node`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` --import`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` ./otel.mjs`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` index.js`}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # ES modules`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`node`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` index.js`}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` # CommonJS`})]}),`\n`]})})}),_jsxs(_components.p,{children:[`The register entry starts the pipelines on its own when it finds `,_jsx(_components.code,{children:`SHERLOCK_ACCESS_TOKEN`}),` and `,_jsx(_components.code,{children:`OTEL_SERVICE_NAME`}),`. There is no code to write.`]}),_jsxs(_components.p,{children:[`The SDK ships with a default endpoint. Compare it with the Endpoint on `,_jsx(_components.strong,{children:`Settings → Collector`}),`, and set `,_jsx(_components.code,{children:`SHERLOCK_ENDPOINT`}),` to that value when they differ.`]})]}),_jsxs(Step,{title:`Send some requests`,children:[_jsx(_components.p,{children:`Hit a few routes of your service.`}),_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` http://localhost:3000/hello`})]}),`\n`]})})})]}),_jsxs(Step,{title:`See the data in Sherlock`,children:[_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Traces.`}),` Open `,_jsx(_components.strong,{children:`Traces`}),`. Your service name appears within about five seconds. Spans leave in batches, so keep the app running. A process that exits without `,_jsx(_components.code,{children:`stop()`}),` drops the pending batch. Open a trace to see the request and its spans.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Metrics.`}),` Open `,_jsx(_components.strong,{children:`Metrics`}),`. `,_jsx(_components.code,{children:`http.server.request.duration`}),` appears after the first export interval, 30 seconds by default. The catalog refreshes every 60 seconds, so allow about a minute.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Logs.`}),` If your service logs with pino, each line written inside a request now carries `,_jsx(_components.code,{children:`trace_id`}),`, `,_jsx(_components.code,{children:`span_id`}),`, and `,_jsx(_components.code,{children:`trace_flags`}),`. The SDK does not ship logs. `,_jsx(_components.a,{href:`/sdk/nodejs/add-telemetry#10-ship-and-correlate-logs`,children:`Ship and correlate logs`}),` shows the two ways to send them.`]}),`\n`]}),_jsx(Frame,{caption:`Traces: your service and its requests`,children:_jsx(OptimizedImage,{src:`https://mintcdn.com/sherlock-c8721ead/hBlHCz8EH4O7570h/images/traces-list.jpg?fit=max\u0026auto=format\u0026n=hBlHCz8EH4O7570h\u0026q=85\u0026s=bb6ab67425ed8cdd053446b0a05a962c`,alt:`The Traces page listing requests of one service with span counts and durations`,\"data-og-width\":`1407`,width:`1407`,\"data-og-height\":`840`,height:`840`,\"data-path\":`images/traces-list.jpg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/sherlock-c8721ead/hBlHCz8EH4O7570h/images/traces-list.jpg?w=280\u0026fit=max\u0026auto=format\u0026n=hBlHCz8EH4O7570h\u0026q=85\u0026s=8fdb98cb9679fde7bc2ceb11466937bb 280w, https://mintcdn.com/sherlock-c8721ead/hBlHCz8EH4O7570h/images/traces-list.jpg?w=560\u0026fit=max\u0026auto=format\u0026n=hBlHCz8EH4O7570h\u0026q=85\u0026s=2895722f0e6e3871df684e1d398fe0cb 560w, https://mintcdn.com/sherlock-c8721ead/hBlHCz8EH4O7570h/images/traces-list.jpg?w=840\u0026fit=max\u0026auto=format\u0026n=hBlHCz8EH4O7570h\u0026q=85\u0026s=61827443cc2ddf3915126cef0ab954d0 840w, https://mintcdn.com/sherlock-c8721ead/hBlHCz8EH4O7570h/images/traces-list.jpg?w=1100\u0026fit=max\u0026auto=format\u0026n=hBlHCz8EH4O7570h\u0026q=85\u0026s=5e8142f5dccb1303451ddbd62f816989 1100w, https://mintcdn.com/sherlock-c8721ead/hBlHCz8EH4O7570h/images/traces-list.jpg?w=1650\u0026fit=max\u0026auto=format\u0026n=hBlHCz8EH4O7570h\u0026q=85\u0026s=8112051186ab9fc309f3fbe58b808dfa 1650w, https://mintcdn.com/sherlock-c8721ead/hBlHCz8EH4O7570h/images/traces-list.jpg?w=2500\u0026fit=max\u0026auto=format\u0026n=hBlHCz8EH4O7570h\u0026q=85\u0026s=242105f80af694cf0171fd44803189e9 2500w`})}),_jsx(Frame,{caption:`Metrics: http.server.request.duration`,children:_jsx(OptimizedImage,{src:`https://mintcdn.com/sherlock-c8721ead/hBlHCz8EH4O7570h/images/metrics-http-duration.jpg?fit=max\u0026auto=format\u0026n=hBlHCz8EH4O7570h\u0026q=85\u0026s=f2f2679aaad4494b7ea8d4e158949601`,alt:`The Metrics Explorer charting the p95 of http.server.request.duration`,\"data-og-width\":`1407`,width:`1407`,\"data-og-height\":`840`,height:`840`,\"data-path\":`images/metrics-http-duration.jpg`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/sherlock-c8721ead/hBlHCz8EH4O7570h/images/metrics-http-duration.jpg?w=280\u0026fit=max\u0026auto=format\u0026n=hBlHCz8EH4O7570h\u0026q=85\u0026s=ea01ef1b61eefa6937fb6f83656771df 280w, https://mintcdn.com/sherlock-c8721ead/hBlHCz8EH4O7570h/images/metrics-http-duration.jpg?w=560\u0026fit=max\u0026auto=format\u0026n=hBlHCz8EH4O7570h\u0026q=85\u0026s=00a3a63cf965fd9e27048c2a04902412 560w, https://mintcdn.com/sherlock-c8721ead/hBlHCz8EH4O7570h/images/metrics-http-duration.jpg?w=840\u0026fit=max\u0026auto=format\u0026n=hBlHCz8EH4O7570h\u0026q=85\u0026s=6f42f20f43d8b828a25f501cb4c610ff 840w, https://mintcdn.com/sherlock-c8721ead/hBlHCz8EH4O7570h/images/metrics-http-duration.jpg?w=1100\u0026fit=max\u0026auto=format\u0026n=hBlHCz8EH4O7570h\u0026q=85\u0026s=144e2723ff8a180fdbc8cbc5d536ae65 1100w, https://mintcdn.com/sherlock-c8721ead/hBlHCz8EH4O7570h/images/metrics-http-duration.jpg?w=1650\u0026fit=max\u0026auto=format\u0026n=hBlHCz8EH4O7570h\u0026q=85\u0026s=032db4ab44e201bffde293969b289ea1 1650w, https://mintcdn.com/sherlock-c8721ead/hBlHCz8EH4O7570h/images/metrics-http-duration.jpg?w=2500\u0026fit=max\u0026auto=format\u0026n=hBlHCz8EH4O7570h\u0026q=85\u0026s=a9868901d6282e3e4b9d09b7119ac8f8 2500w`})})]})]}),`\n`,_jsx(Heading,{level:`2`,id:`the-whole-thing-in-one-file`,children:`The whole thing in one file`}),`\n`,_jsxs(_components.p,{children:[`This Express app is the quickstart plus one custom histogram with an exemplar and a clean shutdown. Save it as `,_jsx(_components.code,{children:`app.mjs`}),` next to the `,_jsx(_components.code,{children:`otel.mjs`}),` preload from step 3 and run `,_jsx(_components.code,{children:`node --import ./otel.mjs app.mjs`}),`.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`33`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`33`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// app.mjs — registered through --import ./otel.mjs, so no register import here`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`defineMeter`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`stop`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '@sherlock-labs/otel'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`applyMetricsMiddleware`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '@sherlock-labs/otel/express'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` express`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'express'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` m`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` defineMeter`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'app'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` workDuration`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` m`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`histogram`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'app.work.duration'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`); `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// unit s, seconds buckets`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` app`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` express`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`app`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`use`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`applyMetricsMiddleware`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()); `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// app.http.server.count / .errors / .duration`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`app`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`get`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'/hello'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, (`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`_req`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`res`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` res`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`json`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({ `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`hello:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'world'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` });`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`app`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`get`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'/work'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`async`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`_req`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`res`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` jobId`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\" `job-\"}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`Math`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`round`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`Math`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`random`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`() `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 1e6`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`)`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` startedAt`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` performance`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`now`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` Promise`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`((`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`resolve`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` setTimeout`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`resolve`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`100`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` +`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` Math`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`random`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`() `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 200`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`));`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` seconds`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`performance`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`now`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`() `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`-`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` startedAt`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`/`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 1000`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // 2nd argument: low-cardinality metric attributes.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // 3rd argument: high-cardinality exemplar attributes.`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` workDuration`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`recordWithExemplar`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`seconds`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`kind:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'report'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }, { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`jobId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` });`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` res`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`json`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({ `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`jobId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`seconds`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` });`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` server`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` app`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`listen`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`3000`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`process`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`on`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'SIGTERM'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`async`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` () `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` server`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`close`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` stop`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(); `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// flushes the last metric interval and the pending span batch`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` process`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`exit`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`troubleshooting`,children:`Troubleshooting`}),`\n`,_jsxs(AccordionGroup,{children:[_jsxs(Accordion,{title:`Nothing arrives`,id:`nothing-arrives`,children:[_jsx(_components.p,{children:`Look at the first lines of your process output. With no token, the SDK logs one line and stays off:`}),_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`[otel] sherlock: no access token (SHERLOCK_ACCESS_TOKEN) — telemetry stays off`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),_jsxs(_components.p,{children:[`A rejected token shows at the default log level as an export failure whose message ends in `,_jsx(_components.code,{children:`Unauthorized`}),`. Compare the token with `,_jsx(_components.strong,{children:`Settings → Collector`}),`. `,_jsx(_components.code,{children:`OTEL_LOG_LEVEL=debug`}),` shows every export attempt.`]})]}),_jsx(Accordion,{title:`Bare GET spans, and no http.route on the HTTP metric`,id:`bare-get-spans-and-no-http-route-on-the-http-metric`,children:_jsxs(_components.p,{children:[`The app is an ES module and the SDK was registered with an import instead of the `,_jsx(_components.code,{children:`--import`}),` preload. Go back to step 3.`]})})]}),`\n`,_jsxs(_components.p,{children:[`More cases are in `,_jsx(_components.a,{href:`/sdk/nodejs/troubleshooting`,children:`Troubleshooting`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`related-topics`,children:`Related topics`}),`\n`,_jsxs(CardGroup,{cols:2,children:[_jsx(Card,{title:`End-to-end steps`,icon:`list-ol`,href:`/sdk/nodejs/add-telemetry`,children:_jsx(_components.p,{children:`Start from code, deploy, verify, and operate.`})}),_jsx(Card,{title:`Custom metrics`,icon:`chart-line`,href:`/sdk/nodejs/custom-metrics`,children:_jsx(_components.p,{children:`Define your own instruments with exemplars.`})}),_jsx(Card,{title:`Custom spans`,icon:`diagram-project`,href:`/sdk/nodejs/manual-spans`,children:_jsx(_components.p,{children:`Trace queue jobs and database calls.`})}),_jsx(Card,{title:`Troubleshooting`,icon:`wrench`,href:`/sdk/nodejs/troubleshooting`,children:_jsx(_components.p,{children:`Symptom, cause, and fix.`})})]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Quickstart","description":"Get the first traces and metrics from a Node.js service into Sherlock in about ten minutes.","icon":"rocket","href":"/sdk/nodejs/quickstart"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"What you’ll learn","slug":"what-you’ll-learn","depth":2,"children":[]},{"title":"Prerequisites","slug":"prerequisites","depth":2,"children":[]},{"title":"Steps","slug":"steps","depth":2,"children":[]},{"title":"The whole thing in one file","slug":"the-whole-thing-in-one-file","depth":2,"children":[]},{"title":"Troubleshooting","slug":"troubleshooting","depth":2,"children":[]},{"title":"Related topics","slug":"related-topics","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"sherlock-c8721ead","siteName":"Sherlock","title":"Quickstart - Sherlock","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-09-27T04:56:45.730Z","originalFileLocation":"sdk/nodejs/quickstart.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Get the first traces and metrics from a Node.js service into Sherlock in about ten minutes.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Sherlock\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/sherlock-c8721ead/CM50KmpJ1ACM1to1/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/sherlock-c8721ead/CM50KmpJ1ACM1to1/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/sherlock-c8721ead/CM50KmpJ1ACM1to1/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/sherlock-c8721ead/CM50KmpJ1ACM1to1/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/sherlock-c8721ead/CM50KmpJ1ACM1to1/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/sherlock-c8721ead/CM50KmpJ1ACM1to1/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/sherlock-c8721ead/CM50KmpJ1ACM1to1/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/sherlock-c8721ead/CM50KmpJ1ACM1to1/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/sherlock-c8721ead/CM50KmpJ1ACM1to1/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Quickstart - Sherlock\">\u003cmeta data-mint-head property=\"og:description\" content=\"Get the first traces and metrics from a Node.js service into Sherlock in about ten minutes.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Sherlock\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.sherlocklabs.dev/sdk/nodejs/quickstart\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://sherlock-c8721ead.mintlify.app/_mintlify/api/og/v2?division=Node.js+SDK\u0026amp;title=Quickstart\u0026amp;description=Get+the+first+traces+and+metrics+from+a+Node.js+service+into+Sherlock+in+about+ten+minutes.\u0026amp;theme=e50e186ee7971c1046787e92\u0026amp;signature=b1fec733db24859473e2a4512e8bf96afe1d6fe17c23af9e6ac759f39a954bdb\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Quickstart - Sherlock\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Get the first traces and metrics from a Node.js service into Sherlock in about ten minutes.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://sherlock-c8721ead.mintlify.app/_mintlify/api/og/v2?division=Node.js+SDK\u0026amp;title=Quickstart\u0026amp;description=Get+the+first+traces+and+metrics+from+a+Node.js+service+into+Sherlock+in+about+ten+minutes.\u0026amp;theme=e50e186ee7971c1046787e92\u0026amp;signature=b1fec733db24859473e2a4512e8bf96afe1d6fe17c23af9e6ac759f39a954bdb\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/sherlock-c8721ead/CM50KmpJ1ACM1to1/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Sherlock\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#262626\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.sherlocklabs.dev/sdk/nodejs/quickstart\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/sdk/nodejs/quickstart.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.sherlocklabs.dev/#organization\",\"name\":\"Sherlock\",\"url\":\"https://docs.sherlocklabs.dev\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/sherlock-c8721ead/hBlHCz8EH4O7570h/logo/light.png?fit=max\u0026auto=format\u0026n=hBlHCz8EH4O7570h\u0026q=85\u0026s=ecd14ef37115e0f5fa60edc05bf7b8d8\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.sherlocklabs.dev#website\",\"name\":\"Sherlock\",\"url\":\"https://docs.sherlocklabs.dev\",\"publisher\":{\"@id\":\"https://docs.sherlocklabs.dev/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.sherlocklabs.dev/sdk/nodejs/quickstart#webpage\",\"url\":\"https://docs.sherlocklabs.dev/sdk/nodejs/quickstart\",\"name\":\"Quickstart\",\"description\":\"Get the first traces and metrics from a Node.js service into Sherlock in about ten minutes.\",\"dateModified\":\"2026-09-27T04:56:45.730Z\",\"isPartOf\":{\"@id\":\"https://docs.sherlocklabs.dev#website\"},\"breadcrumb\":{\"@id\":\"https://docs.sherlocklabs.dev/sdk/nodejs/quickstart#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.sherlocklabs.dev/sdk/nodejs/quickstart#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Node.js SDK\",\"item\":\"https://docs.sherlocklabs.dev/sdk/nodejs/overview\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Quickstart\",\"item\":\"https://docs.sherlocklabs.dev/sdk/nodejs/quickstart\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.sherlocklabs.dev/sdk/nodejs/quickstart#article\",\"headline\":\"Quickstart\",\"name\":\"Quickstart\",\"description\":\"Get the first traces and metrics from a Node.js service into Sherlock in about ten minutes.\",\"url\":\"https://docs.sherlocklabs.dev/sdk/nodejs/quickstart\",\"mainEntityOfPage\":{\"@id\":\"https://docs.sherlocklabs.dev/sdk/nodejs/quickstart#webpage\"},\"dateModified\":\"2026-09-27T04:56:45.730Z\",\"publisher\":{\"@id\":\"https://docs.sherlocklabs.dev/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.sherlocklabs.dev#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Sherlock\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"Sherlock","nav":{"global":null,"pages":[{"title":"Sherlock overview","sidebarTitle":"Overview","icon":"compass","href":"/index"},{"title":"Get started with Sherlock","sidebarTitle":"Get started","icon":"rocket","href":"/get-started/getting-started"},{"title":"Use these docs with AI agents","sidebarTitle":"Docs for AI agents","icon":"sparkles","href":"/get-started/ai-agents"},{"title":"Ask an AI assistant","sidebarTitle":"AI assistant (MCP)","icon":"plug","href":"/explore/mcp"},{"group":"Send data","icon":"paper-plane","pages":[{"title":"Send data overview","sidebarTitle":"Overview","icon":"compass","href":"/send-data/overview"},{"title":"Environments","sidebarTitle":"Environments","icon":"layer-group","href":"/send-data/environments"},{"title":"OpenTelemetry SDKs and collectors","sidebarTitle":"OpenTelemetry SDKs and collectors","icon":"arrow-right-arrow-left","href":"/send-data/otlp"},{"title":"Metric temporality","sidebarTitle":"Metric temporality","icon":"wave-square","href":"/send-data/metric-temporality"},{"title":"Monitor a Linux VM","sidebarTitle":"Linux VM","icon":"server","href":"/send-data/linux-vm"},{"title":"Monitor a Kubernetes cluster","sidebarTitle":"Kubernetes","icon":"dharmachakra","href":"/send-data/kubernetes"}]},{"group":"Node.js SDK","icon":{"style":"brands","name":"node-js"},"pages":[{"title":"Sherlock SDK for Node.js","sidebarTitle":"Overview","description":"Add traces, metrics, and trace-linked exemplars to a Node.js service with one import.","icon":"compass","href":"/sdk/nodejs/overview"},{"title":"Quickstart","icon":"rocket","href":"/sdk/nodejs/quickstart"},{"title":"End-to-end steps","description":"The full path from credentials to production: register, start, stop, deploy, extend, verify, and operate.","icon":"list-ol","href":"/sdk/nodejs/add-telemetry"},{"title":"Custom metrics","icon":"chart-line","href":"/sdk/nodejs/custom-metrics"},{"title":"Custom spans","sidebarTitle":"Custom spans","icon":"code-branch","href":"/sdk/nodejs/manual-spans"},{"title":"Troubleshooting","icon":"wrench","href":"/sdk/nodejs/troubleshooting"}]},{"group":"Go SDK","icon":{"style":"brands","name":"golang"},"pages":[{"title":"Go setup","sidebarTitle":"Setup","icon":"rocket","href":"/sdk/go/setup"},{"title":"Go configuration","sidebarTitle":"Configuration","icon":"sliders","href":"/sdk/go/configuration"},{"title":"Differences from the Node.js SDK","sidebarTitle":"Differences from Node.js","icon":"code-compare","href":"/sdk/go/differences"}]},{"title":"Logs","icon":"scroll","href":"/explore/logs"},{"title":"Traces","icon":"diagram-project","href":"/explore/traces"},{"title":"Metrics","icon":"chart-simple","href":"/explore/metrics"},{"title":"From a chart to a trace to the logs","sidebarTitle":"Exemplars","icon":"link","href":"/explore/exemplars"},{"title":"Alerts","icon":"bell","href":"/explore/alerts"}]},"basePath":"","title":"Quickstart - Sherlock","buildId":"dpl_9VVk5y1P8k1ATeJguVngy9Q3cmbD","deploymentId":"dpl_9VVk5y1P8k1ATeJguVngy9Q3cmbD","dynamics":["07c022d89b","a74be98ba7"],"chunks":["Frame-BdiBGm0H.js","DynamicMarkdown-CbqEDjbV.js","zoom-image-lightbox-CvtNkYOX.js","lightbox-handle-r17bVUz3.js"]}