How to use the @opencensus/core.globalStats.createView 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 / stackdriver.js View on Github external
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.
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,
github census-instrumentation / opencensus-node / examples / stats / exporter / stackdriver.js View on Github external
// 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,
  tagKeys,
  'Groups the lengths of keys in buckets',
  // Bucket Boudaries:
github census-instrumentation / opencensus-node / examples / stats / exporter / prometheus.js View on Github external
[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();
let endNanoseconds;

// REPL is the read, evaluate, print and loop
github census-instrumentation / opencensus-node / examples / stats / exporter / prometheus.js View on Github external
// 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,
  tagKeys,
  'Groups the lengths of keys in buckets',
  // Bucket Boudaries:
github census-instrumentation / opencensus-node / packages / opencensus-instrumentation-grpc / src / grpc-stats / client-stats.ts View on Github external
'Distribution of sent messages count per RPC, by method.',
  DEFAULT_MESSAGE_COUNT_DISTRIBUTION
);

/** {@link View} for client sent bytes per RPC. */
const GRPC_CLIENT_SENT_BYTES_PER_RPC_VIEW = globalStats.createView(
  'grpc.io/client/sent_bytes_per_rpc',
  GRPC_CLIENT_SENT_BYTES_PER_RPC,
  AggregationType.DISTRIBUTION,
  [GRPC_CLIENT_METHOD],
  'Distribution of bytes sent per RPC, by method.',
  DEFAULT_BYTES_DISTRIBUTION
);

/** {@link View} for client roundtrip latency in milliseconds. */
const GRPC_CLIENT_ROUNDTRIP_LATENCY_VIEW = globalStats.createView(
  'grpc.io/client/roundtrip_latency',
  GRPC_CLIENT_ROUNDTRIP_LATENCY,
  AggregationType.DISTRIBUTION,
  [GRPC_CLIENT_METHOD],
  'Distribution of round-trip latency, by method.',
  DEFAULT_MILLI_SECONDS_DISTRIBUTION
);

/**
 * {@link View} for completed client RPCs.
 *
 * This {@code View} uses measure {@code GRPC_CLIENT_ROUNDTRIP_LATENCY},
 * since completed RPCs can be inferred over any measure recorded once per RPC
 * (since it's just a count aggregation over the measure). It would be
 * unnecessary to use a separate "count" measure.
 */
github census-instrumentation / opencensus-node / packages / opencensus-instrumentation-grpc / src / grpc-stats / server-stats.ts View on Github external
'Distribution of received bytes per RPC, by method.',
  DEFAULT_BYTES_DISTRIBUTION
);

/** {@link View} for server sent messages per RPC. */
const GRPC_SERVER_SENT_MESSAGES_PER_RPC_VIEW = globalStats.createView(
  'grpc.io/server/sent_messages_per_rpc',
  GRPC_SERVER_SENT_MESSAGES_PER_RPC,
  AggregationType.DISTRIBUTION,
  [GRPC_SERVER_METHOD],
  'Distribution of messages received count per RPC, by method.',
  DEFAULT_MESSAGE_COUNT_DISTRIBUTION
);

/** {@link View} for server sent bytes per RPC. */
const GRPC_SERVER_SENT_BYTES_PER_RPC_VIEW = globalStats.createView(
  'grpc.io/server/sent_bytes_per_rpc',
  GRPC_SERVER_SENT_BYTES_PER_RPC,
  AggregationType.DISTRIBUTION,
  [GRPC_SERVER_METHOD],
  'Distribution of total sent bytes per RPC, by method.',
  DEFAULT_BYTES_DISTRIBUTION
);

/** {@link View} for server server latency in milliseconds. */
const GRPC_SERVER_SERVER_LATENCY_VIEW = globalStats.createView(
  'grpc.io/server/server_latency',
  GRPC_SERVER_SERVER_LATENCY,
  AggregationType.DISTRIBUTION,
  [GRPC_SERVER_METHOD],
  'Distribution of server latency in milliseconds, by method.',
  DEFAULT_MILLI_SECONDS_DISTRIBUTION
github census-instrumentation / opencensus-node / packages / opencensus-instrumentation-http / src / http-stats.ts View on Github external
);

/** {@link View} for size distribution of server-side HTTP response body. */
const HTTP_SERVER_SENT_BYTES_VIEW = globalStats.createView(
  'opencensus.io/http/server/sent_bytes',
  HTTP_SERVER_SENT_BYTES,
  AggregationType.DISTRIBUTION,
  [HTTP_SERVER_METHOD, HTTP_SERVER_ROUTE, HTTP_SERVER_STATUS],
  'Size distribution of server-side HTTP response body',
  SIZE_DISTRIBUTION
);

/**
 * {@link View} for latency distribution of server-side HTTP requests serving.
 */
const HTTP_SERVER_LATENCY_VIEW = globalStats.createView(
  'opencensus.io/http/server/server_latency',
  HTTP_SERVER_LATENCY,
  AggregationType.DISTRIBUTION,
  [HTTP_SERVER_METHOD, HTTP_SERVER_ROUTE, HTTP_SERVER_STATUS],
  'Latency distribution of server-side HTTP requests serving',
  LATENCY_DISTRIBUTION
);

const HTTP_BASIC_SERVER_VIEWS: View[] = [
  HTTP_SERVER_COMPLETED_COUNT_VIEW,
  HTTP_SERVER_RECEIVED_BYTES_VIEW,
  HTTP_SERVER_SENT_BYTES_VIEW,
  HTTP_SERVER_LATENCY_VIEW,
];

