Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Hapi plugin to produce commonly needed opencensus measures and views.

License

Notifications You must be signed in to change notification settings

cruxinformatics/hapi-opencensus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hapi-opencensus

A hapi plugin for reporting commonly needed custom metrics. Useful for clients using stackdriver.

install

npm install hapi-opencensus

usage

The following is an example of how to use this plugin with stackdriver.

const hapiOpencensus = require('hapi-opencensus');
const { Stats } = require('@opencensus/core');
const { StackdriverStatsExporter } = require('@opencensus/exporter-stackdriver');

async function startServer() {}
  const stats = new Stats();

  // The gcp project id associated with client's stackdriver
  const projectId = process.env.GCLOUD_PROJECT;

  const exporter = new StackdriverStatsExporter({ projectId });

  stats.registerExporter(exporter);

  const server = new Hapi.Server();

  await server.register({
    plugin: hapiOpencensus,
    options: { stats },
  });

  await server.start();
}

options

  • stats (required): instance of opencensus Stats object. Should register exporter prior to initializing plugin.

About

Hapi plugin to produce commonly needed opencensus measures and views.

Resources

License

Stars

Watchers

Forks

Packages

No packages published