MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / setMeterState

Function setMeterState

source code/entrypoints/init.ts:307–342  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

305}
306
307async function setMeterState(): Promise<void> {
308 // Lazy-load instrumentation to defer ~400KB of OpenTelemetry + protobuf
309 const { initializeTelemetry } = await import(
310 '../utils/telemetry/instrumentation.js'
311 )
312 // Initialize customer OTLP telemetry (metrics, logs, traces)
313 const meter = await initializeTelemetry()
314 if (meter) {
315 // Create factory function for attributed counters
316 const createAttributedCounter = (
317 name: string,
318 options: MetricOptions,
319 ): AttributedCounter => {
320 const counter = meter?.createCounter(name, options)
321
322 return {
323 add(value: number, additionalAttributes: Attributes = {}) {
324 // Always fetch fresh telemetry attributes to ensure they're up to date
325 const currentAttributes = getTelemetryAttributes()
326 const mergedAttributes = {
327 ...currentAttributes,
328 ...additionalAttributes,
329 }
330 counter?.add(value, mergedAttributes)
331 },
332 }
333 }
334
335 setMeter(meter, createAttributedCounter)
336
337 // Increment session counter here because the startup telemetry path
338 // runs before this async initialization completes, so the counter
339 // would be null there.
340 getSessionCounter()?.add(1)
341 }
342}

Callers 1

doInitializeTelemetryFunction · 0.85

Calls 4

initializeTelemetryFunction · 0.85
setMeterFunction · 0.85
getSessionCounterFunction · 0.85
addMethod · 0.45

Tested by

no test coverage detected