InternalLog an informational message with meta data.
The trace object.
The message to log.
The meta data to log.
Log a warning message with meta data.
The trace object.
The message to log.
The meta data to log.
Log a debug message with meta data.
The trace object.
The message to log.
The meta data to log.
Log an error message with meta data.
The trace object.
The message to log.
The meta data to log.
Log an error message with meta data.
Creates a counter metric. A Counter is a metric that represents a monotonically increasing value. It is used to measure the cumulative count of an event that increases over time and resets to zero only when the process restarts.
The name of the counter metric
A description of the counter metric
More information about the counter metric
Optionallabels: LABELS[]Optional labels to associate with the counter metric
A Counter object that can be used to update the counter metric
Use Cases:
Event Counting: Counting the number of requests received, errors encountered, or messages processed. Work Done: Measuring the total number of bytes read or written, tasks completed, or jobs processed. Characteristics:
Monotonic: Counters can only increase or reset. They cannot decrease. Sum: The focus is on the total accumulated value over time. Example: A Counter can be used to count the number of HTTP requests received by a server.
Creates a gauge metric. A Gauge is a metric that represents a value that can go up and down. It measures the current value of a particular data point at a specific moment in time.
The name of the gauge metric
A description of the gauge metric
More information about the gauge metric
Optionallabels: LABELS[]Optional labels to associate with the gauge metric
A Gauge object that can be used to update the gauge metric
Use Cases:
Resource Levels: Monitoring CPU usage, memory consumption, or disk space. Temperature or Pressure: Tracking real-time sensor readings. Current State: Measuring the current number of active users or open connections. Characteristics:
Variable: Gauges can increase and decrease over time. Instantaneous: Captures a snapshot of a value at a particular time. Example: A Gauge can be used to measure the current temperature of a system or the current memory usage of an application.
let gauge = this.metrics.createGauge("my-gauge", "A gauge metric");
gauge.set(10); // Set the gauge to 10
gauge.set(20); // Set the gauge to 20
gauge.set(30); // Set the gauge to 30
gauge.increment(); // Increment the gauge by 1
gauge.increment(10); // Increment the gauge by 10
gauge.decrement(); // Decrement the gauge by 1
gauge.decrement(10); // Decrement the gauge by 10
Creates a histogram metric. A Histogram is a metric that collects data samples and counts them in predefined buckets. It provides statistical distribution of values over time, capturing not just the total sum but also the distribution of values.
The name of the histogram metric
A description of the histogram metric
More information about the histogram metric
Optionalboundaries: number[]Optional boundaries for the histogram metric
Optionallabels: LABELS[]Optional labels to associate with the histogram metric
A Histogram object that can be used to update the histogram metric
Use Cases:
Event Distribution: Measuring the distribution of events received by a system, such as the number of requests per second or the distribution of response times. Work Done: Measuring the distribution of bytes read or written, tasks completed, or jobs processed. Characteristics:
Monotonic: Histograms can only increase or reset. They cannot decrease. Sum: The focus is on the total accumulated value over time. Example: A Histogram can be used to measure the distribution of response times for a web server.
Creates a trace metric. A Trace is a metric that represents a sequence of events or operations that form a request or transaction. It provides a way to track and monitor the flow of operations across your application.
The name of the trace, used to identify the operation or request being traced
Optionalattributes: Record<string, string | number | boolean>Optional key-value pairs providing additional context about the trace
A Trace object that can be used to record spans, errors, and manage the trace lifecycle
Use Cases:
Characteristics:
// Create a simple trace
const trace = this.metrics.createTrace("user-registration");
// OR Create a trace with attributes
const trace = this.metrics.createTrace("payment-processing", {
"customer-id": "12345",
"payment-method": "credit-card"
});
// Using the trace
try {
// Perform operations
const span = this.metrics.createSpan(trace, "get-customer-balance");
// Do some external work
span.end({balance: 100});
trace.end({transactionId: "12345"});
} catch (error) {
trace.error(error);
}
trace.end();
Creates a new span from an existing trace (automatic parent span).
The trace to associate with the span
The name of the span
Optionalattributes: Record<string, string | number | boolean>Optional attributes to associate with the span
A Span object that can be used to update the span metric
Create Timer A Timer is a metric that measures the time taken to execute a block of code. It provides a simple way to measure the time taken to execute a block of code.
A Timer object that can be used to update the timer metric
Use Cases:
Event Timing: Measuring the time taken to execute a block of code. Work Done: Measuring the time taken to execute a block of code. Characteristics:
Monotonic: Timers can only increase or reset. They cannot decrease. Sum: The focus is on the total accumulated value over time. Example: A Timer can be used to measure the time taken to execute a block of code.
See
API: IPluginObservable
Unified interface combining logging and metrics capabilities. This is the internal interface implemented by ObservableBackend.