0.0.5-beta.4 • Published 5 years ago

opencensusz v0.0.5-beta.4

Weekly downloads
44
License
-
Repository
-
Last release
5 years ago

Opencensusz

Opencensusz is a thin wrapper around the Opencensus Node.js metrics library to make it easier to add metrics.

This API is inspired by Google's internal cross-language metrics library and the name Opencensusz is an homage to it.

Usage

Regular Prometheus (poll-based)

const mBarStatus = new Counter(
  'foo/server/bar_status',
  'Bar status',
  ['status']
)

const mBarTime = new Distribution(
  'foo/server/bar_time_millis',
  'Time to bar',
  ['type'],
  [1, 2, 3, 4, 5, 6].map(n => 10**n),
  MeasureUnit.MS
)


mBarStatus.increment({ status: 'OK' })

Prometheus PushGateway (push-based)

Set environment variable:

PUSH_GATEWAY_ENDPOINT=http://localhost:9091

Counters:

const mErrors = new PushCounter('errors', 'General errrs', 'frontend_server')
await mErrors.increment({error: 'Invalid input'})

Convenience function for logging heartbeat timestamps:

await PulseHeartbeat('api_server', 'prod')