How to use the @opencensus/core.globalStats.record 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
globalStats.record([{
      measure: mLineLengths,
      value: processedLine.length
    }], tags);

    globalStats.record([{
      measure: mLatencyMs,
      value: sinceInMilliseconds(endNanoseconds, startNanoseconds)
    }], tags);
  } catch (err) {
    console.log(err);

    const errTags = new TagMap();
    errTags.set(methodKey, { value: 'repl' });
    errTags.set(statusKey, { value: 'ERROR' });
    globalStats.record([{
      measure: mLatencyMs,
      value: sinceInMilliseconds(endNanoseconds, startNanoseconds)
    }], errTags);
  }

  // Restarts the start time for the REPL
  startNanoseconds = endNanoseconds;
});
github census-instrumentation / opencensus-node / examples / stats / exporter / stackdriver.js View on Github external
globalStats.record([{
      measure: mLineLengths,
      value: processedLine.length
    }], tags);

    globalStats.record([{
      measure: mLatencyMs,
      value: sinceInMilliseconds(endNanoseconds, startNanoseconds)
    }], tags);
  } catch (err) {
    console.log(err);

    const errTags = new TagMap();
    errTags.set(methodKey, { value: 'repl' });
    errTags.set(statusKey, { value: 'ERROR' });
    globalStats.record([{
      measure: mLatencyMs,
      value: sinceInMilliseconds(endNanoseconds, startNanoseconds)
    }], errTags);
  }

  // Restarts the start time for the REPL
  startNanoseconds = endNanoseconds;
});
github census-instrumentation / opencensus-node / examples / stats / exporter / stackdriver.js View on Github external
const processedLine = processLine(line); // Evaluate
    console.log(processedLine); // Print

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

    const tags = new TagMap();
    tags.set(methodKey, { value: 'REPL' });
    tags.set(statusKey, { value: 'OK' });

    globalStats.record([{
      measure: mLineLengths,
      value: processedLine.length
    }], tags);

    globalStats.record([{
      measure: mLatencyMs,
      value: sinceInMilliseconds(endNanoseconds, startNanoseconds)
    }], tags);
  } catch (err) {
    console.log(err);

    const errTags = new TagMap();
    errTags.set(methodKey, { value: 'repl' });
    errTags.set(statusKey, { value: 'ERROR' });
    globalStats.record([{
      measure: mLatencyMs,
      value: sinceInMilliseconds(endNanoseconds, startNanoseconds)
    }], errTags);
  }

  // Restarts the start time for the REPL
github census-instrumentation / opencensus-node / examples / stats / web_client_monitoring / app.js View on Github external
tags.set(tagPhase, { value: valueTLSNegotiation });
    globalStats.record([{
      measure: mLatencyMs,
      value: 1
    }], tags);

    tags.set(tagPhase, { value: valueLoad });
    globalStats.record([{
      measure: mLatencyMs,
      value: 1
    }], tags);

    const tags1 = new TagMap();
    tags1.set(tagClient, { value: valueWeb });
    globalStats.record([{
      measure: mClickCount,
      value: 1
    }], tags1);
    res.status(200).send("Received").end();
    console.log('Competed recording metrics');
  } catch (err) {
    console.log(`Could not save stats: ${err}`);
    res.status(500).send("Error saving stats").end();
  }
  // [END web_client_monitoring_record]
});
github census-instrumentation / opencensus-node / examples / stats / exporter / prometheus.js View on Github external
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();
    tags.set(methodKey, { value: 'REPL' });
    tags.set(statusKey, { value: 'OK' });

    globalStats.record([{
      measure: mLineLengths,
      value: processedLine.length
    }], tags);

    globalStats.record([{
      measure: mLatencyMs,
      value: sinceInMilliseconds(endNanoseconds, startNanoseconds)
    }], tags);
  } catch (err) {
    console.log(err);

    const errTags = new TagMap();
    errTags.set(methodKey, { value: 'repl' });
    errTags.set(statusKey, { value: 'ERROR' });
    globalStats.record([{
      measure: mLatencyMs,
github census-instrumentation / opencensus-node / examples / stats / web_client_monitoring / app.js View on Github external
const valueDNSLookup = "dns_lookup";
  const valueLoad = "load";
  const valueWeb = "web";

  const tags = new TagMap();
  tags.set(tagPhase, { value: valueDNSLookup });
  tags.set(tagClient, { value: valueWeb });
  // [START web_client_monitoring_record]
  try {
    globalStats.record([{
      measure: mLatencyMs,
      value: 1
    }], tags);

    tags.set(tagPhase, { value: valueTLSNegotiation });
    globalStats.record([{
      measure: mLatencyMs,
      value: 1
    }], tags);

    tags.set(tagPhase, { value: valueLoad });
    globalStats.record([{
      measure: mLatencyMs,
      value: 1
    }], tags);

    const tags1 = new TagMap();
    tags1.set(tagClient, { value: valueWeb });
    globalStats.record([{
      measure: mClickCount,
      value: 1
    }], tags1);
github census-instrumentation / opencensus-node / examples / tags / tag-context-example.js View on Github external
globalStats.withTagContext(tags2, () => {
      console.log('Enter Scope 2');
      printMap('Add Tags', tags2.tags);
      printMap('Current Tags == Default + tags1 + tags2:', globalStats.getCurrentTagContext().tags);

      const measurement = { measure: mLatencyMs, value: 10 };
      globalStats.record([measurement]);
      console.log('Close Scope 2');
    });
    printMap('Current Tags == Default + tags1:', globalStats.getCurrentTagContext().tags);