API Reference
Error Monitoring
Getting Started
Welcome to Highlight
Integrations
Product Features
Session Replay
Tips
Menu
H.recordMetric()
recordMetric: ( secureSessionId: string, name: string, value: number, requestId?: string, tags?: { name: string; value: string }[], ) => void
Purpose
H.recordMetric() reports a metric to Highlight. Backend metrics can be used just like frontend metrics for creating custom dashboards. See Frontend Observability for more details.
Example Usage
import { H } from "@highlight-run/node"; const handler = (request) => { const parsed = H.parseHeaders(request.headers); const start = Date.now(); doInterestingWork(); const elapsed = Date.now() - start; H.recordMetric(parsed.secureSessionId, "elapsedTimeMs", elapsed, parsed.requestId, ["user": "Zane"]); };
Arguments
secureSessionId : string
- A randomized id representing the Highlight session making the network request. This can be parsed from the network request's headers using H.parseHeaders().
name : string
- The name of the metric being reported.
value : number
- The numeric value of the metric being reported.
requestId : optional string
- A randomized id generated by the Highlight client representing the request for this metric. This can be parsed from the network request's headers using H.parseHeaders(). If the metric is not request-specific, this argument can be omitted.
tags : optional { name: string; value: string }[]
- Tags are arbitrary name-value pairs you can associate to your metrics. This is helpful for categorizing data in dashboards, e.g. for grouping or filtering metrics by particular tags.