const HTTP_BASIC_CLIENT_VIEWS: View[] = [
github census-instrumentation / opencensus-node / packages / opencensus-instrumentation-http / src / http-stats.ts View on Github external
);

/** {@link View} for size distribution of client-side HTTP response body. */
const HTTP_CLIENT_RECEIVED_BYTES_VIEW = globalStats.createView(
  'opencensus.io/http/client/received_bytes',
  HTTP_CLIENT_RECEIVED_BYTES,
  AggregationType.DISTRIBUTION,
  [HTTP_CLIENT_METHOD, HTTP_CLIENT_STATUS],
  'Size distribution of client-side HTTP response body',
  SIZE_DISTRIBUTION
);

/**
 * {@link View} for roundtrip latency distribution of client-side HTTP requests.
 */
const HTTP_CLIENT_ROUNDTRIP_LATENCY_VIEW = globalStats.createView(
  'opencensus.io/http/client/roundtrip_latency',
  HTTP_CLIENT_ROUNDTRIP_LATENCY,
  AggregationType.DISTRIBUTION,
  [HTTP_CLIENT_METHOD, HTTP_CLIENT_STATUS],
  'Roundtrip latency distribution of client-side HTTP requests',
  LATENCY_DISTRIBUTION
);

/** {@link View} for count of server-side HTTP requests serving completed. */
const HTTP_SERVER_COMPLETED_COUNT_VIEW = globalStats.createView(
  'opencensus.io/http/server/completed_count',
  HTTP_SERVER_LATENCY,
  AggregationType.COUNT,
  [HTTP_SERVER_METHOD, HTTP_SERVER_ROUTE, HTTP_SERVER_STATUS],
  'Count of HTTP server-side requests serving completed'
);
github census-instrumentation / opencensus-node / packages / opencensus-instrumentation-grpc / src / grpc-stats / server-stats.ts View on Github external
'Distribution of messages received count per RPC, by method.',
  DEFAULT_MESSAGE_COUNT_DISTRIBUTION
);

/** {@link View} for server received bytes per RPC. */
const GRPC_SERVER_RECEIVED_BYTES_PER_RPC_VIEW = globalStats.createView(
  'grpc.io/server/received_bytes_per_rpc',
  GRPC_SERVER_RECEIVED_BYTES_PER_RPC,
  AggregationType.DISTRIBUTION,
  [GRPC_SERVER_METHOD],
  'Distribution of received bytes per RPC, by method.',
  DEFAULT_BYTES_DISTRIBUTION
);

/** {@link View} for server sent messages per RPC. */
const GRPC_SERVER_SENT_MESSAGES_PER_RPC_VIEW = globalStats.createView(
  'grpc.io/server/sent_messages_per_rpc',
  GRPC_SERVER_SENT_MESSAGES_PER_RPC,
  AggregationType.DISTRIBUTION,
  [GRPC_SERVER_METHOD],
  'Distribution of messages received count per RPC, by method.',
  DEFAULT_MESSAGE_COUNT_DISTRIBUTION
);

/** {@link View} for server sent bytes per RPC. */
const GRPC_SERVER_SENT_BYTES_PER_RPC_VIEW = globalStats.createView(
  'grpc.io/server/sent_bytes_per_rpc',
  GRPC_SERVER_SENT_BYTES_PER_RPC,
  AggregationType.DISTRIBUTION,
  [GRPC_SERVER_METHOD],
  'Distribution of total sent bytes per RPC, by method.',
  DEFAULT_BYTES_DISTRIBUTION
github census-instrumentation / opencensus-node / packages / opencensus-instrumentation-grpc / src / grpc-stats / client-stats.ts View on Github external
GRPC_CLIENT_ROUNDTRIP_LATENCY,
  AggregationType.DISTRIBUTION,
  [GRPC_CLIENT_METHOD],
  'Distribution of round-trip latency, by method.',
  DEFAULT_MILLI_SECONDS_DISTRIBUTION
);

/**
 * {@link View} for completed client RPCs.
 *
 * This {@code View} uses measure {@code GRPC_CLIENT_ROUNDTRIP_LATENCY},
 * since completed RPCs can be inferred over any measure recorded once per RPC
 * (since it's just a count aggregation over the measure). It would be
 * unnecessary to use a separate "count" measure.
 */
const GRPC_CLIENT_COMPLETED_RPC_VIEW = globalStats.createView(
  'grpc.io/client/completed_rpcs',
  GRPC_CLIENT_ROUNDTRIP_LATENCY,
  AggregationType.COUNT,
  [GRPC_CLIENT_METHOD, GRPC_CLIENT_STATUS],
  'Count of RPCs by method and status.',
  DEFAULT_MESSAGE_COUNT_DISTRIBUTION
);

export const GRPC_BASIC_CLIENT_VIEWS: View[] = [
  GRPC_CLIENT_RECEIVED_MESSAGES_PER_RPC_VIEW,
  GRPC_CLIENT_RECEIVED_BYTES_PER_RPC_VIEW,
  GRPC_CLIENT_SENT_MESSAGES_PER_RPC_VIEW,
  GRPC_CLIENT_SENT_BYTES_PER_RPC_VIEW,
  GRPC_CLIENT_ROUNDTRIP_LATENCY_VIEW,
  GRPC_CLIENT_COMPLETED_RPC_VIEW,
];