Skip to main content
TL;DRClone the HackerNews Analyzer, fill .env with your OTLP endpoint and token, then paste the agent prompt. The backend needs no OpenTelemetry imports; the agent wires @hyperdx/node-opentelemetry at process start.Time required: about 10 minutes
The HackerNews Analyzer is a Node.js app that queries the HackerNews dataset hosted in the public ClickHouse demo. Every chart, table, and search box is a real ClickHouse query, so every interaction produces a trace whose main span is the HTTPS call from the backend out to ClickHouse. This is a different job from the session replay demo, which instruments a browser-only app against local Docker ClickStack. Here you get backend auto-instrumentation, ClickHouse query spans, and session replay from the same app.

Prerequisites

  • Node 18+ and npm
  • A ClickStack OTLP/HTTP endpoint and ingestion token:
    • ClickHouse Cloud: open the service, then ClickStackConfigure your OpenTelemetry exporterEnv vars. Protocol is http/protobuf. Headers are authorization=<ingestion token> with no Bearer prefix.
    • Local collector: use http://localhost:4318. If the collector is unsecured, leave authorization= empty.

Clone the repository

Clone HackerNews Analyzer, install dependencies, and copy the env template:
You’ll fill .env in the next steps, then instrument from this directory.

Instrument the application

1

Run the application

From the cloned hn-news-analyzer directory, start the app. The ClickHouse data source defaults to the public read-only demo cluster, so it runs without any further configuration:
Open http://localhost:5001. You will see a year selector, summary statistics, an activity chart, top users and domains tables, and a search box. Click around: switch years, drill into stories.
At this point the application is running but uninstrumented. ClickStack shows no data: it is waiting for telemetry.
2

Configure environment

The SDKs read standard OpenTelemetry exporter variables. They are not hardcoded in source. Open .env and set:
OTEL_EXPORTER_OTLP_ENDPOINT is the OTLP/HTTP endpoint (port 4318). OTEL_EXPORTER_OTLP_HEADERS is the authorization header, in the form authorization=<token> with no Bearer prefix.If the collector does not enforce auth, leave the token empty (OTEL_EXPORTER_OTLP_HEADERS=authorization=). The variable must still be present; the SDK skips initialization if it is unset or fully empty.The browser SDK reuses these same values. vite.config.ts bakes the endpoint and token into the public bundle at build time, so use a throwaway ingestion token, not a production one.
3

Instrument the application

Pick one path. All three end at the same instrumented app.
With the repo cloned and .env filled in, paste this prompt into a coding agent in that directory to instrument the application.
4

Generate traffic and view telemetry

Restart the application so the new launch command and freshly built browser bundle take effect:
Confirm the startup banner prints three “Health check passed” lines for /v1/traces, /v1/metrics, and /v1/logs. Reload the browser tab so Vite serves the updated bundle, then switch years and click into stories to generate traffic.Open the ClickStack UI:
  1. Go to Search and filter to the last 5 minutes. Logs for hn-analyzer-api stream in.
  1. Click into a request and walk up the trace. You will see the Express handler span, a child HTTP span pointing at sql-clickhouse.clickhouse.com with real network duration, and correlated console.log records on the same trace.
  1. Open Session Replay to play back a scrubbable video of a browser session, synced to the trace timeline.
Logs, metrics, traces, and session replays land in the same UI, share the same query language, and are correlated automatically.

Learn more

Last modified on August 28, 2026