Gauge
Gauge represents a gauge labeled with values from the context. See labeled.SetMetricsKeys for more information
Methods
Inc()
@classmethod
def Inc(
ctx: context.Context
)
Increments the gauge by 1. Call this method to increase the gauge's current value by a fixed amount.
Parameters
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context for the operation, used to carry deadlines, cancellation signals, and other request-scoped values. |
Add()
@classmethod
def Add(
ctx: context.Context,
v: float64
)
Adds a specified float64 value to the gauge. Use this method to increase the gauge's value by a variable amount.
Parameters
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context for the operation, used to carry deadlines, cancellation signals, and other request-scoped values. |
| v | float64 | The value to add to the gauge. This can be any positive or negative float64 number. |
Set()
@classmethod
def Set(
ctx: context.Context,
v: float64
)
Sets the gauge to a specific float64 value. This method is used to explicitly define the gauge's current reading.
Parameters
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context for the operation, used to carry deadlines, cancellation signals, and other request-scoped values. |
| v | float64 | The new float64 value to set the gauge to. This will overwrite the current gauge value. |
Dec()
@classmethod
def Dec(
ctx: context.Context
)
Decrements the gauge by 1. Call this method to decrease the gauge's current value by a fixed amount.
Parameters
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context for the operation, used to carry deadlines, cancellation signals, and other request-scoped values. |
Sub()
@classmethod
def Sub(
ctx: context.Context,
v: float64
)
Subtracts a specified float64 value from the gauge. Use this method to decrease the gauge's value by a variable amount.
Parameters
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context for the operation, used to carry deadlines, cancellation signals, and other request-scoped values. |
| v | float64 | The value to subtract from the gauge. This can be any positive or negative float64 number. |
SetToCurrentTime()
@classmethod
def SetToCurrentTime(
ctx: context.Context
)
Sets the gauge to the current Unix timestamp in seconds. This is useful for tracking the time of the last event or operation.
Parameters
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context for the operation, used to carry deadlines, cancellation signals, and other request-scoped values. |