How to use the @opencensus/core.globalStats.createMeasureInt64 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 / web_client_monitoring / app.js View on Github external
app.use(bodyParser.json());

// The project id must be provided for running in a local environment
const project = process.env.GOOGLE_CLOUD_PROJECT;
assert(typeof project !== 'undefined' && project,
  "Please set environment variable GOOGLE_CLOUD_PROJECT to the project id.");
console.log(`Sending metrics data to project: ${project}`);

// OpenCensus setup
// [START web_client_monitoring_ocsetup]
const exporter = new StackdriverStatsExporter({projectId: project});
globalStats.registerExporter(exporter);
const mLatencyMs = globalStats.createMeasureDouble("webmetrics/latency",
                       MeasureUnit.MS,
                       "Latency related to page loading");
const mClickCount = globalStats.createMeasureInt64("webmetrics/click_count",
                       MeasureUnit.UNIT,
                       "Number of clicks");
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
github census-instrumentation / opencensus-node / examples / stats / exporter / stackdriver.js View on Github external
}
const exporter = new StackdriverStatsExporter({ projectId: projectId });

// Pass the created exporter to global Stats
globalStats.registerExporter(exporter);
// [END setup_exporter]

// The latency in milliseconds
const mLatencyMs = globalStats.createMeasureDouble(
  'repl/latency',
  MeasureUnit.MS,
  'The latency in milliseconds per REPL loop'
);

// Counts/groups the lengths of lines read in.
const mLineLengths = globalStats.createMeasureInt64(
  'repl/line_lengths',
  MeasureUnit.BYTE,
  'The distribution of line lengths'
);

// Create a stream to read our file
const stream = fs.createReadStream('./test.txt');

// Create an interface to read and process our file line by line
const lineReader = readline.createInterface({ input: stream });

const methodKey = { name: 'method' };
const statusKey = { name: 'status' };
const tagKeys = [methodKey, statusKey];

// Create & Register the view.
github census-instrumentation / opencensus-node / packages / opencensus-instrumentation-http / src / http-stats.ts View on Github external
* (not including headers). This is uncompressed bytes.
 */
export const HTTP_SERVER_RECEIVED_BYTES: Measure = globalStats.createMeasureInt64(
  'opencensus.io/http/server/received_bytes',
  MeasureUnit.BYTE,
  'Server-side total bytes received in request body (uncompressed)'
);

/**
 * {@link Measure} for the server-side total bytes sent in response bodies
 * (not including headers but including error responses with bodies). Should
 * be measured from actual bytes written and sent, not the value of the
 * Content-Length header. This is uncompressed bytes. Responses with no
 * body should record 0 for this value.
 */
export const HTTP_SERVER_SENT_BYTES: Measure = globalStats.createMeasureInt64(
  'opencensus.io/http/server/sent_bytes',
  MeasureUnit.BYTE,
  'Server-side total bytes sent in response bodies (uncompressed)'
);

/**
 * {@link Measure} for the server-side time between first byte of request
 * headers received to last byte of response sent, or terminal error.
 */
export const HTTP_SERVER_LATENCY: Measure = globalStats.createMeasureDouble(
  'opencensus.io/http/server/server_latency',
  MeasureUnit.MS,
  'Server-side time between first byte of request headers received to last byte of response sent, or terminal error'
);

/** {@link TagKey} for the value of the client-side HTTP host header. */
github census-instrumentation / opencensus-node / packages / opencensus-instrumentation-grpc / src / grpc-stats / client-stats.ts View on Github external
'grpc.io/client/sent_messages_per_rpc',
  MeasureUnit.UNIT,
  'Number of messages sent in the RPC (always 1 for non-streaming RPCs).'
);

/**
 * {@link Measure} for total bytes sent across all request messages per RPC.
 */
export const GRPC_CLIENT_SENT_BYTES_PER_RPC: Measure = globalStats.createMeasureInt64(
  'grpc.io/client/sent_bytes_per_rpc',
  MeasureUnit.BYTE,
  'Total bytes sent across all request messages per RPC.'
);

/** {@link Measure} for number of response messages received per RPC. */
export const GRPC_CLIENT_RECEIVED_MESSAGES_PER_RPC: Measure = globalStats.createMeasureInt64(
  'grpc.io/client/received_messages_per_rpc',
  MeasureUnit.UNIT,
  'Number of response messages received per RPC (always 1 for non-streaming RPCs).'
);

/**
 * {@link Measure} for total bytes received across all response messages per RPC
 */
