Socket
Socket
Sign inDemoInstall

@zaplabs/opencensus-core

Package Overview
Dependencies
7
Maintainers
26
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @zaplabs/opencensus-core

Zaplabs - OpenCensus is a toolkit for collecting application performance and behavior data.


Version published
Maintainers
26
Created

Changelog

Source

0.0.14 - 2019-06-04

  • Exporter/Stats/Stackdriver: Add support for exemplar
  • exporter-stackdriver: Add support the credentials option used for authentication instead of your application default credentials
  • Update dependency @types/nock to v10
  • Object Trace Exporter for programatic span access
  • Update dependency axios to ^0.19.0 [SECURITY]
  • Refactor resource util to match specs
  • Update dependency jaeger-client to ~3.15.0
  • Trace Context Propagation: return null instead of empty spancontext
  • Update dependency gcp-metadata to v2
  • Fix duplicate spans issue and clean up
  • chore(deps): update dependency nyc to v14.1.1
  • chore: add node 12 ci job

Readme

Source

OpenCensus Core Node.js

Gitter chat Node Version NPM Published Version dependencies Status devDependencies Status Apache License

OpenCensus for Node.js is an implementation of OpenCensus, a toolkit for collecting application performance and behavior monitoring data. It currently includes 3 apis: stats, tracing and tags.

The library is in alpha stage and the API is subject to change.

Installation

Install the opencensus-core package with NPM:

npm install @opencensus/core

Usage

Get the global Stats manager instance.

To enable metrics, we’ll import a few items from OpenCensus Core package.

const { globalStats, MeasureUnit, AggregationType, TagMap } = require('@opencensus/core');

// The latency in milliseconds
const mLatencyMs = globalStats.createMeasureDouble(
  "repl/latency",
  MeasureUnit.MS,
  "The latency in milliseconds"
);
Create Views and Tags:

We now determine how our metrics will be organized by creating Views. We will also create the variable needed to add extra text meta-data to our metrics – methodTagKey, statusTagKey, and errorTagKey.

const methodTagKey = { name: "method" };
const statusTagKey = { name: "status" };
const errorTagKey = { name: "error" };

// Create & Register the view.
const latencyView = globalStats.createView(
  "demo/latency",
  mLatencyMs,
  AggregationType.DISTRIBUTION,
  [methodTagKey, statusTagKey, errorTagKey],
  "The distribution of the latencies",
  // Bucket Boundaries:
  // [>=0ms, >=25ms, >=50ms, >=75ms, >=100ms, >=200ms, >=400ms, >=600ms, >=800ms, >=1s, >=2s, >=4s, >=6s]
  [0, 25, 50, 75, 100, 200, 400, 600, 800, 1000, 2000, 4000, 6000]
);
globalStats.registerView(latencyView);
Recording Metrics:

Now we will record the desired metrics. To do so, we will use globalStats.record() and pass in measurements.

const [_, startNanoseconds] = process.hrtime();
const tags = new TagMap();
tags.set(methodTagKey, { value: "REPL" });
tags.set(statusTagKey, { value: "OK" });

globalStats.record([{
  measure: mLatencyMs,
  value: sinceInMilliseconds(startNanoseconds)
}], tags);

function sinceInMilliseconds(startNanoseconds) {
  const [_, endNanoseconds] = process.hrtime();
  return (endNanoseconds - startNanoseconds) / 1e6;
}

Measures can be of type Int64 or DOUBLE, created by calling createMeasureInt64 and createMeasureDouble respectively. Its units can be:

MeasureUnitUsage
UNITfor general counts
BYTEbytes
KBYTEKbytes
SECseconds
MSmillisecond
NSnanosecond

Views can have agregations of type SUM, LAST_VALUE, COUNT and DISTRIBUTION. To know more about Stats core concepts, please visit: https://opencensus.io/core-concepts/metrics/

See Quickstart/Metrics for a full example of registering and collecting metrics.

LICENSE

Apache License 2.0

Keywords

FAQs

Last updated on 07 Jun 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc