Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 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.
const latencyView = globalStats.createView(
'demo/latency',
// 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.
const latencyView = globalStats.createView(
'demo/latency',
'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,
'Propagated from the server and should have the same value as "grpc.io/server/latency'
);
'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(
'grpc.io/server/sent_bytes_per_rpc',
MeasureUnit.BYTE,
'Total bytes sent in across all response messages per RPC'
);
/**
* Tag key that represents a server gRPC method.
*
* {@link #GRPC_SERVER_METHOD} is set when an incoming request starts and is
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'
);
/**
* {@link Measure} for the server-side total bytes received in request body
* (not including headers). This is uncompressed bytes.
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(
'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,
'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(
'grpc.io/server/sent_bytes_per_rpc',
MeasureUnit.BYTE,
'Total bytes sent in across all response messages per RPC'
);
/**
* Tag key that represents a server gRPC method.
*
* {@link #GRPC_SERVER_METHOD} is set when an incoming request starts and is
* available in the context for the entire RPC call handling.
*/
export const GRPC_SERVER_METHOD = {
name: 'grpc_server_method',
};
/**
* Tag key that represents a server gRPC canonical status. Refer to
* https://github.com/grpc/grpc/blob/master/doc/statuscodes.md.
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)'
);