export const GRPC_CLIENT_RECEIVED_BYTES_PER_RPC: Measure = globalStats.createMeasureInt64(
  'grpc.io/client/received_bytes_per_rpc',
  MeasureUnit.BYTE,
  'Total bytes received across all response messages per RPC.'
);

/** {@link Measure} for gRPC client roundtrip latency in milliseconds. */
export const GRPC_CLIENT_ROUNDTRIP_LATENCY: Measure = globalStats.createMeasureDouble(
github census-instrumentation / opencensus-node / packages / opencensus-instrumentation-grpc / src / grpc-stats / client-stats.ts View on Github external
import {
  AggregationType,
  globalStats,
  Measure,
  MeasureUnit,
  View,
} from '@opencensus/core';
import {
  DEFAULT_BYTES_DISTRIBUTION,
  DEFAULT_MESSAGE_COUNT_DISTRIBUTION,
  DEFAULT_MILLI_SECONDS_DISTRIBUTION,
} from './common-distributions';

/** {@link Measure} for number of messages sent in the RPC. */
export const GRPC_CLIENT_SENT_MESSAGES_PER_RPC: Measure = globalStats.createMeasureInt64(
  'grpc.io/client/sent_messages_per_rpc',
  MeasureUnit.UNIT,
  'Number of messages sent in the RPC (always 1 for non-streaming RPCs).'
);

/**
 * {@link Measure} for total bytes sent across all request messages per RPC.
 */
export const GRPC_CLIENT_SENT_BYTES_PER_RPC: Measure = globalStats.createMeasureInt64(
  'grpc.io/client/sent_bytes_per_rpc',
  MeasureUnit.BYTE,
  'Total bytes sent across all request messages per RPC.'
);

/** {@link Measure} for number of response messages received per RPC. */
export const GRPC_CLIENT_RECEIVED_MESSAGES_PER_RPC: Measure = globalStats.createMeasureInt64(
github census-instrumentation / opencensus-node / packages / opencensus-instrumentation-grpc / src / grpc-stats / server-stats.ts View on Github external
/** {@link Measure} for number of messages received in each RPC. */
export const GRPC_SERVER_RECEIVED_MESSAGES_PER_RPC: Measure = globalStats.createMeasureInt64(
  'grpc.io/server/received_messages_per_rpc',
  MeasureUnit.UNIT,
  'Number of messages received in each RPC. Has value 1 for non-streaming RPCs.'
);

/** {@link Measure} for gRPC server latency in milliseconds. */
export const GRPC_SERVER_SERVER_LATENCY: Measure = globalStats.createMeasureDouble(
  'grpc.io/server/server_latency',
  MeasureUnit.MS,
  'Time between first byte of request received to last byte of response sent, or terminal error.'
);

/** {@link Measure} for number of messages sent in each RPC. */
export const GRPC_SERVER_SENT_MESSAGES_PER_RPC: Measure = globalStats.createMeasureInt64(
  'grpc.io/server/sent_messages_per_rpc',
  MeasureUnit.UNIT,
  'Number of messages sent in each RPC. Has value 1 for non-streaming RPCs.'
);

/** {@link Measure} for total bytes received across all messages per RPC. */
export const GRPC_SERVER_RECEIVED_BYTES_PER_RPC: Measure = globalStats.createMeasureDouble(
  'grpc.io/server/received_bytes_per_rpc',
  MeasureUnit.BYTE,
  'Total bytes received across all messages per RPC.'
);

/**
 * {@link Measure} for total bytes sent across all response messages per RPC.
 */
export const GRPC_SERVER_SENT_BYTES_PER_RPC: Measure = globalStats.createMeasureDouble(
github census-instrumentation / opencensus-node / packages / opencensus-instrumentation-grpc / src / grpc-stats / client-stats.ts View on Github external
'grpc.io/client/sent_bytes_per_rpc',
  MeasureUnit.BYTE,
  'Total bytes sent across all request messages per RPC.'
);

/** {@link Measure} for number of response messages received per RPC. */
export const GRPC_CLIENT_RECEIVED_MESSAGES_PER_RPC: Measure = globalStats.createMeasureInt64(
  'grpc.io/client/received_messages_per_rpc',
  MeasureUnit.UNIT,
  'Number of response messages received per RPC (always 1 for non-streaming RPCs).'
);

/**
 * {@link Measure} for total bytes received across all response messages per RPC
 */
export const GRPC_CLIENT_RECEIVED_BYTES_PER_RPC: Measure = globalStats.createMeasureInt64(
  'grpc.io/client/received_bytes_per_rpc',
  MeasureUnit.BYTE,
  'Total bytes received across all response messages per RPC.'
);

/** {@link Measure} for gRPC client roundtrip latency in milliseconds. */
export const GRPC_CLIENT_ROUNDTRIP_LATENCY: Measure = globalStats.createMeasureDouble(
  'grpc.io/client/roundtrip_latency',
  MeasureUnit.MS,
  'Time between first byte of request sent to last byte of response received, or terminal error.'
);

/** {@link Measure} for gRPC server latency in milliseconds. */
export const GRPC_CLIENT_SERVER_LATENCY: Measure = globalStats.createMeasureDouble(
  'grpc.io/client/server_latency',
  MeasureUnit.MS,
github census-instrumentation / opencensus-node / packages / opencensus-instrumentation-grpc / src / grpc-stats / server-stats.ts View on Github external
import {
  AggregationType,
  globalStats,
  Measure,
  MeasureUnit,
  View,
} from '@opencensus/core';

import {
  DEFAULT_BYTES_DISTRIBUTION,
  DEFAULT_MESSAGE_COUNT_DISTRIBUTION,
  DEFAULT_MILLI_SECONDS_DISTRIBUTION,
} from './common-distributions';

/** {@link Measure} for number of messages received in each RPC. */
export const GRPC_SERVER_RECEIVED_MESSAGES_PER_RPC: Measure = globalStats.createMeasureInt64(
  'grpc.io/server/received_messages_per_rpc',
  MeasureUnit.UNIT,
  'Number of messages received in each RPC. Has value 1 for non-streaming RPCs.'
);

/** {@link Measure} for gRPC server latency in milliseconds. */
export const GRPC_SERVER_SERVER_LATENCY: Measure = globalStats.createMeasureDouble(
  'grpc.io/server/server_latency',
  MeasureUnit.MS,
  'Time between first byte of request received to last byte of response sent, or terminal error.'
);

/** {@link Measure} for number of messages sent in each RPC. */
export const GRPC_SERVER_SENT_MESSAGES_PER_RPC: Measure = globalStats.createMeasureInt64(
  'grpc.io/server/sent_messages_per_rpc',
  MeasureUnit.UNIT,
github census-instrumentation / opencensus-node / packages / opencensus-instrumentation-http / src / http-stats.ts View on Github external
*/

import {
  AggregationType,
  globalStats,
  Measure,
  MeasureUnit,
  Stats,
  View,
} from '@opencensus/core';

/**
 * {@link Measure} for the client-side total bytes sent in request body (not
 * including headers). This is uncompressed bytes.
 */
export const HTTP_CLIENT_SENT_BYTES: Measure = globalStats.createMeasureInt64(
  'opencensus.io/http/client/sent_bytes',
  MeasureUnit.BYTE,
  'Client-side total bytes sent in request body (uncompressed)'
);

/**
 * {@link Measure} for the client-side total bytes received in response
 * bodies (not including headers but including error responses with bodies).
 * Should be measured from actual bytes received and read, not the value of
 * the Content-Length header. This is uncompressed bytes. Responses with no
 * body should record 0 for this value.
 */
export const HTTP_CLIENT_RECEIVED_BYTES: Measure = globalStats.createMeasureInt64(
  'opencensus.io/http/client/received_bytes',
  MeasureUnit.BYTE,
  'Client-side total bytes received in response bodies (uncompressed)'
github census-instrumentation / opencensus-node / packages / opencensus-instrumentation-http / src / http-stats.ts View on Github external
* including headers). This is uncompressed bytes.
 */
export const HTTP_CLIENT_SENT_BYTES: Measure = globalStats.createMeasureInt64(
  'opencensus.io/http/client/sent_bytes',
  MeasureUnit.BYTE,
  'Client-side total bytes sent in request body (uncompressed)'
);

/**
 * {@link Measure} for the client-side total bytes received in response
 * bodies (not including headers but including error responses with bodies).
 * Should be measured from actual bytes received and read, not the value of
 * the Content-Length header. This is uncompressed bytes. Responses with no
 * body should record 0 for this value.
 */
export const HTTP_CLIENT_RECEIVED_BYTES: Measure = globalStats.createMeasureInt64(
  'opencensus.io/http/client/received_bytes',
  MeasureUnit.BYTE,
  'Client-side total bytes received in response bodies (uncompressed)'
);

/**
 * {@link Measure} for the client-side time between first byte of request
 * headers sent to last byte of response received, or terminal error.
 */
export const HTTP_CLIENT_ROUNDTRIP_LATENCY: Measure = globalStats.createMeasureDouble(
  'opencensus.io/http/client/roundtrip_latency',
  MeasureUnit.MS,
  'Client-side time between first byte of request headers sent to last byte of response received, or terminal error'
);

/**