Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

583 B
Raw Blame
import { performance } from 'perf_hooks'
import { Summary } from 'prom-client'

const jsonParseDurationMsSummary = new Summary({
    name: 'json_parse_duration_ms',
    help: 'Time to parse JSON using different methods',
    labelNames: ['method'],
    percentiles: [0.5, 0.9, 0.95, 0.99],
})

export function parseJSON(json: string) {
    const startTime = performance.now()
    // oxlint-disable-next-line eslint-js/no-restricted-syntax
    const result = JSON.parse(json)
    jsonParseDurationMsSummary.labels('native').observe(performance.now() - startTime)

    return result
}