How to use the @opencensus/core.globalStats.registerView function in @opencensus/core

To help you get started, we’ve selected a few @opencensus/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github census-instrumentation / opencensus-node / examples / stats / exporter / prometheus.js View on Github external
'The number of lines from standard input'
);
globalStats.registerView(lineCountView);

// Create & Register the view.
const lineLengthView = globalStats.createView(
  'demo/line_lengths',
  mLineLengths,
  AggregationType.DISTRIBUTION,
  tagKeys,
  'Groups the lengths of keys in buckets',
  // Bucket Boudaries:
  // [>=5B, >=10B, >=15B, >=20B, >=40B, >=60B, >=80, >=100B, >=200B, >=400, >=600, >=800, >=1000]
  [5, 10, 15, 20, 40, 60, 80, 100, 200, 400, 600, 800, 1000]
);
globalStats.registerView(lineLengthView);

// The begining of our REPL loop
let [_, startNanoseconds] = process.hrtime();
let endNanoseconds;

// REPL is the read, evaluate, print and loop
lineReader.on('line', function (line) {
  // Read
  try {
    const processedLine = processLine(line); // Evaluate
    console.log(processedLine); // Print

    // Registers the end of our REPL
    [_, endNanoseconds] = process.hrtime();

    const tags = new TagMap();
github census-instrumentation / opencensus-node / examples / stats / web_client_monitoring / app.js View on Github external
"webmetrics/latency",
  mLatencyMs,
  AggregationType.DISTRIBUTION,
  [tagPhase, tagClient],
  "Distribution of latencies",
  buckets
);
globalStats.registerView(latencyView);
const clickCountView = globalStats.createView(
  "webmetrics/click_count",
  mClickCount,
  AggregationType.COUNT,
  [tagClient],
  "The number of button clicks"
);
globalStats.registerView(clickCountView);
// [END web_client_monitoring_ocsetup]

// Process the metrics data posted to the server
app.post("/metrics", (req, res) => {
  const dnsTime = req.body["dnsTime"];
  const connectTime = req.body["connectTime"];
  const totalTime = req.body["totalTime"];
  const clickCount = req.body["count"];
  console.log(`totalTime ${totalTime}`);
  console.log(`connectTime ${connectTime}`);
  console.log(`dnsTime ${dnsTime}`);
  console.log(`count ${clickCount}`);
  const valueTLSNegotiation = "tls_negotiation";
  const valueDNSLookup = "dns_lookup";
  const valueLoad = "load";
  const valueWeb = "web";
github census-instrumentation / opencensus-node / examples / stats / exporter / stackdriver.js View on Github external
'The number of lines from standard input'
);
globalStats.registerView(lineCountView);

// Create & Register the view.
const lineLengthView = globalStats.createView(
  'demo/line_lengths',
  mLineLengths,
  AggregationType.DISTRIBUTION,
  tagKeys,
  'Groups the lengths of keys in buckets',
  // Bucket Boudaries:
  // [>=5B, >=10B, >=15B, >=20B, >=40B, >=60B, >=80, >=100B, >=200B, >=400, >=600, >=800, >=1000]
  [5, 10, 15, 20, 40, 60, 80, 100, 200, 400, 600, 800, 1000]
);
globalStats.registerView(lineLengthView);

// The begining of our REPL loop
let [_, startNanoseconds] = process.hrtime();
let endNanoseconds;

// REPL is the read, evaluate, print and loop
lineReader.on('line', function (line) {
  // Read
  try {
    const processedLine = processLine(line); // Evaluate
    console.log(processedLine); // Print

    // Registers the end of our REPL
    [_, endNanoseconds] = process.hrtime();

    const tags = new TagMap();
github census-instrumentation / opencensus-node / examples / stats / exporter / prometheus.js View on Github external
'The distribution of the repl latencies',
  // Latency in buckets:
  // [>=25ms, >=50ms, >=75ms, >=100ms, >=200ms, >=400ms, >=600ms, >=800ms, >=1s, >=2s, >=4s, >=6s]
  [25, 50, 75, 100, 200, 400, 600, 800, 1000, 2000, 4000, 6000]
);
globalStats.registerView(latencyView);

// Create & Register the view.
const lineCountView = globalStats.createView(
  'demo/lines_in',
  mLineLengths,
  AggregationType.COUNT,
  tagKeys,
  'The number of lines from standard input'
);
globalStats.registerView(lineCountView);

// Create & Register the view.
const lineLengthView = globalStats.createView(
  'demo/line_lengths',
  mLineLengths,
  AggregationType.DISTRIBUTION,
  tagKeys,
  'Groups the lengths of keys in buckets',
  // Bucket Boudaries:
  // [>=5B, >=10B, >=15B, >=20B, >=40B, >=60B, >=80, >=100B, >=200B, >=400, >=600, >=800, >=1000]
  [5, 10, 15, 20, 40, 60, 80, 100, 200, 400, 600, 800, 1000]
);
globalStats.registerView(lineLengthView);

// The begining of our REPL loop
let [_, startNanoseconds] = process.hrtime();
github census-instrumentation / opencensus-node / examples / stats / exporter / stackdriver.js View on Github external
'The distribution of the repl latencies',
  // Latency in buckets:
  // [>=25ms, >=50ms, >=75ms, >=100ms, >=200ms, >=400ms, >=600ms, >=800ms, >=1s, >=2s, >=4s, >=6s]
  [25, 50, 75, 100, 200, 400, 600, 800, 1000, 2000, 4000, 6000]
);
globalStats.registerView(latencyView);

// Create & Register the view.
const lineCountView = globalStats.createView(
  'demo/lines_in',
  mLineLengths,
  AggregationType.COUNT,
  tagKeys,
  'The number of lines from standard input'
);
globalStats.registerView(lineCountView);

// Create & Register the view.
const lineLengthView = globalStats.createView(
  'demo/line_lengths',
  mLineLengths,
  AggregationType.DISTRIBUTION,
  tagKeys,
  'Groups the lengths of keys in buckets',
  // Bucket Boudaries:
  // [>=5B, >=10B, >=15B, >=20B, >=40B, >=60B, >=80, >=100B, >=200B, >=400, >=600, >=800, >=1000]
  [5, 10, 15, 20, 40, 60, 80, 100, 200, 400, 600, 800, 1000]
);
globalStats.registerView(lineLengthView);

// The begining of our REPL loop
let [_, startNanoseconds] = process.hrtime();
github census-instrumentation / opencensus-node / examples / stats / web_client_monitoring / app.js View on Github external
const buckets = [0, 1, 2, 3, 4, 5, 6, 8, 10, 13, 16, 20, 25, 30, 40, 50, 65, 80,
                100, 130, 160, 200, 250, 300, 400, 500, 650, 800, 1000, 2000,
                5000, 10000, 20000, 50000, 100000];

const tagPhase = { name: "phase" };
const tagClient = { name: "client" };

const latencyView = globalStats.createView(
  "webmetrics/latency",
  mLatencyMs,
  AggregationType.DISTRIBUTION,
  [tagPhase, tagClient],
  "Distribution of latencies",
  buckets
);
globalStats.registerView(latencyView);
const clickCountView = globalStats.createView(
  "webmetrics/click_count",
  mClickCount,
  AggregationType.COUNT,
  [tagClient],
  "The number of button clicks"
);
globalStats.registerView(clickCountView);
// [END web_client_monitoring_ocsetup]

// Process the metrics data posted to the server
app.post("/metrics", (req, res) => {
  const dnsTime = req.body["dnsTime"];
  const connectTime = req.body["connectTime"];
  const totalTime = req.body["totalTime"];
  const clickCount = req.body["count"];
github census-instrumentation / opencensus-node / examples / stats / exporter / stackdriver.js View on Github external
const methodKey = { name: 'method' };
const statusKey = { name: 'status' };
const tagKeys = [methodKey, statusKey];

// Create & Register the view.
const latencyView = globalStats.createView(
  'demo/latency',
  mLatencyMs,
  AggregationType.DISTRIBUTION,
  tagKeys,
  'The distribution of the repl latencies',
  // Latency in buckets:
  // [>=25ms, >=50ms, >=75ms, >=100ms, >=200ms, >=400ms, >=600ms, >=800ms, >=1s, >=2s, >=4s, >=6s]
  [25, 50, 75, 100, 200, 400, 600, 800, 1000, 2000, 4000, 6000]
);
globalStats.registerView(latencyView);

// Create & Register the view.
const lineCountView = globalStats.createView(
  'demo/lines_in',
  mLineLengths,
  AggregationType.COUNT,
  tagKeys,
  'The number of lines from standard input'
);
globalStats.registerView(lineCountView);

// Create & Register the view.
const lineLengthView = globalStats.createView(
  'demo/line_lengths',
  mLineLengths,
  AggregationType.DISTRIBUTION,
github census-instrumentation / opencensus-node / examples / stats / exporter / prometheus.js View on Github external
const methodKey = { name: 'method' };
const statusKey = { name: 'status' };
const tagKeys = [methodKey, statusKey];

// Create & Register the view.
const latencyView = globalStats.createView(
  'demo/latency',
  mLatencyMs,
  AggregationType.DISTRIBUTION,
  tagKeys,
  'The distribution of the repl latencies',
  // Latency in buckets:
  // [>=25ms, >=50ms, >=75ms, >=100ms, >=200ms, >=400ms, >=600ms, >=800ms, >=1s, >=2s, >=4s, >=6s]
  [25, 50, 75, 100, 200, 400, 600, 800, 1000, 2000, 4000, 6000]
);
globalStats.registerView(latencyView);

// Create & Register the view.
const lineCountView = globalStats.createView(
  'demo/lines_in',
  mLineLengths,
  AggregationType.COUNT,
  tagKeys,
  'The number of lines from standard input'
);
globalStats.registerView(lineCountView);

// Create & Register the view.
const lineLengthView = globalStats.createView(
  'demo/line_lengths',
  mLineLengths,
  AggregationType.DISTRIBUTION,