This commit is contained in:
Christian Mantha
2026-03-02 19:10:52 -05:00
commit 2ca0b9ef7c
28907 changed files with 5233713 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
# Copyright The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Final
from opentelemetry.metrics import Histogram, Meter, UpDownCounter
AZURE_COSMOSDB_CLIENT_ACTIVE_INSTANCE_COUNT: Final = (
"azure.cosmosdb.client.active_instance.count"
)
"""
Number of active client instances
Instrument: updowncounter
Unit: {instance}
"""
def create_azure_cosmosdb_client_active_instance_count(
meter: Meter,
) -> UpDownCounter:
"""Number of active client instances"""
return meter.create_up_down_counter(
name=AZURE_COSMOSDB_CLIENT_ACTIVE_INSTANCE_COUNT,
description="Number of active client instances.",
unit="{instance}",
)
AZURE_COSMOSDB_CLIENT_OPERATION_REQUEST_CHARGE: Final = (
"azure.cosmosdb.client.operation.request_charge"
)
"""
[Request units](https://learn.microsoft.com/azure/cosmos-db/request-units) consumed by the operation
Instrument: histogram
Unit: {request_unit}
"""
def create_azure_cosmosdb_client_operation_request_charge(
meter: Meter,
) -> Histogram:
"""[Request units](https://learn.microsoft.com/azure/cosmos-db/request-units) consumed by the operation"""
return meter.create_histogram(
name=AZURE_COSMOSDB_CLIENT_OPERATION_REQUEST_CHARGE,
description="[Request units](https://learn.microsoft.com/azure/cosmos-db/request-units) consumed by the operation.",
unit="{request_unit}",
)

View File

@@ -0,0 +1,105 @@
# Copyright The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Final
from opentelemetry.metrics import Counter, Histogram, Meter, UpDownCounter
CICD_PIPELINE_RUN_ACTIVE: Final = "cicd.pipeline.run.active"
"""
The number of pipeline runs currently active in the system by state
Instrument: updowncounter
Unit: {run}
"""
def create_cicd_pipeline_run_active(meter: Meter) -> UpDownCounter:
"""The number of pipeline runs currently active in the system by state"""
return meter.create_up_down_counter(
name=CICD_PIPELINE_RUN_ACTIVE,
description="The number of pipeline runs currently active in the system by state.",
unit="{run}",
)
CICD_PIPELINE_RUN_DURATION: Final = "cicd.pipeline.run.duration"
"""
Duration of a pipeline run grouped by pipeline, state and result
Instrument: histogram
Unit: s
"""
def create_cicd_pipeline_run_duration(meter: Meter) -> Histogram:
"""Duration of a pipeline run grouped by pipeline, state and result"""
return meter.create_histogram(
name=CICD_PIPELINE_RUN_DURATION,
description="Duration of a pipeline run grouped by pipeline, state and result.",
unit="s",
)
CICD_PIPELINE_RUN_ERRORS: Final = "cicd.pipeline.run.errors"
"""
The number of errors encountered in pipeline runs (eg. compile, test failures)
Instrument: counter
Unit: {error}
Note: There might be errors in a pipeline run that are non fatal (eg. they are suppressed) or in a parallel stage multiple stages could have a fatal error.
This means that this error count might not be the same as the count of metric `cicd.pipeline.run.duration` with run result `failure`.
"""
def create_cicd_pipeline_run_errors(meter: Meter) -> Counter:
"""The number of errors encountered in pipeline runs (eg. compile, test failures)"""
return meter.create_counter(
name=CICD_PIPELINE_RUN_ERRORS,
description="The number of errors encountered in pipeline runs (eg. compile, test failures).",
unit="{error}",
)
CICD_SYSTEM_ERRORS: Final = "cicd.system.errors"
"""
The number of errors in a component of the CICD system (eg. controller, scheduler, agent)
Instrument: counter
Unit: {error}
Note: Errors in pipeline run execution are explicitly excluded. Ie a test failure is not counted in this metric.
"""
def create_cicd_system_errors(meter: Meter) -> Counter:
"""The number of errors in a component of the CICD system (eg. controller, scheduler, agent)"""
return meter.create_counter(
name=CICD_SYSTEM_ERRORS,
description="The number of errors in a component of the CICD system (eg. controller, scheduler, agent).",
unit="{error}",
)
CICD_WORKER_COUNT: Final = "cicd.worker.count"
"""
The number of workers on the CICD system by state
Instrument: updowncounter
Unit: {count}
"""
def create_cicd_worker_count(meter: Meter) -> UpDownCounter:
"""The number of workers on the CICD system by state"""
return meter.create_up_down_counter(
name=CICD_WORKER_COUNT,
description="The number of workers on the CICD system by state.",
unit="{count}",
)

View File

@@ -0,0 +1,295 @@
# Copyright The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import (
Callable,
Final,
Generator,
Iterable,
Optional,
Sequence,
Union,
)
from opentelemetry.metrics import (
CallbackOptions,
Counter,
Meter,
ObservableGauge,
Observation,
UpDownCounter,
)
# pylint: disable=invalid-name
CallbackT = Union[
Callable[[CallbackOptions], Iterable[Observation]],
Generator[Iterable[Observation], CallbackOptions, None],
]
CONTAINER_CPU_TIME: Final = "container.cpu.time"
"""
Total CPU time consumed
Instrument: counter
Unit: s
Note: Total CPU time consumed by the specific container on all available CPU cores.
"""
def create_container_cpu_time(meter: Meter) -> Counter:
"""Total CPU time consumed"""
return meter.create_counter(
name=CONTAINER_CPU_TIME,
description="Total CPU time consumed.",
unit="s",
)
CONTAINER_CPU_USAGE: Final = "container.cpu.usage"
"""
Container's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs
Instrument: gauge
Unit: {cpu}
Note: CPU usage of the specific container on all available CPU cores, averaged over the sample window.
"""
def create_container_cpu_usage(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Container's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs"""
return meter.create_observable_gauge(
name=CONTAINER_CPU_USAGE,
callbacks=callbacks,
description="Container's CPU usage, measured in cpus. Range from 0 to the number of allocatable CPUs.",
unit="{cpu}",
)
CONTAINER_DISK_IO: Final = "container.disk.io"
"""
Disk bytes for the container
Instrument: counter
Unit: By
Note: The total number of bytes read/written successfully (aggregated from all disks).
"""
def create_container_disk_io(meter: Meter) -> Counter:
"""Disk bytes for the container"""
return meter.create_counter(
name=CONTAINER_DISK_IO,
description="Disk bytes for the container.",
unit="By",
)
CONTAINER_FILESYSTEM_AVAILABLE: Final = "container.filesystem.available"
"""
Container filesystem available bytes
Instrument: updowncounter
Unit: By
Note: In K8s, this metric is derived from the
[FsStats.AvailableBytes](https://pkg.go.dev/k8s.io/kubelet@v0.33.0/pkg/apis/stats/v1alpha1#FsStats) field
of the [ContainerStats.Rootfs](https://pkg.go.dev/k8s.io/kubelet@v0.33.0/pkg/apis/stats/v1alpha1#ContainerStats)
of the Kubelet's stats API.
"""
def create_container_filesystem_available(meter: Meter) -> UpDownCounter:
"""Container filesystem available bytes"""
return meter.create_up_down_counter(
name=CONTAINER_FILESYSTEM_AVAILABLE,
description="Container filesystem available bytes.",
unit="By",
)
CONTAINER_FILESYSTEM_CAPACITY: Final = "container.filesystem.capacity"
"""
Container filesystem capacity
Instrument: updowncounter
Unit: By
Note: In K8s, this metric is derived from the
[FsStats.CapacityBytes](https://pkg.go.dev/k8s.io/kubelet@v0.33.0/pkg/apis/stats/v1alpha1#FsStats) field
of the [ContainerStats.Rootfs](https://pkg.go.dev/k8s.io/kubelet@v0.33.0/pkg/apis/stats/v1alpha1#ContainerStats)
of the Kubelet's stats API.
"""
def create_container_filesystem_capacity(meter: Meter) -> UpDownCounter:
"""Container filesystem capacity"""
return meter.create_up_down_counter(
name=CONTAINER_FILESYSTEM_CAPACITY,
description="Container filesystem capacity.",
unit="By",
)
CONTAINER_FILESYSTEM_USAGE: Final = "container.filesystem.usage"
"""
Container filesystem usage
Instrument: updowncounter
Unit: By
Note: This may not equal capacity - available.
In K8s, this metric is derived from the
[FsStats.UsedBytes](https://pkg.go.dev/k8s.io/kubelet@v0.33.0/pkg/apis/stats/v1alpha1#FsStats) field
of the [ContainerStats.Rootfs](https://pkg.go.dev/k8s.io/kubelet@v0.33.0/pkg/apis/stats/v1alpha1#ContainerStats)
of the Kubelet's stats API.
"""
def create_container_filesystem_usage(meter: Meter) -> UpDownCounter:
"""Container filesystem usage"""
return meter.create_up_down_counter(
name=CONTAINER_FILESYSTEM_USAGE,
description="Container filesystem usage.",
unit="By",
)
CONTAINER_MEMORY_AVAILABLE: Final = "container.memory.available"
"""
Container memory available
Instrument: updowncounter
Unit: By
Note: Available memory for use. This is defined as the memory limit - workingSetBytes. If memory limit is undefined, the available bytes is omitted.
In general, this metric can be derived from [cadvisor](https://github.com/google/cadvisor/blob/v0.53.0/docs/storage/prometheus.md#prometheus-container-metrics) and by subtracting the `container_memory_working_set_bytes` metric from the `container_spec_memory_limit_bytes` metric.
In K8s, this metric is derived from the [MemoryStats.AvailableBytes](https://pkg.go.dev/k8s.io/kubelet@v0.34.0/pkg/apis/stats/v1alpha1#MemoryStats) field of the [PodStats.Memory](https://pkg.go.dev/k8s.io/kubelet@v0.34.0/pkg/apis/stats/v1alpha1#PodStats) of the Kubelet's stats API.
"""
def create_container_memory_available(meter: Meter) -> UpDownCounter:
"""Container memory available"""
return meter.create_up_down_counter(
name=CONTAINER_MEMORY_AVAILABLE,
description="Container memory available.",
unit="By",
)
CONTAINER_MEMORY_PAGING_FAULTS: Final = "container.memory.paging.faults"
"""
Container memory paging faults
Instrument: counter
Unit: {fault}
Note: In general, this metric can be derived from [cadvisor](https://github.com/google/cadvisor/blob/v0.53.0/docs/storage/prometheus.md#prometheus-container-metrics) and specifically the `container_memory_failures_total{failure_type=pgfault, scope=container}` and `container_memory_failures_total{failure_type=pgmajfault, scope=container}`metric.
In K8s, this metric is derived from the [MemoryStats.PageFaults](https://pkg.go.dev/k8s.io/kubelet@v0.34.0/pkg/apis/stats/v1alpha1#MemoryStats) and [MemoryStats.MajorPageFaults](https://pkg.go.dev/k8s.io/kubelet@v0.34.0/pkg/apis/stats/v1alpha1#MemoryStats) field of the [PodStats.Memory](https://pkg.go.dev/k8s.io/kubelet@v0.34.0/pkg/apis/stats/v1alpha1#PodStats) of the Kubelet's stats API.
"""
def create_container_memory_paging_faults(meter: Meter) -> Counter:
"""Container memory paging faults"""
return meter.create_counter(
name=CONTAINER_MEMORY_PAGING_FAULTS,
description="Container memory paging faults.",
unit="{fault}",
)
CONTAINER_MEMORY_RSS: Final = "container.memory.rss"
"""
Container memory RSS
Instrument: updowncounter
Unit: By
Note: In general, this metric can be derived from [cadvisor](https://github.com/google/cadvisor/blob/v0.53.0/docs/storage/prometheus.md#prometheus-container-metrics) and specifically the `container_memory_rss` metric.
In K8s, this metric is derived from the [MemoryStats.RSSBytes](https://pkg.go.dev/k8s.io/kubelet@v0.34.0/pkg/apis/stats/v1alpha1#MemoryStats) field of the [PodStats.Memory](https://pkg.go.dev/k8s.io/kubelet@v0.34.0/pkg/apis/stats/v1alpha1#PodStats) of the Kubelet's stats API.
"""
def create_container_memory_rss(meter: Meter) -> UpDownCounter:
"""Container memory RSS"""
return meter.create_up_down_counter(
name=CONTAINER_MEMORY_RSS,
description="Container memory RSS.",
unit="By",
)
CONTAINER_MEMORY_USAGE: Final = "container.memory.usage"
"""
Memory usage of the container
Instrument: counter
Unit: By
Note: Memory usage of the container.
"""
def create_container_memory_usage(meter: Meter) -> Counter:
"""Memory usage of the container"""
return meter.create_counter(
name=CONTAINER_MEMORY_USAGE,
description="Memory usage of the container.",
unit="By",
)
CONTAINER_MEMORY_WORKING_SET: Final = "container.memory.working_set"
"""
Container memory working set
Instrument: updowncounter
Unit: By
Note: In general, this metric can be derived from [cadvisor](https://github.com/google/cadvisor/blob/v0.53.0/docs/storage/prometheus.md#prometheus-container-metrics) and specifically the `container_memory_working_set_bytes` metric.
In K8s, this metric is derived from the [MemoryStats.WorkingSetBytes](https://pkg.go.dev/k8s.io/kubelet@v0.34.0/pkg/apis/stats/v1alpha1#MemoryStats) field of the [PodStats.Memory](https://pkg.go.dev/k8s.io/kubelet@v0.34.0/pkg/apis/stats/v1alpha1#PodStats) of the Kubelet's stats API.
"""
def create_container_memory_working_set(meter: Meter) -> UpDownCounter:
"""Container memory working set"""
return meter.create_up_down_counter(
name=CONTAINER_MEMORY_WORKING_SET,
description="Container memory working set.",
unit="By",
)
CONTAINER_NETWORK_IO: Final = "container.network.io"
"""
Network bytes for the container
Instrument: counter
Unit: By
Note: The number of bytes sent/received on all network interfaces by the container.
"""
def create_container_network_io(meter: Meter) -> Counter:
"""Network bytes for the container"""
return meter.create_counter(
name=CONTAINER_NETWORK_IO,
description="Network bytes for the container.",
unit="By",
)
CONTAINER_UPTIME: Final = "container.uptime"
"""
The time the container has been running
Instrument: gauge
Unit: s
Note: Instrumentations SHOULD use a gauge with type `double` and measure uptime in seconds as a floating point number with the highest precision available.
The actual accuracy would depend on the instrumentation and operating system.
"""
def create_container_uptime(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""The time the container has been running"""
return meter.create_observable_gauge(
name=CONTAINER_UPTIME,
callbacks=callbacks,
description="The time the container has been running.",
unit="s",
)

View File

@@ -0,0 +1,88 @@
# Copyright The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import (
Callable,
Final,
Generator,
Iterable,
Optional,
Sequence,
Union,
)
from opentelemetry.metrics import (
CallbackOptions,
Counter,
Meter,
ObservableGauge,
Observation,
)
# pylint: disable=invalid-name
CallbackT = Union[
Callable[[CallbackOptions], Iterable[Observation]],
Generator[Iterable[Observation], CallbackOptions, None],
]
CPU_FREQUENCY: Final = "cpu.frequency"
"""
Deprecated: Replaced by `system.cpu.frequency`.
"""
def create_cpu_frequency(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Deprecated. Use `system.cpu.frequency` instead"""
return meter.create_observable_gauge(
name=CPU_FREQUENCY,
callbacks=callbacks,
description="Deprecated. Use `system.cpu.frequency` instead.",
unit="{Hz}",
)
CPU_TIME: Final = "cpu.time"
"""
Deprecated: Replaced by `system.cpu.time`.
"""
def create_cpu_time(meter: Meter) -> Counter:
"""Deprecated. Use `system.cpu.time` instead"""
return meter.create_counter(
name=CPU_TIME,
description="Deprecated. Use `system.cpu.time` instead.",
unit="s",
)
CPU_UTILIZATION: Final = "cpu.utilization"
"""
Deprecated: Replaced by `system.cpu.utilization`.
"""
def create_cpu_utilization(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Deprecated. Use `system.cpu.utilization` instead"""
return meter.create_observable_gauge(
name=CPU_UTILIZATION,
callbacks=callbacks,
description="Deprecated. Use `system.cpu.utilization` instead.",
unit="1",
)

View File

@@ -0,0 +1,71 @@
# Copyright The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Final
from opentelemetry.metrics import Counter, Meter
CPYTHON_GC_COLLECTED_OBJECTS: Final = "cpython.gc.collected_objects"
"""
The total number of objects collected inside a generation since interpreter start
Instrument: counter
Unit: {object}
Note: This metric reports data from [`gc.stats()`](https://docs.python.org/3/library/gc.html#gc.get_stats).
"""
def create_cpython_gc_collected_objects(meter: Meter) -> Counter:
"""The total number of objects collected inside a generation since interpreter start"""
return meter.create_counter(
name=CPYTHON_GC_COLLECTED_OBJECTS,
description="The total number of objects collected inside a generation since interpreter start.",
unit="{object}",
)
CPYTHON_GC_COLLECTIONS: Final = "cpython.gc.collections"
"""
The number of times a generation was collected since interpreter start
Instrument: counter
Unit: {collection}
Note: This metric reports data from [`gc.stats()`](https://docs.python.org/3/library/gc.html#gc.get_stats).
"""
def create_cpython_gc_collections(meter: Meter) -> Counter:
"""The number of times a generation was collected since interpreter start"""
return meter.create_counter(
name=CPYTHON_GC_COLLECTIONS,
description="The number of times a generation was collected since interpreter start.",
unit="{collection}",
)
CPYTHON_GC_UNCOLLECTABLE_OBJECTS: Final = "cpython.gc.uncollectable_objects"
"""
The total number of objects which were found to be uncollectable inside a generation since interpreter start
Instrument: counter
Unit: {object}
Note: This metric reports data from [`gc.stats()`](https://docs.python.org/3/library/gc.html#gc.get_stats).
"""
def create_cpython_gc_uncollectable_objects(meter: Meter) -> Counter:
"""The total number of objects which were found to be uncollectable inside a generation since interpreter start"""
return meter.create_counter(
name=CPYTHON_GC_UNCOLLECTABLE_OBJECTS,
description="The total number of objects which were found to be uncollectable inside a generation since interpreter start.",
unit="{object}",
)

View File

@@ -0,0 +1,383 @@
# Copyright The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Final
from opentelemetry.metrics import Counter, Histogram, Meter, UpDownCounter
DB_CLIENT_CONNECTION_COUNT: Final = "db.client.connection.count"
"""
The number of connections that are currently in state described by the `state` attribute
Instrument: updowncounter
Unit: {connection}
"""
def create_db_client_connection_count(meter: Meter) -> UpDownCounter:
"""The number of connections that are currently in state described by the `state` attribute"""
return meter.create_up_down_counter(
name=DB_CLIENT_CONNECTION_COUNT,
description="The number of connections that are currently in state described by the `state` attribute.",
unit="{connection}",
)
DB_CLIENT_CONNECTION_CREATE_TIME: Final = "db.client.connection.create_time"
"""
The time it took to create a new connection
Instrument: histogram
Unit: s
"""
def create_db_client_connection_create_time(meter: Meter) -> Histogram:
"""The time it took to create a new connection"""
return meter.create_histogram(
name=DB_CLIENT_CONNECTION_CREATE_TIME,
description="The time it took to create a new connection.",
unit="s",
)
DB_CLIENT_CONNECTION_IDLE_MAX: Final = "db.client.connection.idle.max"
"""
The maximum number of idle open connections allowed
Instrument: updowncounter
Unit: {connection}
"""
def create_db_client_connection_idle_max(meter: Meter) -> UpDownCounter:
"""The maximum number of idle open connections allowed"""
return meter.create_up_down_counter(
name=DB_CLIENT_CONNECTION_IDLE_MAX,
description="The maximum number of idle open connections allowed.",
unit="{connection}",
)
DB_CLIENT_CONNECTION_IDLE_MIN: Final = "db.client.connection.idle.min"
"""
The minimum number of idle open connections allowed
Instrument: updowncounter
Unit: {connection}
"""
def create_db_client_connection_idle_min(meter: Meter) -> UpDownCounter:
"""The minimum number of idle open connections allowed"""
return meter.create_up_down_counter(
name=DB_CLIENT_CONNECTION_IDLE_MIN,
description="The minimum number of idle open connections allowed.",
unit="{connection}",
)
DB_CLIENT_CONNECTION_MAX: Final = "db.client.connection.max"
"""
The maximum number of open connections allowed
Instrument: updowncounter
Unit: {connection}
"""
def create_db_client_connection_max(meter: Meter) -> UpDownCounter:
"""The maximum number of open connections allowed"""
return meter.create_up_down_counter(
name=DB_CLIENT_CONNECTION_MAX,
description="The maximum number of open connections allowed.",
unit="{connection}",
)
DB_CLIENT_CONNECTION_PENDING_REQUESTS: Final = (
"db.client.connection.pending_requests"
)
"""
The number of current pending requests for an open connection
Instrument: updowncounter
Unit: {request}
"""
def create_db_client_connection_pending_requests(
meter: Meter,
) -> UpDownCounter:
"""The number of current pending requests for an open connection"""
return meter.create_up_down_counter(
name=DB_CLIENT_CONNECTION_PENDING_REQUESTS,
description="The number of current pending requests for an open connection.",
unit="{request}",
)
DB_CLIENT_CONNECTION_TIMEOUTS: Final = "db.client.connection.timeouts"
"""
The number of connection timeouts that have occurred trying to obtain a connection from the pool
Instrument: counter
Unit: {timeout}
"""
def create_db_client_connection_timeouts(meter: Meter) -> Counter:
"""The number of connection timeouts that have occurred trying to obtain a connection from the pool"""
return meter.create_counter(
name=DB_CLIENT_CONNECTION_TIMEOUTS,
description="The number of connection timeouts that have occurred trying to obtain a connection from the pool.",
unit="{timeout}",
)
DB_CLIENT_CONNECTION_USE_TIME: Final = "db.client.connection.use_time"
"""
The time between borrowing a connection and returning it to the pool
Instrument: histogram
Unit: s
"""
def create_db_client_connection_use_time(meter: Meter) -> Histogram:
"""The time between borrowing a connection and returning it to the pool"""
return meter.create_histogram(
name=DB_CLIENT_CONNECTION_USE_TIME,
description="The time between borrowing a connection and returning it to the pool.",
unit="s",
)
DB_CLIENT_CONNECTION_WAIT_TIME: Final = "db.client.connection.wait_time"
"""
The time it took to obtain an open connection from the pool
Instrument: histogram
Unit: s
"""
def create_db_client_connection_wait_time(meter: Meter) -> Histogram:
"""The time it took to obtain an open connection from the pool"""
return meter.create_histogram(
name=DB_CLIENT_CONNECTION_WAIT_TIME,
description="The time it took to obtain an open connection from the pool.",
unit="s",
)
DB_CLIENT_CONNECTIONS_CREATE_TIME: Final = "db.client.connections.create_time"
"""
Deprecated: Replaced by `db.client.connection.create_time` with unit `s`.
"""
def create_db_client_connections_create_time(meter: Meter) -> Histogram:
"""Deprecated, use `db.client.connection.create_time` instead. Note: the unit also changed from `ms` to `s`"""
return meter.create_histogram(
name=DB_CLIENT_CONNECTIONS_CREATE_TIME,
description="Deprecated, use `db.client.connection.create_time` instead. Note: the unit also changed from `ms` to `s`.",
unit="ms",
)
DB_CLIENT_CONNECTIONS_IDLE_MAX: Final = "db.client.connections.idle.max"
"""
Deprecated: Replaced by `db.client.connection.idle.max`.
"""
def create_db_client_connections_idle_max(meter: Meter) -> UpDownCounter:
"""Deprecated, use `db.client.connection.idle.max` instead"""
return meter.create_up_down_counter(
name=DB_CLIENT_CONNECTIONS_IDLE_MAX,
description="Deprecated, use `db.client.connection.idle.max` instead.",
unit="{connection}",
)
DB_CLIENT_CONNECTIONS_IDLE_MIN: Final = "db.client.connections.idle.min"
"""
Deprecated: Replaced by `db.client.connection.idle.min`.
"""
def create_db_client_connections_idle_min(meter: Meter) -> UpDownCounter:
"""Deprecated, use `db.client.connection.idle.min` instead"""
return meter.create_up_down_counter(
name=DB_CLIENT_CONNECTIONS_IDLE_MIN,
description="Deprecated, use `db.client.connection.idle.min` instead.",
unit="{connection}",
)
DB_CLIENT_CONNECTIONS_MAX: Final = "db.client.connections.max"
"""
Deprecated: Replaced by `db.client.connection.max`.
"""
def create_db_client_connections_max(meter: Meter) -> UpDownCounter:
"""Deprecated, use `db.client.connection.max` instead"""
return meter.create_up_down_counter(
name=DB_CLIENT_CONNECTIONS_MAX,
description="Deprecated, use `db.client.connection.max` instead.",
unit="{connection}",
)
DB_CLIENT_CONNECTIONS_PENDING_REQUESTS: Final = (
"db.client.connections.pending_requests"
)
"""
Deprecated: Replaced by `db.client.connection.pending_requests`.
"""
def create_db_client_connections_pending_requests(
meter: Meter,
) -> UpDownCounter:
"""Deprecated, use `db.client.connection.pending_requests` instead"""
return meter.create_up_down_counter(
name=DB_CLIENT_CONNECTIONS_PENDING_REQUESTS,
description="Deprecated, use `db.client.connection.pending_requests` instead.",
unit="{request}",
)
DB_CLIENT_CONNECTIONS_TIMEOUTS: Final = "db.client.connections.timeouts"
"""
Deprecated: Replaced by `db.client.connection.timeouts`.
"""
def create_db_client_connections_timeouts(meter: Meter) -> Counter:
"""Deprecated, use `db.client.connection.timeouts` instead"""
return meter.create_counter(
name=DB_CLIENT_CONNECTIONS_TIMEOUTS,
description="Deprecated, use `db.client.connection.timeouts` instead.",
unit="{timeout}",
)
DB_CLIENT_CONNECTIONS_USAGE: Final = "db.client.connections.usage"
"""
Deprecated: Replaced by `db.client.connection.count`.
"""
def create_db_client_connections_usage(meter: Meter) -> UpDownCounter:
"""Deprecated, use `db.client.connection.count` instead"""
return meter.create_up_down_counter(
name=DB_CLIENT_CONNECTIONS_USAGE,
description="Deprecated, use `db.client.connection.count` instead.",
unit="{connection}",
)
DB_CLIENT_CONNECTIONS_USE_TIME: Final = "db.client.connections.use_time"
"""
Deprecated: Replaced by `db.client.connection.use_time` with unit `s`.
"""
def create_db_client_connections_use_time(meter: Meter) -> Histogram:
"""Deprecated, use `db.client.connection.use_time` instead. Note: the unit also changed from `ms` to `s`"""
return meter.create_histogram(
name=DB_CLIENT_CONNECTIONS_USE_TIME,
description="Deprecated, use `db.client.connection.use_time` instead. Note: the unit also changed from `ms` to `s`.",
unit="ms",
)
DB_CLIENT_CONNECTIONS_WAIT_TIME: Final = "db.client.connections.wait_time"
"""
Deprecated: Replaced by `db.client.connection.wait_time` with unit `s`.
"""
def create_db_client_connections_wait_time(meter: Meter) -> Histogram:
"""Deprecated, use `db.client.connection.wait_time` instead. Note: the unit also changed from `ms` to `s`"""
return meter.create_histogram(
name=DB_CLIENT_CONNECTIONS_WAIT_TIME,
description="Deprecated, use `db.client.connection.wait_time` instead. Note: the unit also changed from `ms` to `s`.",
unit="ms",
)
DB_CLIENT_COSMOSDB_ACTIVE_INSTANCE_COUNT: Final = (
"db.client.cosmosdb.active_instance.count"
)
"""
Deprecated: Replaced by `azure.cosmosdb.client.active_instance.count`.
"""
def create_db_client_cosmosdb_active_instance_count(
meter: Meter,
) -> UpDownCounter:
"""Deprecated, use `azure.cosmosdb.client.active_instance.count` instead"""
return meter.create_up_down_counter(
name=DB_CLIENT_COSMOSDB_ACTIVE_INSTANCE_COUNT,
description="Deprecated, use `azure.cosmosdb.client.active_instance.count` instead.",
unit="{instance}",
)
DB_CLIENT_COSMOSDB_OPERATION_REQUEST_CHARGE: Final = (
"db.client.cosmosdb.operation.request_charge"
)
"""
Deprecated: Replaced by `azure.cosmosdb.client.operation.request_charge`.
"""
def create_db_client_cosmosdb_operation_request_charge(
meter: Meter,
) -> Histogram:
"""Deprecated, use `azure.cosmosdb.client.operation.request_charge` instead"""
return meter.create_histogram(
name=DB_CLIENT_COSMOSDB_OPERATION_REQUEST_CHARGE,
description="Deprecated, use `azure.cosmosdb.client.operation.request_charge` instead.",
unit="{request_unit}",
)
DB_CLIENT_OPERATION_DURATION: Final = "db.client.operation.duration"
"""
Deprecated in favor of stable :py:const:`opentelemetry.semconv.metrics.db_metrics.DB_CLIENT_OPERATION_DURATION`.
"""
def create_db_client_operation_duration(meter: Meter) -> Histogram:
"""Duration of database client operations"""
return meter.create_histogram(
name=DB_CLIENT_OPERATION_DURATION,
description="Duration of database client operations.",
unit="s",
)
DB_CLIENT_RESPONSE_RETURNED_ROWS: Final = "db.client.response.returned_rows"
"""
The actual number of records returned by the database operation
Instrument: histogram
Unit: {row}
"""
def create_db_client_response_returned_rows(meter: Meter) -> Histogram:
"""The actual number of records returned by the database operation"""
return meter.create_histogram(
name=DB_CLIENT_RESPONSE_RETURNED_ROWS,
description="The actual number of records returned by the database operation.",
unit="{row}",
)

View File

@@ -0,0 +1,34 @@
# Copyright The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Final
from opentelemetry.metrics import Histogram, Meter
DNS_LOOKUP_DURATION: Final = "dns.lookup.duration"
"""
Measures the time taken to perform a DNS lookup
Instrument: histogram
Unit: s
"""
def create_dns_lookup_duration(meter: Meter) -> Histogram:
"""Measures the time taken to perform a DNS lookup"""
return meter.create_histogram(
name=DNS_LOOKUP_DURATION,
description="Measures the time taken to perform a DNS lookup.",
unit="s",
)

View File

@@ -0,0 +1,170 @@
# Copyright The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Final
from opentelemetry.metrics import Counter, Histogram, Meter
FAAS_COLDSTARTS: Final = "faas.coldstarts"
"""
Number of invocation cold starts
Instrument: counter
Unit: {coldstart}
"""
def create_faas_coldstarts(meter: Meter) -> Counter:
"""Number of invocation cold starts"""
return meter.create_counter(
name=FAAS_COLDSTARTS,
description="Number of invocation cold starts.",
unit="{coldstart}",
)
FAAS_CPU_USAGE: Final = "faas.cpu_usage"
"""
Distribution of CPU usage per invocation
Instrument: histogram
Unit: s
"""
def create_faas_cpu_usage(meter: Meter) -> Histogram:
"""Distribution of CPU usage per invocation"""
return meter.create_histogram(
name=FAAS_CPU_USAGE,
description="Distribution of CPU usage per invocation.",
unit="s",
)
FAAS_ERRORS: Final = "faas.errors"
"""
Number of invocation errors
Instrument: counter
Unit: {error}
"""
def create_faas_errors(meter: Meter) -> Counter:
"""Number of invocation errors"""
return meter.create_counter(
name=FAAS_ERRORS,
description="Number of invocation errors.",
unit="{error}",
)
FAAS_INIT_DURATION: Final = "faas.init_duration"
"""
Measures the duration of the function's initialization, such as a cold start
Instrument: histogram
Unit: s
"""
def create_faas_init_duration(meter: Meter) -> Histogram:
"""Measures the duration of the function's initialization, such as a cold start"""
return meter.create_histogram(
name=FAAS_INIT_DURATION,
description="Measures the duration of the function's initialization, such as a cold start.",
unit="s",
)
FAAS_INVOCATIONS: Final = "faas.invocations"
"""
Number of successful invocations
Instrument: counter
Unit: {invocation}
"""
def create_faas_invocations(meter: Meter) -> Counter:
"""Number of successful invocations"""
return meter.create_counter(
name=FAAS_INVOCATIONS,
description="Number of successful invocations.",
unit="{invocation}",
)
FAAS_INVOKE_DURATION: Final = "faas.invoke_duration"
"""
Measures the duration of the function's logic execution
Instrument: histogram
Unit: s
"""
def create_faas_invoke_duration(meter: Meter) -> Histogram:
"""Measures the duration of the function's logic execution"""
return meter.create_histogram(
name=FAAS_INVOKE_DURATION,
description="Measures the duration of the function's logic execution.",
unit="s",
)
FAAS_MEM_USAGE: Final = "faas.mem_usage"
"""
Distribution of max memory usage per invocation
Instrument: histogram
Unit: By
"""
def create_faas_mem_usage(meter: Meter) -> Histogram:
"""Distribution of max memory usage per invocation"""
return meter.create_histogram(
name=FAAS_MEM_USAGE,
description="Distribution of max memory usage per invocation.",
unit="By",
)
FAAS_NET_IO: Final = "faas.net_io"
"""
Distribution of net I/O usage per invocation
Instrument: histogram
Unit: By
"""
def create_faas_net_io(meter: Meter) -> Histogram:
"""Distribution of net I/O usage per invocation"""
return meter.create_histogram(
name=FAAS_NET_IO,
description="Distribution of net I/O usage per invocation.",
unit="By",
)
FAAS_TIMEOUTS: Final = "faas.timeouts"
"""
Number of invocation timeouts
Instrument: counter
Unit: {timeout}
"""
def create_faas_timeouts(meter: Meter) -> Counter:
"""Number of invocation timeouts"""
return meter.create_counter(
name=FAAS_TIMEOUTS,
description="Number of invocation timeouts.",
unit="{timeout}",
)

View File

@@ -0,0 +1,104 @@
# Copyright The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Final
from opentelemetry.metrics import Histogram, Meter
GEN_AI_CLIENT_OPERATION_DURATION: Final = "gen_ai.client.operation.duration"
"""
GenAI operation duration
Instrument: histogram
Unit: s
"""
def create_gen_ai_client_operation_duration(meter: Meter) -> Histogram:
"""GenAI operation duration"""
return meter.create_histogram(
name=GEN_AI_CLIENT_OPERATION_DURATION,
description="GenAI operation duration.",
unit="s",
)
GEN_AI_CLIENT_TOKEN_USAGE: Final = "gen_ai.client.token.usage"
"""
Number of input and output tokens used
Instrument: histogram
Unit: {token}
"""
def create_gen_ai_client_token_usage(meter: Meter) -> Histogram:
"""Number of input and output tokens used"""
return meter.create_histogram(
name=GEN_AI_CLIENT_TOKEN_USAGE,
description="Number of input and output tokens used.",
unit="{token}",
)
GEN_AI_SERVER_REQUEST_DURATION: Final = "gen_ai.server.request.duration"
"""
Generative AI server request duration such as time-to-last byte or last output token
Instrument: histogram
Unit: s
"""
def create_gen_ai_server_request_duration(meter: Meter) -> Histogram:
"""Generative AI server request duration such as time-to-last byte or last output token"""
return meter.create_histogram(
name=GEN_AI_SERVER_REQUEST_DURATION,
description="Generative AI server request duration such as time-to-last byte or last output token.",
unit="s",
)
GEN_AI_SERVER_TIME_PER_OUTPUT_TOKEN: Final = (
"gen_ai.server.time_per_output_token"
)
"""
Time per output token generated after the first token for successful responses
Instrument: histogram
Unit: s
"""
def create_gen_ai_server_time_per_output_token(meter: Meter) -> Histogram:
"""Time per output token generated after the first token for successful responses"""
return meter.create_histogram(
name=GEN_AI_SERVER_TIME_PER_OUTPUT_TOKEN,
description="Time per output token generated after the first token for successful responses.",
unit="s",
)
GEN_AI_SERVER_TIME_TO_FIRST_TOKEN: Final = "gen_ai.server.time_to_first_token"
"""
Time to generate first token for successful responses
Instrument: histogram
Unit: s
"""
def create_gen_ai_server_time_to_first_token(meter: Meter) -> Histogram:
"""Time to generate first token for successful responses"""
return meter.create_histogram(
name=GEN_AI_SERVER_TIME_TO_FIRST_TOKEN,
description="Time to generate first token for successful responses.",
unit="s",
)

View File

@@ -0,0 +1,187 @@
# Copyright The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Final
from opentelemetry.metrics import Histogram, Meter, UpDownCounter
HTTP_CLIENT_ACTIVE_REQUESTS: Final = "http.client.active_requests"
"""
Number of active HTTP requests
Instrument: updowncounter
Unit: {request}
"""
def create_http_client_active_requests(meter: Meter) -> UpDownCounter:
"""Number of active HTTP requests"""
return meter.create_up_down_counter(
name=HTTP_CLIENT_ACTIVE_REQUESTS,
description="Number of active HTTP requests.",
unit="{request}",
)
HTTP_CLIENT_CONNECTION_DURATION: Final = "http.client.connection.duration"
"""
The duration of the successfully established outbound HTTP connections
Instrument: histogram
Unit: s
"""
def create_http_client_connection_duration(meter: Meter) -> Histogram:
"""The duration of the successfully established outbound HTTP connections"""
return meter.create_histogram(
name=HTTP_CLIENT_CONNECTION_DURATION,
description="The duration of the successfully established outbound HTTP connections.",
unit="s",
)
HTTP_CLIENT_OPEN_CONNECTIONS: Final = "http.client.open_connections"
"""
Number of outbound HTTP connections that are currently active or idle on the client
Instrument: updowncounter
Unit: {connection}
"""
def create_http_client_open_connections(meter: Meter) -> UpDownCounter:
"""Number of outbound HTTP connections that are currently active or idle on the client"""
return meter.create_up_down_counter(
name=HTTP_CLIENT_OPEN_CONNECTIONS,
description="Number of outbound HTTP connections that are currently active or idle on the client.",
unit="{connection}",
)
HTTP_CLIENT_REQUEST_BODY_SIZE: Final = "http.client.request.body.size"
"""
Size of HTTP client request bodies
Instrument: histogram
Unit: By
Note: The size of the request payload body in bytes. This is the number of bytes transferred excluding headers and is often, but not always, present as the [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length) header. For requests using transport encoding, this should be the compressed size.
"""
def create_http_client_request_body_size(meter: Meter) -> Histogram:
"""Size of HTTP client request bodies"""
return meter.create_histogram(
name=HTTP_CLIENT_REQUEST_BODY_SIZE,
description="Size of HTTP client request bodies.",
unit="By",
)
HTTP_CLIENT_REQUEST_DURATION: Final = "http.client.request.duration"
"""
Deprecated in favor of stable :py:const:`opentelemetry.semconv.metrics.http_metrics.HTTP_CLIENT_REQUEST_DURATION`.
"""
def create_http_client_request_duration(meter: Meter) -> Histogram:
"""Duration of HTTP client requests"""
return meter.create_histogram(
name=HTTP_CLIENT_REQUEST_DURATION,
description="Duration of HTTP client requests.",
unit="s",
)
HTTP_CLIENT_RESPONSE_BODY_SIZE: Final = "http.client.response.body.size"
"""
Size of HTTP client response bodies
Instrument: histogram
Unit: By
Note: The size of the response payload body in bytes. This is the number of bytes transferred excluding headers and is often, but not always, present as the [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length) header. For requests using transport encoding, this should be the compressed size.
"""
def create_http_client_response_body_size(meter: Meter) -> Histogram:
"""Size of HTTP client response bodies"""
return meter.create_histogram(
name=HTTP_CLIENT_RESPONSE_BODY_SIZE,
description="Size of HTTP client response bodies.",
unit="By",
)
HTTP_SERVER_ACTIVE_REQUESTS: Final = "http.server.active_requests"
"""
Number of active HTTP server requests
Instrument: updowncounter
Unit: {request}
"""
def create_http_server_active_requests(meter: Meter) -> UpDownCounter:
"""Number of active HTTP server requests"""
return meter.create_up_down_counter(
name=HTTP_SERVER_ACTIVE_REQUESTS,
description="Number of active HTTP server requests.",
unit="{request}",
)
HTTP_SERVER_REQUEST_BODY_SIZE: Final = "http.server.request.body.size"
"""
Size of HTTP server request bodies
Instrument: histogram
Unit: By
Note: The size of the request payload body in bytes. This is the number of bytes transferred excluding headers and is often, but not always, present as the [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length) header. For requests using transport encoding, this should be the compressed size.
"""
def create_http_server_request_body_size(meter: Meter) -> Histogram:
"""Size of HTTP server request bodies"""
return meter.create_histogram(
name=HTTP_SERVER_REQUEST_BODY_SIZE,
description="Size of HTTP server request bodies.",
unit="By",
)
HTTP_SERVER_REQUEST_DURATION: Final = "http.server.request.duration"
"""
Deprecated in favor of stable :py:const:`opentelemetry.semconv.metrics.http_metrics.HTTP_SERVER_REQUEST_DURATION`.
"""
def create_http_server_request_duration(meter: Meter) -> Histogram:
"""Duration of HTTP server requests"""
return meter.create_histogram(
name=HTTP_SERVER_REQUEST_DURATION,
description="Duration of HTTP server requests.",
unit="s",
)
HTTP_SERVER_RESPONSE_BODY_SIZE: Final = "http.server.response.body.size"
"""
Size of HTTP server response bodies
Instrument: histogram
Unit: By
Note: The size of the response payload body in bytes. This is the number of bytes transferred excluding headers and is often, but not always, present as the [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length) header. For requests using transport encoding, this should be the compressed size.
"""
def create_http_server_response_body_size(meter: Meter) -> Histogram:
"""Size of HTTP server response bodies"""
return meter.create_histogram(
name=HTTP_SERVER_RESPONSE_BODY_SIZE,
description="Size of HTTP server response bodies.",
unit="By",
)

View File

@@ -0,0 +1,830 @@
# Copyright The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import (
Callable,
Final,
Generator,
Iterable,
Optional,
Sequence,
Union,
)
from opentelemetry.metrics import (
CallbackOptions,
Counter,
Meter,
ObservableGauge,
Observation,
UpDownCounter,
)
# pylint: disable=invalid-name
CallbackT = Union[
Callable[[CallbackOptions], Iterable[Observation]],
Generator[Iterable[Observation], CallbackOptions, None],
]
HW_BATTERY_CHARGE: Final = "hw.battery.charge"
"""
Remaining fraction of battery charge
Instrument: gauge
Unit: 1
"""
def create_hw_battery_charge(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Remaining fraction of battery charge"""
return meter.create_observable_gauge(
name=HW_BATTERY_CHARGE,
callbacks=callbacks,
description="Remaining fraction of battery charge.",
unit="1",
)
HW_BATTERY_CHARGE_LIMIT: Final = "hw.battery.charge.limit"
"""
Lower limit of battery charge fraction to ensure proper operation
Instrument: gauge
Unit: 1
"""
def create_hw_battery_charge_limit(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Lower limit of battery charge fraction to ensure proper operation"""
return meter.create_observable_gauge(
name=HW_BATTERY_CHARGE_LIMIT,
callbacks=callbacks,
description="Lower limit of battery charge fraction to ensure proper operation.",
unit="1",
)
HW_BATTERY_TIME_LEFT: Final = "hw.battery.time_left"
"""
Time left before battery is completely charged or discharged
Instrument: gauge
Unit: s
"""
def create_hw_battery_time_left(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Time left before battery is completely charged or discharged"""
return meter.create_observable_gauge(
name=HW_BATTERY_TIME_LEFT,
callbacks=callbacks,
description="Time left before battery is completely charged or discharged.",
unit="s",
)
HW_CPU_SPEED: Final = "hw.cpu.speed"
"""
CPU current frequency
Instrument: gauge
Unit: Hz
"""
def create_hw_cpu_speed(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""CPU current frequency"""
return meter.create_observable_gauge(
name=HW_CPU_SPEED,
callbacks=callbacks,
description="CPU current frequency.",
unit="Hz",
)
HW_CPU_SPEED_LIMIT: Final = "hw.cpu.speed.limit"
"""
CPU maximum frequency
Instrument: gauge
Unit: Hz
"""
def create_hw_cpu_speed_limit(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""CPU maximum frequency"""
return meter.create_observable_gauge(
name=HW_CPU_SPEED_LIMIT,
callbacks=callbacks,
description="CPU maximum frequency.",
unit="Hz",
)
HW_ENERGY: Final = "hw.energy"
"""
Energy consumed by the component
Instrument: counter
Unit: J
"""
def create_hw_energy(meter: Meter) -> Counter:
"""Energy consumed by the component"""
return meter.create_counter(
name=HW_ENERGY,
description="Energy consumed by the component.",
unit="J",
)
HW_ERRORS: Final = "hw.errors"
"""
Number of errors encountered by the component
Instrument: counter
Unit: {error}
"""
def create_hw_errors(meter: Meter) -> Counter:
"""Number of errors encountered by the component"""
return meter.create_counter(
name=HW_ERRORS,
description="Number of errors encountered by the component.",
unit="{error}",
)
HW_FAN_SPEED: Final = "hw.fan.speed"
"""
Fan speed in revolutions per minute
Instrument: gauge
Unit: rpm
"""
def create_hw_fan_speed(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Fan speed in revolutions per minute"""
return meter.create_observable_gauge(
name=HW_FAN_SPEED,
callbacks=callbacks,
description="Fan speed in revolutions per minute.",
unit="rpm",
)
HW_FAN_SPEED_LIMIT: Final = "hw.fan.speed.limit"
"""
Speed limit in rpm
Instrument: gauge
Unit: rpm
"""
def create_hw_fan_speed_limit(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Speed limit in rpm"""
return meter.create_observable_gauge(
name=HW_FAN_SPEED_LIMIT,
callbacks=callbacks,
description="Speed limit in rpm.",
unit="rpm",
)
HW_FAN_SPEED_RATIO: Final = "hw.fan.speed_ratio"
"""
Fan speed expressed as a fraction of its maximum speed
Instrument: gauge
Unit: 1
"""
def create_hw_fan_speed_ratio(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Fan speed expressed as a fraction of its maximum speed"""
return meter.create_observable_gauge(
name=HW_FAN_SPEED_RATIO,
callbacks=callbacks,
description="Fan speed expressed as a fraction of its maximum speed.",
unit="1",
)
HW_GPU_IO: Final = "hw.gpu.io"
"""
Received and transmitted bytes by the GPU
Instrument: counter
Unit: By
"""
def create_hw_gpu_io(meter: Meter) -> Counter:
"""Received and transmitted bytes by the GPU"""
return meter.create_counter(
name=HW_GPU_IO,
description="Received and transmitted bytes by the GPU.",
unit="By",
)
HW_GPU_MEMORY_LIMIT: Final = "hw.gpu.memory.limit"
"""
Size of the GPU memory
Instrument: updowncounter
Unit: By
"""
def create_hw_gpu_memory_limit(meter: Meter) -> UpDownCounter:
"""Size of the GPU memory"""
return meter.create_up_down_counter(
name=HW_GPU_MEMORY_LIMIT,
description="Size of the GPU memory.",
unit="By",
)
HW_GPU_MEMORY_USAGE: Final = "hw.gpu.memory.usage"
"""
GPU memory used
Instrument: updowncounter
Unit: By
"""
def create_hw_gpu_memory_usage(meter: Meter) -> UpDownCounter:
"""GPU memory used"""
return meter.create_up_down_counter(
name=HW_GPU_MEMORY_USAGE,
description="GPU memory used.",
unit="By",
)
HW_GPU_MEMORY_UTILIZATION: Final = "hw.gpu.memory.utilization"
"""
Fraction of GPU memory used
Instrument: gauge
Unit: 1
"""
def create_hw_gpu_memory_utilization(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Fraction of GPU memory used"""
return meter.create_observable_gauge(
name=HW_GPU_MEMORY_UTILIZATION,
callbacks=callbacks,
description="Fraction of GPU memory used.",
unit="1",
)
HW_GPU_UTILIZATION: Final = "hw.gpu.utilization"
"""
Fraction of time spent in a specific task
Instrument: gauge
Unit: 1
"""
def create_hw_gpu_utilization(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Fraction of time spent in a specific task"""
return meter.create_observable_gauge(
name=HW_GPU_UTILIZATION,
callbacks=callbacks,
description="Fraction of time spent in a specific task.",
unit="1",
)
HW_HOST_AMBIENT_TEMPERATURE: Final = "hw.host.ambient_temperature"
"""
Ambient (external) temperature of the physical host
Instrument: gauge
Unit: Cel
"""
def create_hw_host_ambient_temperature(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Ambient (external) temperature of the physical host"""
return meter.create_observable_gauge(
name=HW_HOST_AMBIENT_TEMPERATURE,
callbacks=callbacks,
description="Ambient (external) temperature of the physical host.",
unit="Cel",
)
HW_HOST_ENERGY: Final = "hw.host.energy"
"""
Total energy consumed by the entire physical host, in joules
Instrument: counter
Unit: J
Note: The overall energy usage of a host MUST be reported using the specific `hw.host.energy` and `hw.host.power` metrics **only**, instead of the generic `hw.energy` and `hw.power` described in the previous section, to prevent summing up overlapping values.
"""
def create_hw_host_energy(meter: Meter) -> Counter:
"""Total energy consumed by the entire physical host, in joules"""
return meter.create_counter(
name=HW_HOST_ENERGY,
description="Total energy consumed by the entire physical host, in joules.",
unit="J",
)
HW_HOST_HEATING_MARGIN: Final = "hw.host.heating_margin"
"""
By how many degrees Celsius the temperature of the physical host can be increased, before reaching a warning threshold on one of the internal sensors
Instrument: gauge
Unit: Cel
"""
def create_hw_host_heating_margin(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""By how many degrees Celsius the temperature of the physical host can be increased, before reaching a warning threshold on one of the internal sensors"""
return meter.create_observable_gauge(
name=HW_HOST_HEATING_MARGIN,
callbacks=callbacks,
description="By how many degrees Celsius the temperature of the physical host can be increased, before reaching a warning threshold on one of the internal sensors.",
unit="Cel",
)
HW_HOST_POWER: Final = "hw.host.power"
"""
Instantaneous power consumed by the entire physical host in Watts (`hw.host.energy` is preferred)
Instrument: gauge
Unit: W
Note: The overall energy usage of a host MUST be reported using the specific `hw.host.energy` and `hw.host.power` metrics **only**, instead of the generic `hw.energy` and `hw.power` described in the previous section, to prevent summing up overlapping values.
"""
def create_hw_host_power(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Instantaneous power consumed by the entire physical host in Watts (`hw.host.energy` is preferred)"""
return meter.create_observable_gauge(
name=HW_HOST_POWER,
callbacks=callbacks,
description="Instantaneous power consumed by the entire physical host in Watts (`hw.host.energy` is preferred).",
unit="W",
)
HW_LOGICAL_DISK_LIMIT: Final = "hw.logical_disk.limit"
"""
Size of the logical disk
Instrument: updowncounter
Unit: By
"""
def create_hw_logical_disk_limit(meter: Meter) -> UpDownCounter:
"""Size of the logical disk"""
return meter.create_up_down_counter(
name=HW_LOGICAL_DISK_LIMIT,
description="Size of the logical disk.",
unit="By",
)
HW_LOGICAL_DISK_USAGE: Final = "hw.logical_disk.usage"
"""
Logical disk space usage
Instrument: updowncounter
Unit: By
"""
def create_hw_logical_disk_usage(meter: Meter) -> UpDownCounter:
"""Logical disk space usage"""
return meter.create_up_down_counter(
name=HW_LOGICAL_DISK_USAGE,
description="Logical disk space usage.",
unit="By",
)
HW_LOGICAL_DISK_UTILIZATION: Final = "hw.logical_disk.utilization"
"""
Logical disk space utilization as a fraction
Instrument: gauge
Unit: 1
"""
def create_hw_logical_disk_utilization(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Logical disk space utilization as a fraction"""
return meter.create_observable_gauge(
name=HW_LOGICAL_DISK_UTILIZATION,
callbacks=callbacks,
description="Logical disk space utilization as a fraction.",
unit="1",
)
HW_MEMORY_SIZE: Final = "hw.memory.size"
"""
Size of the memory module
Instrument: updowncounter
Unit: By
"""
def create_hw_memory_size(meter: Meter) -> UpDownCounter:
"""Size of the memory module"""
return meter.create_up_down_counter(
name=HW_MEMORY_SIZE,
description="Size of the memory module.",
unit="By",
)
HW_NETWORK_BANDWIDTH_LIMIT: Final = "hw.network.bandwidth.limit"
"""
Link speed
Instrument: updowncounter
Unit: By/s
"""
def create_hw_network_bandwidth_limit(meter: Meter) -> UpDownCounter:
"""Link speed"""
return meter.create_up_down_counter(
name=HW_NETWORK_BANDWIDTH_LIMIT,
description="Link speed.",
unit="By/s",
)
HW_NETWORK_BANDWIDTH_UTILIZATION: Final = "hw.network.bandwidth.utilization"
"""
Utilization of the network bandwidth as a fraction
Instrument: gauge
Unit: 1
"""
def create_hw_network_bandwidth_utilization(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Utilization of the network bandwidth as a fraction"""
return meter.create_observable_gauge(
name=HW_NETWORK_BANDWIDTH_UTILIZATION,
callbacks=callbacks,
description="Utilization of the network bandwidth as a fraction.",
unit="1",
)
HW_NETWORK_IO: Final = "hw.network.io"
"""
Received and transmitted network traffic in bytes
Instrument: counter
Unit: By
"""
def create_hw_network_io(meter: Meter) -> Counter:
"""Received and transmitted network traffic in bytes"""
return meter.create_counter(
name=HW_NETWORK_IO,
description="Received and transmitted network traffic in bytes.",
unit="By",
)
HW_NETWORK_PACKETS: Final = "hw.network.packets"
"""
Received and transmitted network traffic in packets (or frames)
Instrument: counter
Unit: {packet}
"""
def create_hw_network_packets(meter: Meter) -> Counter:
"""Received and transmitted network traffic in packets (or frames)"""
return meter.create_counter(
name=HW_NETWORK_PACKETS,
description="Received and transmitted network traffic in packets (or frames).",
unit="{packet}",
)
HW_NETWORK_UP: Final = "hw.network.up"
"""
Link status: `1` (up) or `0` (down)
Instrument: updowncounter
Unit: 1
"""
def create_hw_network_up(meter: Meter) -> UpDownCounter:
"""Link status: `1` (up) or `0` (down)"""
return meter.create_up_down_counter(
name=HW_NETWORK_UP,
description="Link status: `1` (up) or `0` (down).",
unit="1",
)
HW_PHYSICAL_DISK_ENDURANCE_UTILIZATION: Final = (
"hw.physical_disk.endurance_utilization"
)
"""
Endurance remaining for this SSD disk
Instrument: gauge
Unit: 1
"""
def create_hw_physical_disk_endurance_utilization(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Endurance remaining for this SSD disk"""
return meter.create_observable_gauge(
name=HW_PHYSICAL_DISK_ENDURANCE_UTILIZATION,
callbacks=callbacks,
description="Endurance remaining for this SSD disk.",
unit="1",
)
HW_PHYSICAL_DISK_SIZE: Final = "hw.physical_disk.size"
"""
Size of the disk
Instrument: updowncounter
Unit: By
"""
def create_hw_physical_disk_size(meter: Meter) -> UpDownCounter:
"""Size of the disk"""
return meter.create_up_down_counter(
name=HW_PHYSICAL_DISK_SIZE,
description="Size of the disk.",
unit="By",
)
HW_PHYSICAL_DISK_SMART: Final = "hw.physical_disk.smart"
"""
Value of the corresponding [S.M.A.R.T.](https://wikipedia.org/wiki/S.M.A.R.T.) (Self-Monitoring, Analysis, and Reporting Technology) attribute
Instrument: gauge
Unit: 1
"""
def create_hw_physical_disk_smart(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Value of the corresponding [S.M.A.R.T.](https://wikipedia.org/wiki/S.M.A.R.T.) (Self-Monitoring, Analysis, and Reporting Technology) attribute"""
return meter.create_observable_gauge(
name=HW_PHYSICAL_DISK_SMART,
callbacks=callbacks,
description="Value of the corresponding [S.M.A.R.T.](https://wikipedia.org/wiki/S.M.A.R.T.) (Self-Monitoring, Analysis, and Reporting Technology) attribute.",
unit="1",
)
HW_POWER: Final = "hw.power"
"""
Instantaneous power consumed by the component
Instrument: gauge
Unit: W
Note: It is recommended to report `hw.energy` instead of `hw.power` when possible.
"""
def create_hw_power(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Instantaneous power consumed by the component"""
return meter.create_observable_gauge(
name=HW_POWER,
callbacks=callbacks,
description="Instantaneous power consumed by the component.",
unit="W",
)
HW_POWER_SUPPLY_LIMIT: Final = "hw.power_supply.limit"
"""
Maximum power output of the power supply
Instrument: updowncounter
Unit: W
"""
def create_hw_power_supply_limit(meter: Meter) -> UpDownCounter:
"""Maximum power output of the power supply"""
return meter.create_up_down_counter(
name=HW_POWER_SUPPLY_LIMIT,
description="Maximum power output of the power supply.",
unit="W",
)
HW_POWER_SUPPLY_USAGE: Final = "hw.power_supply.usage"
"""
Current power output of the power supply
Instrument: updowncounter
Unit: W
"""
def create_hw_power_supply_usage(meter: Meter) -> UpDownCounter:
"""Current power output of the power supply"""
return meter.create_up_down_counter(
name=HW_POWER_SUPPLY_USAGE,
description="Current power output of the power supply.",
unit="W",
)
HW_POWER_SUPPLY_UTILIZATION: Final = "hw.power_supply.utilization"
"""
Utilization of the power supply as a fraction of its maximum output
Instrument: gauge
Unit: 1
"""
def create_hw_power_supply_utilization(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Utilization of the power supply as a fraction of its maximum output"""
return meter.create_observable_gauge(
name=HW_POWER_SUPPLY_UTILIZATION,
callbacks=callbacks,
description="Utilization of the power supply as a fraction of its maximum output.",
unit="1",
)
HW_STATUS: Final = "hw.status"
"""
Operational status: `1` (true) or `0` (false) for each of the possible states
Instrument: updowncounter
Unit: 1
Note: `hw.status` is currently specified as an *UpDownCounter* but would ideally be represented using a [*StateSet* as defined in OpenMetrics](https://github.com/prometheus/OpenMetrics/blob/v1.0.0/specification/OpenMetrics.md#stateset). This semantic convention will be updated once *StateSet* is specified in OpenTelemetry. This planned change is not expected to have any consequence on the way users query their timeseries backend to retrieve the values of `hw.status` over time.
"""
def create_hw_status(meter: Meter) -> UpDownCounter:
"""Operational status: `1` (true) or `0` (false) for each of the possible states"""
return meter.create_up_down_counter(
name=HW_STATUS,
description="Operational status: `1` (true) or `0` (false) for each of the possible states.",
unit="1",
)
HW_TAPE_DRIVE_OPERATIONS: Final = "hw.tape_drive.operations"
"""
Operations performed by the tape drive
Instrument: counter
Unit: {operation}
"""
def create_hw_tape_drive_operations(meter: Meter) -> Counter:
"""Operations performed by the tape drive"""
return meter.create_counter(
name=HW_TAPE_DRIVE_OPERATIONS,
description="Operations performed by the tape drive.",
unit="{operation}",
)
HW_TEMPERATURE: Final = "hw.temperature"
"""
Temperature in degrees Celsius
Instrument: gauge
Unit: Cel
"""
def create_hw_temperature(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Temperature in degrees Celsius"""
return meter.create_observable_gauge(
name=HW_TEMPERATURE,
callbacks=callbacks,
description="Temperature in degrees Celsius.",
unit="Cel",
)
HW_TEMPERATURE_LIMIT: Final = "hw.temperature.limit"
"""
Temperature limit in degrees Celsius
Instrument: gauge
Unit: Cel
"""
def create_hw_temperature_limit(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Temperature limit in degrees Celsius"""
return meter.create_observable_gauge(
name=HW_TEMPERATURE_LIMIT,
callbacks=callbacks,
description="Temperature limit in degrees Celsius.",
unit="Cel",
)
HW_VOLTAGE: Final = "hw.voltage"
"""
Voltage measured by the sensor
Instrument: gauge
Unit: V
"""
def create_hw_voltage(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Voltage measured by the sensor"""
return meter.create_observable_gauge(
name=HW_VOLTAGE,
callbacks=callbacks,
description="Voltage measured by the sensor.",
unit="V",
)
HW_VOLTAGE_LIMIT: Final = "hw.voltage.limit"
"""
Voltage limit in Volts
Instrument: gauge
Unit: V
"""
def create_hw_voltage_limit(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Voltage limit in Volts"""
return meter.create_observable_gauge(
name=HW_VOLTAGE_LIMIT,
callbacks=callbacks,
description="Voltage limit in Volts.",
unit="V",
)
HW_VOLTAGE_NOMINAL: Final = "hw.voltage.nominal"
"""
Nominal (expected) voltage
Instrument: gauge
Unit: V
"""
def create_hw_voltage_nominal(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Nominal (expected) voltage"""
return meter.create_observable_gauge(
name=HW_VOLTAGE_NOMINAL,
callbacks=callbacks,
description="Nominal (expected) voltage.",
unit="V",
)

View File

@@ -0,0 +1,186 @@
# Copyright The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Final
from opentelemetry.metrics import Counter, Histogram, Meter
MESSAGING_CLIENT_CONSUMED_MESSAGES: Final = (
"messaging.client.consumed.messages"
)
"""
Number of messages that were delivered to the application
Instrument: counter
Unit: {message}
Note: Records the number of messages pulled from the broker or number of messages dispatched to the application in push-based scenarios.
The metric SHOULD be reported once per message delivery. For example, if receiving and processing operations are both instrumented for a single message delivery, this counter is incremented when the message is received and not reported when it is processed.
"""
def create_messaging_client_consumed_messages(meter: Meter) -> Counter:
"""Number of messages that were delivered to the application"""
return meter.create_counter(
name=MESSAGING_CLIENT_CONSUMED_MESSAGES,
description="Number of messages that were delivered to the application.",
unit="{message}",
)
MESSAGING_CLIENT_OPERATION_DURATION: Final = (
"messaging.client.operation.duration"
)
"""
Duration of messaging operation initiated by a producer or consumer client
Instrument: histogram
Unit: s
Note: This metric SHOULD NOT be used to report processing duration - processing duration is reported in `messaging.process.duration` metric.
"""
def create_messaging_client_operation_duration(meter: Meter) -> Histogram:
"""Duration of messaging operation initiated by a producer or consumer client"""
return meter.create_histogram(
name=MESSAGING_CLIENT_OPERATION_DURATION,
description="Duration of messaging operation initiated by a producer or consumer client.",
unit="s",
)
MESSAGING_CLIENT_PUBLISHED_MESSAGES: Final = (
"messaging.client.published.messages"
)
"""
Deprecated: Replaced by `messaging.client.sent.messages`.
"""
def create_messaging_client_published_messages(meter: Meter) -> Counter:
"""Deprecated. Use `messaging.client.sent.messages` instead"""
return meter.create_counter(
name=MESSAGING_CLIENT_PUBLISHED_MESSAGES,
description="Deprecated. Use `messaging.client.sent.messages` instead.",
unit="{message}",
)
MESSAGING_CLIENT_SENT_MESSAGES: Final = "messaging.client.sent.messages"
"""
Number of messages producer attempted to send to the broker
Instrument: counter
Unit: {message}
Note: This metric MUST NOT count messages that were created but haven't yet been sent.
"""
def create_messaging_client_sent_messages(meter: Meter) -> Counter:
"""Number of messages producer attempted to send to the broker"""
return meter.create_counter(
name=MESSAGING_CLIENT_SENT_MESSAGES,
description="Number of messages producer attempted to send to the broker.",
unit="{message}",
)
MESSAGING_PROCESS_DURATION: Final = "messaging.process.duration"
"""
Duration of processing operation
Instrument: histogram
Unit: s
Note: This metric MUST be reported for operations with `messaging.operation.type` that matches `process`.
"""
def create_messaging_process_duration(meter: Meter) -> Histogram:
"""Duration of processing operation"""
return meter.create_histogram(
name=MESSAGING_PROCESS_DURATION,
description="Duration of processing operation.",
unit="s",
)
MESSAGING_PROCESS_MESSAGES: Final = "messaging.process.messages"
"""
Deprecated: Replaced by `messaging.client.consumed.messages`.
"""
def create_messaging_process_messages(meter: Meter) -> Counter:
"""Deprecated. Use `messaging.client.consumed.messages` instead"""
return meter.create_counter(
name=MESSAGING_PROCESS_MESSAGES,
description="Deprecated. Use `messaging.client.consumed.messages` instead.",
unit="{message}",
)
MESSAGING_PUBLISH_DURATION: Final = "messaging.publish.duration"
"""
Deprecated: Replaced by `messaging.client.operation.duration`.
"""
def create_messaging_publish_duration(meter: Meter) -> Histogram:
"""Deprecated. Use `messaging.client.operation.duration` instead"""
return meter.create_histogram(
name=MESSAGING_PUBLISH_DURATION,
description="Deprecated. Use `messaging.client.operation.duration` instead.",
unit="s",
)
MESSAGING_PUBLISH_MESSAGES: Final = "messaging.publish.messages"
"""
Deprecated: Replaced by `messaging.client.sent.messages`.
"""
def create_messaging_publish_messages(meter: Meter) -> Counter:
"""Deprecated. Use `messaging.client.sent.messages` instead"""
return meter.create_counter(
name=MESSAGING_PUBLISH_MESSAGES,
description="Deprecated. Use `messaging.client.sent.messages` instead.",
unit="{message}",
)
MESSAGING_RECEIVE_DURATION: Final = "messaging.receive.duration"
"""
Deprecated: Replaced by `messaging.client.operation.duration`.
"""
def create_messaging_receive_duration(meter: Meter) -> Histogram:
"""Deprecated. Use `messaging.client.operation.duration` instead"""
return meter.create_histogram(
name=MESSAGING_RECEIVE_DURATION,
description="Deprecated. Use `messaging.client.operation.duration` instead.",
unit="s",
)
MESSAGING_RECEIVE_MESSAGES: Final = "messaging.receive.messages"
"""
Deprecated: Replaced by `messaging.client.consumed.messages`.
"""
def create_messaging_receive_messages(meter: Meter) -> Counter:
"""Deprecated. Use `messaging.client.consumed.messages` instead"""
return meter.create_counter(
name=MESSAGING_RECEIVE_MESSAGES,
description="Deprecated. Use `messaging.client.consumed.messages` instead.",
unit="{message}",
)

View File

@@ -0,0 +1,305 @@
# Copyright The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Final
from opentelemetry.metrics import Counter, Meter, UpDownCounter
NFS_CLIENT_NET_COUNT: Final = "nfs.client.net.count"
"""
Reports the count of kernel NFS client TCP segments and UDP datagrams handled
Instrument: counter
Unit: {record}
Note: Linux: this metric is taken from the Linux kernel's svc_stat.netudpcnt and svc_stat.nettcpcnt.
"""
def create_nfs_client_net_count(meter: Meter) -> Counter:
"""Reports the count of kernel NFS client TCP segments and UDP datagrams handled"""
return meter.create_counter(
name=NFS_CLIENT_NET_COUNT,
description="Reports the count of kernel NFS client TCP segments and UDP datagrams handled.",
unit="{record}",
)
NFS_CLIENT_NET_TCP_CONNECTION_ACCEPTED: Final = (
"nfs.client.net.tcp.connection.accepted"
)
"""
Reports the count of kernel NFS client TCP connections accepted
Instrument: counter
Unit: {connection}
Note: Linux: this metric is taken from the Linux kernel's svc_stat.nettcpconn.
"""
def create_nfs_client_net_tcp_connection_accepted(meter: Meter) -> Counter:
"""Reports the count of kernel NFS client TCP connections accepted"""
return meter.create_counter(
name=NFS_CLIENT_NET_TCP_CONNECTION_ACCEPTED,
description="Reports the count of kernel NFS client TCP connections accepted.",
unit="{connection}",
)
NFS_CLIENT_OPERATION_COUNT: Final = "nfs.client.operation.count"
"""
Reports the count of kernel NFSv4+ client operations
Instrument: counter
Unit: {operation}
"""
def create_nfs_client_operation_count(meter: Meter) -> Counter:
"""Reports the count of kernel NFSv4+ client operations"""
return meter.create_counter(
name=NFS_CLIENT_OPERATION_COUNT,
description="Reports the count of kernel NFSv4+ client operations.",
unit="{operation}",
)
NFS_CLIENT_PROCEDURE_COUNT: Final = "nfs.client.procedure.count"
"""
Reports the count of kernel NFS client procedures
Instrument: counter
Unit: {procedure}
"""
def create_nfs_client_procedure_count(meter: Meter) -> Counter:
"""Reports the count of kernel NFS client procedures"""
return meter.create_counter(
name=NFS_CLIENT_PROCEDURE_COUNT,
description="Reports the count of kernel NFS client procedures.",
unit="{procedure}",
)
NFS_CLIENT_RPC_AUTHREFRESH_COUNT: Final = "nfs.client.rpc.authrefresh.count"
"""
Reports the count of kernel NFS client RPC authentication refreshes
Instrument: counter
Unit: {authrefresh}
Note: Linux: this metric is taken from the Linux kernel's svc_stat.rpcauthrefresh.
"""
def create_nfs_client_rpc_authrefresh_count(meter: Meter) -> Counter:
"""Reports the count of kernel NFS client RPC authentication refreshes"""
return meter.create_counter(
name=NFS_CLIENT_RPC_AUTHREFRESH_COUNT,
description="Reports the count of kernel NFS client RPC authentication refreshes.",
unit="{authrefresh}",
)
NFS_CLIENT_RPC_COUNT: Final = "nfs.client.rpc.count"
"""
Reports the count of kernel NFS client RPCs sent, regardless of whether they're accepted/rejected by the server
Instrument: counter
Unit: {request}
Note: Linux: this metric is taken from the Linux kernel's svc_stat.rpccnt.
"""
def create_nfs_client_rpc_count(meter: Meter) -> Counter:
"""Reports the count of kernel NFS client RPCs sent, regardless of whether they're accepted/rejected by the server"""
return meter.create_counter(
name=NFS_CLIENT_RPC_COUNT,
description="Reports the count of kernel NFS client RPCs sent, regardless of whether they're accepted/rejected by the server.",
unit="{request}",
)
NFS_CLIENT_RPC_RETRANSMIT_COUNT: Final = "nfs.client.rpc.retransmit.count"
"""
Reports the count of kernel NFS client RPC retransmits
Instrument: counter
Unit: {retransmit}
Note: Linux: this metric is taken from the Linux kernel's svc_stat.rpcretrans.
"""
def create_nfs_client_rpc_retransmit_count(meter: Meter) -> Counter:
"""Reports the count of kernel NFS client RPC retransmits"""
return meter.create_counter(
name=NFS_CLIENT_RPC_RETRANSMIT_COUNT,
description="Reports the count of kernel NFS client RPC retransmits.",
unit="{retransmit}",
)
NFS_SERVER_FH_STALE_COUNT: Final = "nfs.server.fh.stale.count"
"""
Reports the count of kernel NFS server stale file handles
Instrument: counter
Unit: {fh}
Note: Linux: this metric is taken from the Linux kernel NFSD_STATS_FH_STALE counter in the nfsd_net struct.
"""
def create_nfs_server_fh_stale_count(meter: Meter) -> Counter:
"""Reports the count of kernel NFS server stale file handles"""
return meter.create_counter(
name=NFS_SERVER_FH_STALE_COUNT,
description="Reports the count of kernel NFS server stale file handles.",
unit="{fh}",
)
NFS_SERVER_IO: Final = "nfs.server.io"
"""
Reports the count of kernel NFS server bytes returned to receive and transmit (read and write) requests
Instrument: counter
Unit: By
Note: Linux: this metric is taken from the Linux kernel NFSD_STATS_IO_READ and NFSD_STATS_IO_WRITE counters in the nfsd_net struct.
"""
def create_nfs_server_io(meter: Meter) -> Counter:
"""Reports the count of kernel NFS server bytes returned to receive and transmit (read and write) requests"""
return meter.create_counter(
name=NFS_SERVER_IO,
description="Reports the count of kernel NFS server bytes returned to receive and transmit (read and write) requests.",
unit="By",
)
NFS_SERVER_NET_COUNT: Final = "nfs.server.net.count"
"""
Reports the count of kernel NFS server TCP segments and UDP datagrams handled
Instrument: counter
Unit: {record}
Note: Linux: this metric is taken from the Linux kernel's svc_stat.nettcpcnt and svc_stat.netudpcnt.
"""
def create_nfs_server_net_count(meter: Meter) -> Counter:
"""Reports the count of kernel NFS server TCP segments and UDP datagrams handled"""
return meter.create_counter(
name=NFS_SERVER_NET_COUNT,
description="Reports the count of kernel NFS server TCP segments and UDP datagrams handled.",
unit="{record}",
)
NFS_SERVER_NET_TCP_CONNECTION_ACCEPTED: Final = (
"nfs.server.net.tcp.connection.accepted"
)
"""
Reports the count of kernel NFS server TCP connections accepted
Instrument: counter
Unit: {connection}
Note: Linux: this metric is taken from the Linux kernel's svc_stat.nettcpconn.
"""
def create_nfs_server_net_tcp_connection_accepted(meter: Meter) -> Counter:
"""Reports the count of kernel NFS server TCP connections accepted"""
return meter.create_counter(
name=NFS_SERVER_NET_TCP_CONNECTION_ACCEPTED,
description="Reports the count of kernel NFS server TCP connections accepted.",
unit="{connection}",
)
NFS_SERVER_OPERATION_COUNT: Final = "nfs.server.operation.count"
"""
Reports the count of kernel NFSv4+ server operations
Instrument: counter
Unit: {operation}
"""
def create_nfs_server_operation_count(meter: Meter) -> Counter:
"""Reports the count of kernel NFSv4+ server operations"""
return meter.create_counter(
name=NFS_SERVER_OPERATION_COUNT,
description="Reports the count of kernel NFSv4+ server operations.",
unit="{operation}",
)
NFS_SERVER_PROCEDURE_COUNT: Final = "nfs.server.procedure.count"
"""
Reports the count of kernel NFS server procedures
Instrument: counter
Unit: {procedure}
"""
def create_nfs_server_procedure_count(meter: Meter) -> Counter:
"""Reports the count of kernel NFS server procedures"""
return meter.create_counter(
name=NFS_SERVER_PROCEDURE_COUNT,
description="Reports the count of kernel NFS server procedures.",
unit="{procedure}",
)
NFS_SERVER_REPCACHE_REQUESTS: Final = "nfs.server.repcache.requests"
"""
Reports the kernel NFS server reply cache request count by cache hit status
Instrument: counter
Unit: {request}
"""
def create_nfs_server_repcache_requests(meter: Meter) -> Counter:
"""Reports the kernel NFS server reply cache request count by cache hit status"""
return meter.create_counter(
name=NFS_SERVER_REPCACHE_REQUESTS,
description="Reports the kernel NFS server reply cache request count by cache hit status.",
unit="{request}",
)
NFS_SERVER_RPC_COUNT: Final = "nfs.server.rpc.count"
"""
Reports the count of kernel NFS server RPCs handled
Instrument: counter
Unit: {request}
Note: Linux: this metric is taken from the Linux kernel's svc_stat.rpccnt, the count of good RPCs. This metric can have
an error.type of "format", "auth", or "client" for svc_stat.badfmt, svc_stat.badauth, and svc_stat.badclnt.
"""
def create_nfs_server_rpc_count(meter: Meter) -> Counter:
"""Reports the count of kernel NFS server RPCs handled"""
return meter.create_counter(
name=NFS_SERVER_RPC_COUNT,
description="Reports the count of kernel NFS server RPCs handled.",
unit="{request}",
)
NFS_SERVER_THREAD_COUNT: Final = "nfs.server.thread.count"
"""
Reports the count of kernel NFS server available threads
Instrument: updowncounter
Unit: {thread}
Note: Linux: this metric is taken from the Linux kernel nfsd_th_cnt variable.
"""
def create_nfs_server_thread_count(meter: Meter) -> UpDownCounter:
"""Reports the count of kernel NFS server available threads"""
return meter.create_up_down_counter(
name=NFS_SERVER_THREAD_COUNT,
description="Reports the count of kernel NFS server available threads.",
unit="{thread}",
)

View File

@@ -0,0 +1,529 @@
# Copyright The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Final
from opentelemetry.metrics import Meter, UpDownCounter
OPENSHIFT_CLUSTERQUOTA_CPU_LIMIT_HARD: Final = (
"openshift.clusterquota.cpu.limit.hard"
)
"""
The enforced hard limit of the resource across all projects
Instrument: updowncounter
Unit: {cpu}
Note: This metric is retrieved from the `Status.Total.Hard` field of the
[K8s ResourceQuotaStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core)
of the
[ClusterResourceQuota](https://docs.redhat.com/en/documentation/openshift_container_platform/4.19/html/schedule_and_quota_apis/clusterresourcequota-quota-openshift-io-v1#status-total).
"""
def create_openshift_clusterquota_cpu_limit_hard(
meter: Meter,
) -> UpDownCounter:
"""The enforced hard limit of the resource across all projects"""
return meter.create_up_down_counter(
name=OPENSHIFT_CLUSTERQUOTA_CPU_LIMIT_HARD,
description="The enforced hard limit of the resource across all projects.",
unit="{cpu}",
)
OPENSHIFT_CLUSTERQUOTA_CPU_LIMIT_USED: Final = (
"openshift.clusterquota.cpu.limit.used"
)
"""
The current observed total usage of the resource across all projects
Instrument: updowncounter
Unit: {cpu}
Note: This metric is retrieved from the `Status.Total.Used` field of the
[K8s ResourceQuotaStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core)
of the
[ClusterResourceQuota](https://docs.redhat.com/en/documentation/openshift_container_platform/4.19/html/schedule_and_quota_apis/clusterresourcequota-quota-openshift-io-v1#status-total).
"""
def create_openshift_clusterquota_cpu_limit_used(
meter: Meter,
) -> UpDownCounter:
"""The current observed total usage of the resource across all projects"""
return meter.create_up_down_counter(
name=OPENSHIFT_CLUSTERQUOTA_CPU_LIMIT_USED,
description="The current observed total usage of the resource across all projects.",
unit="{cpu}",
)
OPENSHIFT_CLUSTERQUOTA_CPU_REQUEST_HARD: Final = (
"openshift.clusterquota.cpu.request.hard"
)
"""
The enforced hard limit of the resource across all projects
Instrument: updowncounter
Unit: {cpu}
Note: This metric is retrieved from the `Status.Total.Hard` field of the
[K8s ResourceQuotaStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core)
of the
[ClusterResourceQuota](https://docs.redhat.com/en/documentation/openshift_container_platform/4.19/html/schedule_and_quota_apis/clusterresourcequota-quota-openshift-io-v1#status-total).
"""
def create_openshift_clusterquota_cpu_request_hard(
meter: Meter,
) -> UpDownCounter:
"""The enforced hard limit of the resource across all projects"""
return meter.create_up_down_counter(
name=OPENSHIFT_CLUSTERQUOTA_CPU_REQUEST_HARD,
description="The enforced hard limit of the resource across all projects.",
unit="{cpu}",
)
OPENSHIFT_CLUSTERQUOTA_CPU_REQUEST_USED: Final = (
"openshift.clusterquota.cpu.request.used"
)
"""
The current observed total usage of the resource across all projects
Instrument: updowncounter
Unit: {cpu}
Note: This metric is retrieved from the `Status.Total.Used` field of the
[K8s ResourceQuotaStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core)
of the
[ClusterResourceQuota](https://docs.redhat.com/en/documentation/openshift_container_platform/4.19/html/schedule_and_quota_apis/clusterresourcequota-quota-openshift-io-v1#status-total).
"""
def create_openshift_clusterquota_cpu_request_used(
meter: Meter,
) -> UpDownCounter:
"""The current observed total usage of the resource across all projects"""
return meter.create_up_down_counter(
name=OPENSHIFT_CLUSTERQUOTA_CPU_REQUEST_USED,
description="The current observed total usage of the resource across all projects.",
unit="{cpu}",
)
OPENSHIFT_CLUSTERQUOTA_EPHEMERAL_STORAGE_LIMIT_HARD: Final = (
"openshift.clusterquota.ephemeral_storage.limit.hard"
)
"""
The enforced hard limit of the resource across all projects
Instrument: updowncounter
Unit: By
Note: This metric is retrieved from the `Status.Total.Hard` field of the
[K8s ResourceQuotaStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core)
of the
[ClusterResourceQuota](https://docs.redhat.com/en/documentation/openshift_container_platform/4.19/html/schedule_and_quota_apis/clusterresourcequota-quota-openshift-io-v1#status-total).
"""
def create_openshift_clusterquota_ephemeral_storage_limit_hard(
meter: Meter,
) -> UpDownCounter:
"""The enforced hard limit of the resource across all projects"""
return meter.create_up_down_counter(
name=OPENSHIFT_CLUSTERQUOTA_EPHEMERAL_STORAGE_LIMIT_HARD,
description="The enforced hard limit of the resource across all projects.",
unit="By",
)
OPENSHIFT_CLUSTERQUOTA_EPHEMERAL_STORAGE_LIMIT_USED: Final = (
"openshift.clusterquota.ephemeral_storage.limit.used"
)
"""
The current observed total usage of the resource across all projects
Instrument: updowncounter
Unit: By
Note: This metric is retrieved from the `Status.Total.Used` field of the
[K8s ResourceQuotaStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core)
of the
[ClusterResourceQuota](https://docs.redhat.com/en/documentation/openshift_container_platform/4.19/html/schedule_and_quota_apis/clusterresourcequota-quota-openshift-io-v1#status-total).
"""
def create_openshift_clusterquota_ephemeral_storage_limit_used(
meter: Meter,
) -> UpDownCounter:
"""The current observed total usage of the resource across all projects"""
return meter.create_up_down_counter(
name=OPENSHIFT_CLUSTERQUOTA_EPHEMERAL_STORAGE_LIMIT_USED,
description="The current observed total usage of the resource across all projects.",
unit="By",
)
OPENSHIFT_CLUSTERQUOTA_EPHEMERAL_STORAGE_REQUEST_HARD: Final = (
"openshift.clusterquota.ephemeral_storage.request.hard"
)
"""
The enforced hard limit of the resource across all projects
Instrument: updowncounter
Unit: By
Note: This metric is retrieved from the `Status.Total.Hard` field of the
[K8s ResourceQuotaStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core)
of the
[ClusterResourceQuota](https://docs.redhat.com/en/documentation/openshift_container_platform/4.19/html/schedule_and_quota_apis/clusterresourcequota-quota-openshift-io-v1#status-total).
"""
def create_openshift_clusterquota_ephemeral_storage_request_hard(
meter: Meter,
) -> UpDownCounter:
"""The enforced hard limit of the resource across all projects"""
return meter.create_up_down_counter(
name=OPENSHIFT_CLUSTERQUOTA_EPHEMERAL_STORAGE_REQUEST_HARD,
description="The enforced hard limit of the resource across all projects.",
unit="By",
)
OPENSHIFT_CLUSTERQUOTA_EPHEMERAL_STORAGE_REQUEST_USED: Final = (
"openshift.clusterquota.ephemeral_storage.request.used"
)
"""
The current observed total usage of the resource across all projects
Instrument: updowncounter
Unit: By
Note: This metric is retrieved from the `Status.Total.Used` field of the
[K8s ResourceQuotaStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core)
of the
[ClusterResourceQuota](https://docs.redhat.com/en/documentation/openshift_container_platform/4.19/html/schedule_and_quota_apis/clusterresourcequota-quota-openshift-io-v1#status-total).
"""
def create_openshift_clusterquota_ephemeral_storage_request_used(
meter: Meter,
) -> UpDownCounter:
"""The current observed total usage of the resource across all projects"""
return meter.create_up_down_counter(
name=OPENSHIFT_CLUSTERQUOTA_EPHEMERAL_STORAGE_REQUEST_USED,
description="The current observed total usage of the resource across all projects.",
unit="By",
)
OPENSHIFT_CLUSTERQUOTA_HUGEPAGE_COUNT_REQUEST_HARD: Final = (
"openshift.clusterquota.hugepage_count.request.hard"
)
"""
The enforced hard limit of the resource across all projects
Instrument: updowncounter
Unit: {hugepage}
Note: This metric is retrieved from the `Status.Total.Hard` field of the
[K8s ResourceQuotaStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core)
of the
[ClusterResourceQuota](https://docs.redhat.com/en/documentation/openshift_container_platform/4.19/html/schedule_and_quota_apis/clusterresourcequota-quota-openshift-io-v1#status-total).
"""
def create_openshift_clusterquota_hugepage_count_request_hard(
meter: Meter,
) -> UpDownCounter:
"""The enforced hard limit of the resource across all projects"""
return meter.create_up_down_counter(
name=OPENSHIFT_CLUSTERQUOTA_HUGEPAGE_COUNT_REQUEST_HARD,
description="The enforced hard limit of the resource across all projects.",
unit="{hugepage}",
)
OPENSHIFT_CLUSTERQUOTA_HUGEPAGE_COUNT_REQUEST_USED: Final = (
"openshift.clusterquota.hugepage_count.request.used"
)
"""
The current observed total usage of the resource across all projects
Instrument: updowncounter
Unit: {hugepage}
Note: This metric is retrieved from the `Status.Total.Used` field of the
[K8s ResourceQuotaStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core)
of the
[ClusterResourceQuota](https://docs.redhat.com/en/documentation/openshift_container_platform/4.19/html/schedule_and_quota_apis/clusterresourcequota-quota-openshift-io-v1#status-total).
"""
def create_openshift_clusterquota_hugepage_count_request_used(
meter: Meter,
) -> UpDownCounter:
"""The current observed total usage of the resource across all projects"""
return meter.create_up_down_counter(
name=OPENSHIFT_CLUSTERQUOTA_HUGEPAGE_COUNT_REQUEST_USED,
description="The current observed total usage of the resource across all projects.",
unit="{hugepage}",
)
OPENSHIFT_CLUSTERQUOTA_MEMORY_LIMIT_HARD: Final = (
"openshift.clusterquota.memory.limit.hard"
)
"""
The enforced hard limit of the resource across all projects
Instrument: updowncounter
Unit: By
Note: This metric is retrieved from the `Status.Total.Hard` field of the
[K8s ResourceQuotaStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core)
of the
[ClusterResourceQuota](https://docs.redhat.com/en/documentation/openshift_container_platform/4.19/html/schedule_and_quota_apis/clusterresourcequota-quota-openshift-io-v1#status-total).
"""
def create_openshift_clusterquota_memory_limit_hard(
meter: Meter,
) -> UpDownCounter:
"""The enforced hard limit of the resource across all projects"""
return meter.create_up_down_counter(
name=OPENSHIFT_CLUSTERQUOTA_MEMORY_LIMIT_HARD,
description="The enforced hard limit of the resource across all projects.",
unit="By",
)
OPENSHIFT_CLUSTERQUOTA_MEMORY_LIMIT_USED: Final = (
"openshift.clusterquota.memory.limit.used"
)
"""
The current observed total usage of the resource across all projects
Instrument: updowncounter
Unit: By
Note: This metric is retrieved from the `Status.Total.Used` field of the
[K8s ResourceQuotaStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core)
of the
[ClusterResourceQuota](https://docs.redhat.com/en/documentation/openshift_container_platform/4.19/html/schedule_and_quota_apis/clusterresourcequota-quota-openshift-io-v1#status-total).
"""
def create_openshift_clusterquota_memory_limit_used(
meter: Meter,
) -> UpDownCounter:
"""The current observed total usage of the resource across all projects"""
return meter.create_up_down_counter(
name=OPENSHIFT_CLUSTERQUOTA_MEMORY_LIMIT_USED,
description="The current observed total usage of the resource across all projects.",
unit="By",
)
OPENSHIFT_CLUSTERQUOTA_MEMORY_REQUEST_HARD: Final = (
"openshift.clusterquota.memory.request.hard"
)
"""
The enforced hard limit of the resource across all projects
Instrument: updowncounter
Unit: By
Note: This metric is retrieved from the `Status.Total.Hard` field of the
[K8s ResourceQuotaStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core)
of the
[ClusterResourceQuota](https://docs.redhat.com/en/documentation/openshift_container_platform/4.19/html/schedule_and_quota_apis/clusterresourcequota-quota-openshift-io-v1#status-total).
"""
def create_openshift_clusterquota_memory_request_hard(
meter: Meter,
) -> UpDownCounter:
"""The enforced hard limit of the resource across all projects"""
return meter.create_up_down_counter(
name=OPENSHIFT_CLUSTERQUOTA_MEMORY_REQUEST_HARD,
description="The enforced hard limit of the resource across all projects.",
unit="By",
)
OPENSHIFT_CLUSTERQUOTA_MEMORY_REQUEST_USED: Final = (
"openshift.clusterquota.memory.request.used"
)
"""
The current observed total usage of the resource across all projects
Instrument: updowncounter
Unit: By
Note: This metric is retrieved from the `Status.Total.Used` field of the
[K8s ResourceQuotaStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core)
of the
[ClusterResourceQuota](https://docs.redhat.com/en/documentation/openshift_container_platform/4.19/html/schedule_and_quota_apis/clusterresourcequota-quota-openshift-io-v1#status-total).
"""
def create_openshift_clusterquota_memory_request_used(
meter: Meter,
) -> UpDownCounter:
"""The current observed total usage of the resource across all projects"""
return meter.create_up_down_counter(
name=OPENSHIFT_CLUSTERQUOTA_MEMORY_REQUEST_USED,
description="The current observed total usage of the resource across all projects.",
unit="By",
)
OPENSHIFT_CLUSTERQUOTA_OBJECT_COUNT_HARD: Final = (
"openshift.clusterquota.object_count.hard"
)
"""
The enforced hard limit of the resource across all projects
Instrument: updowncounter
Unit: {object}
Note: This metric is retrieved from the `Status.Total.Hard` field of the
[K8s ResourceQuotaStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core)
of the
[ClusterResourceQuota](https://docs.redhat.com/en/documentation/openshift_container_platform/4.19/html/schedule_and_quota_apis/clusterresourcequota-quota-openshift-io-v1#status-total).
"""
def create_openshift_clusterquota_object_count_hard(
meter: Meter,
) -> UpDownCounter:
"""The enforced hard limit of the resource across all projects"""
return meter.create_up_down_counter(
name=OPENSHIFT_CLUSTERQUOTA_OBJECT_COUNT_HARD,
description="The enforced hard limit of the resource across all projects.",
unit="{object}",
)
OPENSHIFT_CLUSTERQUOTA_OBJECT_COUNT_USED: Final = (
"openshift.clusterquota.object_count.used"
)
"""
The current observed total usage of the resource across all projects
Instrument: updowncounter
Unit: {object}
Note: This metric is retrieved from the `Status.Total.Used` field of the
[K8s ResourceQuotaStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core)
of the
[ClusterResourceQuota](https://docs.redhat.com/en/documentation/openshift_container_platform/4.19/html/schedule_and_quota_apis/clusterresourcequota-quota-openshift-io-v1#status-total).
"""
def create_openshift_clusterquota_object_count_used(
meter: Meter,
) -> UpDownCounter:
"""The current observed total usage of the resource across all projects"""
return meter.create_up_down_counter(
name=OPENSHIFT_CLUSTERQUOTA_OBJECT_COUNT_USED,
description="The current observed total usage of the resource across all projects.",
unit="{object}",
)
OPENSHIFT_CLUSTERQUOTA_PERSISTENTVOLUMECLAIM_COUNT_HARD: Final = (
"openshift.clusterquota.persistentvolumeclaim_count.hard"
)
"""
The enforced hard limit of the resource across all projects
Instrument: updowncounter
Unit: {persistentvolumeclaim}
Note: This metric is retrieved from the `Status.Total.Hard` field of the
[K8s ResourceQuotaStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core)
of the
[ClusterResourceQuota](https://docs.redhat.com/en/documentation/openshift_container_platform/4.19/html/schedule_and_quota_apis/clusterresourcequota-quota-openshift-io-v1#status-total).
The `k8s.storageclass.name` should be required when a resource quota is defined for a specific
storage class.
"""
def create_openshift_clusterquota_persistentvolumeclaim_count_hard(
meter: Meter,
) -> UpDownCounter:
"""The enforced hard limit of the resource across all projects"""
return meter.create_up_down_counter(
name=OPENSHIFT_CLUSTERQUOTA_PERSISTENTVOLUMECLAIM_COUNT_HARD,
description="The enforced hard limit of the resource across all projects.",
unit="{persistentvolumeclaim}",
)
OPENSHIFT_CLUSTERQUOTA_PERSISTENTVOLUMECLAIM_COUNT_USED: Final = (
"openshift.clusterquota.persistentvolumeclaim_count.used"
)
"""
The current observed total usage of the resource across all projects
Instrument: updowncounter
Unit: {persistentvolumeclaim}
Note: This metric is retrieved from the `Status.Total.Used` field of the
[K8s ResourceQuotaStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core)
of the
[ClusterResourceQuota](https://docs.redhat.com/en/documentation/openshift_container_platform/4.19/html/schedule_and_quota_apis/clusterresourcequota-quota-openshift-io-v1#status-total).
The `k8s.storageclass.name` should be required when a resource quota is defined for a specific
storage class.
"""
def create_openshift_clusterquota_persistentvolumeclaim_count_used(
meter: Meter,
) -> UpDownCounter:
"""The current observed total usage of the resource across all projects"""
return meter.create_up_down_counter(
name=OPENSHIFT_CLUSTERQUOTA_PERSISTENTVOLUMECLAIM_COUNT_USED,
description="The current observed total usage of the resource across all projects.",
unit="{persistentvolumeclaim}",
)
OPENSHIFT_CLUSTERQUOTA_STORAGE_REQUEST_HARD: Final = (
"openshift.clusterquota.storage.request.hard"
)
"""
The enforced hard limit of the resource across all projects
Instrument: updowncounter
Unit: By
Note: This metric is retrieved from the `Status.Total.Hard` field of the
[K8s ResourceQuotaStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core)
of the
[ClusterResourceQuota](https://docs.redhat.com/en/documentation/openshift_container_platform/4.19/html/schedule_and_quota_apis/clusterresourcequota-quota-openshift-io-v1#status-total).
The `k8s.storageclass.name` should be required when a resource quota is defined for a specific
storage class.
"""
def create_openshift_clusterquota_storage_request_hard(
meter: Meter,
) -> UpDownCounter:
"""The enforced hard limit of the resource across all projects"""
return meter.create_up_down_counter(
name=OPENSHIFT_CLUSTERQUOTA_STORAGE_REQUEST_HARD,
description="The enforced hard limit of the resource across all projects.",
unit="By",
)
OPENSHIFT_CLUSTERQUOTA_STORAGE_REQUEST_USED: Final = (
"openshift.clusterquota.storage.request.used"
)
"""
The current observed total usage of the resource across all projects
Instrument: updowncounter
Unit: By
Note: This metric is retrieved from the `Status.Total.Used` field of the
[K8s ResourceQuotaStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#resourcequotastatus-v1-core)
of the
[ClusterResourceQuota](https://docs.redhat.com/en/documentation/openshift_container_platform/4.19/html/schedule_and_quota_apis/clusterresourcequota-quota-openshift-io-v1#status-total).
The `k8s.storageclass.name` should be required when a resource quota is defined for a specific
storage class.
"""
def create_openshift_clusterquota_storage_request_used(
meter: Meter,
) -> UpDownCounter:
"""The current observed total usage of the resource across all projects"""
return meter.create_up_down_counter(
name=OPENSHIFT_CLUSTERQUOTA_STORAGE_REQUEST_USED,
description="The current observed total usage of the resource across all projects.",
unit="By",
)

View File

@@ -0,0 +1,459 @@
# Copyright The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Final
from opentelemetry.metrics import Counter, Histogram, Meter, UpDownCounter
OTEL_SDK_EXPORTER_LOG_EXPORTED: Final = "otel.sdk.exporter.log.exported"
"""
The number of log records for which the export has finished, either successful or failed
Instrument: counter
Unit: {log_record}
Note: For successful exports, `error.type` MUST NOT be set. For failed exports, `error.type` MUST contain the failure cause.
For exporters with partial success semantics (e.g. OTLP with `rejected_log_records`), rejected log records MUST count as failed and only non-rejected log records count as success.
If no rejection reason is available, `rejected` SHOULD be used as value for `error.type`.
"""
def create_otel_sdk_exporter_log_exported(meter: Meter) -> Counter:
"""The number of log records for which the export has finished, either successful or failed"""
return meter.create_counter(
name=OTEL_SDK_EXPORTER_LOG_EXPORTED,
description="The number of log records for which the export has finished, either successful or failed.",
unit="{log_record}",
)
OTEL_SDK_EXPORTER_LOG_INFLIGHT: Final = "otel.sdk.exporter.log.inflight"
"""
The number of log records which were passed to the exporter, but that have not been exported yet (neither successful, nor failed)
Instrument: updowncounter
Unit: {log_record}
Note: For successful exports, `error.type` MUST NOT be set. For failed exports, `error.type` MUST contain the failure cause.
"""
def create_otel_sdk_exporter_log_inflight(meter: Meter) -> UpDownCounter:
"""The number of log records which were passed to the exporter, but that have not been exported yet (neither successful, nor failed)"""
return meter.create_up_down_counter(
name=OTEL_SDK_EXPORTER_LOG_INFLIGHT,
description="The number of log records which were passed to the exporter, but that have not been exported yet (neither successful, nor failed).",
unit="{log_record}",
)
OTEL_SDK_EXPORTER_METRIC_DATA_POINT_EXPORTED: Final = (
"otel.sdk.exporter.metric_data_point.exported"
)
"""
The number of metric data points for which the export has finished, either successful or failed
Instrument: counter
Unit: {data_point}
Note: For successful exports, `error.type` MUST NOT be set. For failed exports, `error.type` MUST contain the failure cause.
For exporters with partial success semantics (e.g. OTLP with `rejected_data_points`), rejected data points MUST count as failed and only non-rejected data points count as success.
If no rejection reason is available, `rejected` SHOULD be used as value for `error.type`.
"""
def create_otel_sdk_exporter_metric_data_point_exported(
meter: Meter,
) -> Counter:
"""The number of metric data points for which the export has finished, either successful or failed"""
return meter.create_counter(
name=OTEL_SDK_EXPORTER_METRIC_DATA_POINT_EXPORTED,
description="The number of metric data points for which the export has finished, either successful or failed.",
unit="{data_point}",
)
OTEL_SDK_EXPORTER_METRIC_DATA_POINT_INFLIGHT: Final = (
"otel.sdk.exporter.metric_data_point.inflight"
)
"""
The number of metric data points which were passed to the exporter, but that have not been exported yet (neither successful, nor failed)
Instrument: updowncounter
Unit: {data_point}
Note: For successful exports, `error.type` MUST NOT be set. For failed exports, `error.type` MUST contain the failure cause.
"""
def create_otel_sdk_exporter_metric_data_point_inflight(
meter: Meter,
) -> UpDownCounter:
"""The number of metric data points which were passed to the exporter, but that have not been exported yet (neither successful, nor failed)"""
return meter.create_up_down_counter(
name=OTEL_SDK_EXPORTER_METRIC_DATA_POINT_INFLIGHT,
description="The number of metric data points which were passed to the exporter, but that have not been exported yet (neither successful, nor failed).",
unit="{data_point}",
)
OTEL_SDK_EXPORTER_OPERATION_DURATION: Final = (
"otel.sdk.exporter.operation.duration"
)
"""
The duration of exporting a batch of telemetry records
Instrument: histogram
Unit: s
Note: This metric defines successful operations using the full success definitions for [http](https://github.com/open-telemetry/opentelemetry-proto/blob/v1.5.0/docs/specification.md#full-success-1)
and [grpc](https://github.com/open-telemetry/opentelemetry-proto/blob/v1.5.0/docs/specification.md#full-success). Anything else is defined as an unsuccessful operation. For successful
operations, `error.type` MUST NOT be set. For unsuccessful export operations, `error.type` MUST contain a relevant failure cause.
"""
def create_otel_sdk_exporter_operation_duration(meter: Meter) -> Histogram:
"""The duration of exporting a batch of telemetry records"""
return meter.create_histogram(
name=OTEL_SDK_EXPORTER_OPERATION_DURATION,
description="The duration of exporting a batch of telemetry records.",
unit="s",
)
OTEL_SDK_EXPORTER_SPAN_EXPORTED: Final = "otel.sdk.exporter.span.exported"
"""
The number of spans for which the export has finished, either successful or failed
Instrument: counter
Unit: {span}
Note: For successful exports, `error.type` MUST NOT be set. For failed exports, `error.type` MUST contain the failure cause.
For exporters with partial success semantics (e.g. OTLP with `rejected_spans`), rejected spans MUST count as failed and only non-rejected spans count as success.
If no rejection reason is available, `rejected` SHOULD be used as value for `error.type`.
"""
def create_otel_sdk_exporter_span_exported(meter: Meter) -> Counter:
"""The number of spans for which the export has finished, either successful or failed"""
return meter.create_counter(
name=OTEL_SDK_EXPORTER_SPAN_EXPORTED,
description="The number of spans for which the export has finished, either successful or failed.",
unit="{span}",
)
OTEL_SDK_EXPORTER_SPAN_EXPORTED_COUNT: Final = (
"otel.sdk.exporter.span.exported.count"
)
"""
Deprecated: Replaced by `otel.sdk.exporter.span.exported`.
"""
def create_otel_sdk_exporter_span_exported_count(
meter: Meter,
) -> UpDownCounter:
"""Deprecated, use `otel.sdk.exporter.span.exported` instead"""
return meter.create_up_down_counter(
name=OTEL_SDK_EXPORTER_SPAN_EXPORTED_COUNT,
description="Deprecated, use `otel.sdk.exporter.span.exported` instead.",
unit="{span}",
)
OTEL_SDK_EXPORTER_SPAN_INFLIGHT: Final = "otel.sdk.exporter.span.inflight"
"""
The number of spans which were passed to the exporter, but that have not been exported yet (neither successful, nor failed)
Instrument: updowncounter
Unit: {span}
Note: For successful exports, `error.type` MUST NOT be set. For failed exports, `error.type` MUST contain the failure cause.
"""
def create_otel_sdk_exporter_span_inflight(meter: Meter) -> UpDownCounter:
"""The number of spans which were passed to the exporter, but that have not been exported yet (neither successful, nor failed)"""
return meter.create_up_down_counter(
name=OTEL_SDK_EXPORTER_SPAN_INFLIGHT,
description="The number of spans which were passed to the exporter, but that have not been exported yet (neither successful, nor failed).",
unit="{span}",
)
OTEL_SDK_EXPORTER_SPAN_INFLIGHT_COUNT: Final = (
"otel.sdk.exporter.span.inflight.count"
)
"""
Deprecated: Replaced by `otel.sdk.exporter.span.inflight`.
"""
def create_otel_sdk_exporter_span_inflight_count(
meter: Meter,
) -> UpDownCounter:
"""Deprecated, use `otel.sdk.exporter.span.inflight` instead"""
return meter.create_up_down_counter(
name=OTEL_SDK_EXPORTER_SPAN_INFLIGHT_COUNT,
description="Deprecated, use `otel.sdk.exporter.span.inflight` instead.",
unit="{span}",
)
OTEL_SDK_LOG_CREATED: Final = "otel.sdk.log.created"
"""
The number of logs submitted to enabled SDK Loggers
Instrument: counter
Unit: {log_record}
"""
def create_otel_sdk_log_created(meter: Meter) -> Counter:
"""The number of logs submitted to enabled SDK Loggers"""
return meter.create_counter(
name=OTEL_SDK_LOG_CREATED,
description="The number of logs submitted to enabled SDK Loggers.",
unit="{log_record}",
)
OTEL_SDK_METRIC_READER_COLLECTION_DURATION: Final = (
"otel.sdk.metric_reader.collection.duration"
)
"""
The duration of the collect operation of the metric reader
Instrument: histogram
Unit: s
Note: For successful collections, `error.type` MUST NOT be set. For failed collections, `error.type` SHOULD contain the failure cause.
It can happen that metrics collection is successful for some MetricProducers, while others fail. In that case `error.type` SHOULD be set to any of the failure causes.
"""
def create_otel_sdk_metric_reader_collection_duration(
meter: Meter,
) -> Histogram:
"""The duration of the collect operation of the metric reader"""
return meter.create_histogram(
name=OTEL_SDK_METRIC_READER_COLLECTION_DURATION,
description="The duration of the collect operation of the metric reader.",
unit="s",
)
OTEL_SDK_PROCESSOR_LOG_PROCESSED: Final = "otel.sdk.processor.log.processed"
"""
The number of log records for which the processing has finished, either successful or failed
Instrument: counter
Unit: {log_record}
Note: For successful processing, `error.type` MUST NOT be set. For failed processing, `error.type` MUST contain the failure cause.
For the SDK Simple and Batching Log Record Processor a log record is considered to be processed already when it has been submitted to the exporter,
not when the corresponding export call has finished.
"""
def create_otel_sdk_processor_log_processed(meter: Meter) -> Counter:
"""The number of log records for which the processing has finished, either successful or failed"""
return meter.create_counter(
name=OTEL_SDK_PROCESSOR_LOG_PROCESSED,
description="The number of log records for which the processing has finished, either successful or failed.",
unit="{log_record}",
)
OTEL_SDK_PROCESSOR_LOG_QUEUE_CAPACITY: Final = (
"otel.sdk.processor.log.queue.capacity"
)
"""
The maximum number of log records the queue of a given instance of an SDK Log Record processor can hold
Instrument: updowncounter
Unit: {log_record}
Note: Only applies to Log Record processors which use a queue, e.g. the SDK Batching Log Record Processor.
"""
def create_otel_sdk_processor_log_queue_capacity(
meter: Meter,
) -> UpDownCounter:
"""The maximum number of log records the queue of a given instance of an SDK Log Record processor can hold"""
return meter.create_up_down_counter(
name=OTEL_SDK_PROCESSOR_LOG_QUEUE_CAPACITY,
description="The maximum number of log records the queue of a given instance of an SDK Log Record processor can hold.",
unit="{log_record}",
)
OTEL_SDK_PROCESSOR_LOG_QUEUE_SIZE: Final = "otel.sdk.processor.log.queue.size"
"""
The number of log records in the queue of a given instance of an SDK log processor
Instrument: updowncounter
Unit: {log_record}
Note: Only applies to log record processors which use a queue, e.g. the SDK Batching Log Record Processor.
"""
def create_otel_sdk_processor_log_queue_size(meter: Meter) -> UpDownCounter:
"""The number of log records in the queue of a given instance of an SDK log processor"""
return meter.create_up_down_counter(
name=OTEL_SDK_PROCESSOR_LOG_QUEUE_SIZE,
description="The number of log records in the queue of a given instance of an SDK log processor.",
unit="{log_record}",
)
OTEL_SDK_PROCESSOR_SPAN_PROCESSED: Final = "otel.sdk.processor.span.processed"
"""
The number of spans for which the processing has finished, either successful or failed
Instrument: counter
Unit: {span}
Note: For successful processing, `error.type` MUST NOT be set. For failed processing, `error.type` MUST contain the failure cause.
For the SDK Simple and Batching Span Processor a span is considered to be processed already when it has been submitted to the exporter, not when the corresponding export call has finished.
"""
def create_otel_sdk_processor_span_processed(meter: Meter) -> Counter:
"""The number of spans for which the processing has finished, either successful or failed"""
return meter.create_counter(
name=OTEL_SDK_PROCESSOR_SPAN_PROCESSED,
description="The number of spans for which the processing has finished, either successful or failed.",
unit="{span}",
)
OTEL_SDK_PROCESSOR_SPAN_PROCESSED_COUNT: Final = (
"otel.sdk.processor.span.processed.count"
)
"""
Deprecated: Replaced by `otel.sdk.processor.span.processed`.
"""
def create_otel_sdk_processor_span_processed_count(
meter: Meter,
) -> UpDownCounter:
"""Deprecated, use `otel.sdk.processor.span.processed` instead"""
return meter.create_up_down_counter(
name=OTEL_SDK_PROCESSOR_SPAN_PROCESSED_COUNT,
description="Deprecated, use `otel.sdk.processor.span.processed` instead.",
unit="{span}",
)
OTEL_SDK_PROCESSOR_SPAN_QUEUE_CAPACITY: Final = (
"otel.sdk.processor.span.queue.capacity"
)
"""
The maximum number of spans the queue of a given instance of an SDK span processor can hold
Instrument: updowncounter
Unit: {span}
Note: Only applies to span processors which use a queue, e.g. the SDK Batching Span Processor.
"""
def create_otel_sdk_processor_span_queue_capacity(
meter: Meter,
) -> UpDownCounter:
"""The maximum number of spans the queue of a given instance of an SDK span processor can hold"""
return meter.create_up_down_counter(
name=OTEL_SDK_PROCESSOR_SPAN_QUEUE_CAPACITY,
description="The maximum number of spans the queue of a given instance of an SDK span processor can hold.",
unit="{span}",
)
OTEL_SDK_PROCESSOR_SPAN_QUEUE_SIZE: Final = (
"otel.sdk.processor.span.queue.size"
)
"""
The number of spans in the queue of a given instance of an SDK span processor
Instrument: updowncounter
Unit: {span}
Note: Only applies to span processors which use a queue, e.g. the SDK Batching Span Processor.
"""
def create_otel_sdk_processor_span_queue_size(meter: Meter) -> UpDownCounter:
"""The number of spans in the queue of a given instance of an SDK span processor"""
return meter.create_up_down_counter(
name=OTEL_SDK_PROCESSOR_SPAN_QUEUE_SIZE,
description="The number of spans in the queue of a given instance of an SDK span processor.",
unit="{span}",
)
OTEL_SDK_SPAN_ENDED: Final = "otel.sdk.span.ended"
"""
Deprecated: Obsoleted.
"""
def create_otel_sdk_span_ended(meter: Meter) -> Counter:
"""Use `otel.sdk.span.started` minus `otel.sdk.span.live` to derive this value"""
return meter.create_counter(
name=OTEL_SDK_SPAN_ENDED,
description="Use `otel.sdk.span.started` minus `otel.sdk.span.live` to derive this value.",
unit="{span}",
)
OTEL_SDK_SPAN_ENDED_COUNT: Final = "otel.sdk.span.ended.count"
"""
Deprecated: Obsoleted.
"""
def create_otel_sdk_span_ended_count(meter: Meter) -> Counter:
"""Use `otel.sdk.span.started` minus `otel.sdk.span.live` to derive this value"""
return meter.create_counter(
name=OTEL_SDK_SPAN_ENDED_COUNT,
description="Use `otel.sdk.span.started` minus `otel.sdk.span.live` to derive this value.",
unit="{span}",
)
OTEL_SDK_SPAN_LIVE: Final = "otel.sdk.span.live"
"""
The number of created spans with `recording=true` for which the end operation has not been called yet
Instrument: updowncounter
Unit: {span}
"""
def create_otel_sdk_span_live(meter: Meter) -> UpDownCounter:
"""The number of created spans with `recording=true` for which the end operation has not been called yet"""
return meter.create_up_down_counter(
name=OTEL_SDK_SPAN_LIVE,
description="The number of created spans with `recording=true` for which the end operation has not been called yet.",
unit="{span}",
)
OTEL_SDK_SPAN_LIVE_COUNT: Final = "otel.sdk.span.live.count"
"""
Deprecated: Replaced by `otel.sdk.span.live`.
"""
def create_otel_sdk_span_live_count(meter: Meter) -> UpDownCounter:
"""Deprecated, use `otel.sdk.span.live` instead"""
return meter.create_up_down_counter(
name=OTEL_SDK_SPAN_LIVE_COUNT,
description="Deprecated, use `otel.sdk.span.live` instead.",
unit="{span}",
)
OTEL_SDK_SPAN_STARTED: Final = "otel.sdk.span.started"
"""
The number of created spans
Instrument: counter
Unit: {span}
Note: Implementations MUST record this metric for all spans, even for non-recording ones.
"""
def create_otel_sdk_span_started(meter: Meter) -> Counter:
"""The number of created spans"""
return meter.create_counter(
name=OTEL_SDK_SPAN_STARTED,
description="The number of created spans.",
unit="{span}",
)

View File

@@ -0,0 +1,235 @@
# Copyright The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import (
Callable,
Final,
Generator,
Iterable,
Optional,
Sequence,
Union,
)
from opentelemetry.metrics import (
CallbackOptions,
Counter,
Meter,
ObservableGauge,
Observation,
UpDownCounter,
)
# pylint: disable=invalid-name
CallbackT = Union[
Callable[[CallbackOptions], Iterable[Observation]],
Generator[Iterable[Observation], CallbackOptions, None],
]
PROCESS_CONTEXT_SWITCHES: Final = "process.context_switches"
"""
Number of times the process has been context switched
Instrument: counter
Unit: {context_switch}
"""
def create_process_context_switches(meter: Meter) -> Counter:
"""Number of times the process has been context switched"""
return meter.create_counter(
name=PROCESS_CONTEXT_SWITCHES,
description="Number of times the process has been context switched.",
unit="{context_switch}",
)
PROCESS_CPU_TIME: Final = "process.cpu.time"
"""
Total CPU seconds broken down by different states
Instrument: counter
Unit: s
"""
def create_process_cpu_time(meter: Meter) -> Counter:
"""Total CPU seconds broken down by different states"""
return meter.create_counter(
name=PROCESS_CPU_TIME,
description="Total CPU seconds broken down by different states.",
unit="s",
)
PROCESS_CPU_UTILIZATION: Final = "process.cpu.utilization"
"""
Difference in process.cpu.time since the last measurement, divided by the elapsed time and number of CPUs available to the process
Instrument: gauge
Unit: 1
"""
def create_process_cpu_utilization(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Difference in process.cpu.time since the last measurement, divided by the elapsed time and number of CPUs available to the process"""
return meter.create_observable_gauge(
name=PROCESS_CPU_UTILIZATION,
callbacks=callbacks,
description="Difference in process.cpu.time since the last measurement, divided by the elapsed time and number of CPUs available to the process.",
unit="1",
)
PROCESS_DISK_IO: Final = "process.disk.io"
"""
Disk bytes transferred
Instrument: counter
Unit: By
"""
def create_process_disk_io(meter: Meter) -> Counter:
"""Disk bytes transferred"""
return meter.create_counter(
name=PROCESS_DISK_IO,
description="Disk bytes transferred.",
unit="By",
)
PROCESS_MEMORY_USAGE: Final = "process.memory.usage"
"""
The amount of physical memory in use
Instrument: updowncounter
Unit: By
"""
def create_process_memory_usage(meter: Meter) -> UpDownCounter:
"""The amount of physical memory in use"""
return meter.create_up_down_counter(
name=PROCESS_MEMORY_USAGE,
description="The amount of physical memory in use.",
unit="By",
)
PROCESS_MEMORY_VIRTUAL: Final = "process.memory.virtual"
"""
The amount of committed virtual memory
Instrument: updowncounter
Unit: By
"""
def create_process_memory_virtual(meter: Meter) -> UpDownCounter:
"""The amount of committed virtual memory"""
return meter.create_up_down_counter(
name=PROCESS_MEMORY_VIRTUAL,
description="The amount of committed virtual memory.",
unit="By",
)
PROCESS_NETWORK_IO: Final = "process.network.io"
"""
Network bytes transferred
Instrument: counter
Unit: By
"""
def create_process_network_io(meter: Meter) -> Counter:
"""Network bytes transferred"""
return meter.create_counter(
name=PROCESS_NETWORK_IO,
description="Network bytes transferred.",
unit="By",
)
PROCESS_OPEN_FILE_DESCRIPTOR_COUNT: Final = (
"process.open_file_descriptor.count"
)
"""
Number of file descriptors in use by the process
Instrument: updowncounter
Unit: {file_descriptor}
"""
def create_process_open_file_descriptor_count(meter: Meter) -> UpDownCounter:
"""Number of file descriptors in use by the process"""
return meter.create_up_down_counter(
name=PROCESS_OPEN_FILE_DESCRIPTOR_COUNT,
description="Number of file descriptors in use by the process.",
unit="{file_descriptor}",
)
PROCESS_PAGING_FAULTS: Final = "process.paging.faults"
"""
Number of page faults the process has made
Instrument: counter
Unit: {fault}
"""
def create_process_paging_faults(meter: Meter) -> Counter:
"""Number of page faults the process has made"""
return meter.create_counter(
name=PROCESS_PAGING_FAULTS,
description="Number of page faults the process has made.",
unit="{fault}",
)
PROCESS_THREAD_COUNT: Final = "process.thread.count"
"""
Process threads count
Instrument: updowncounter
Unit: {thread}
"""
def create_process_thread_count(meter: Meter) -> UpDownCounter:
"""Process threads count"""
return meter.create_up_down_counter(
name=PROCESS_THREAD_COUNT,
description="Process threads count.",
unit="{thread}",
)
PROCESS_UPTIME: Final = "process.uptime"
"""
The time the process has been running
Instrument: gauge
Unit: s
Note: Instrumentations SHOULD use a gauge with type `double` and measure uptime in seconds as a floating point number with the highest precision available.
The actual accuracy would depend on the instrumentation and operating system.
"""
def create_process_uptime(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""The time the process has been running"""
return meter.create_observable_gauge(
name=PROCESS_UPTIME,
callbacks=callbacks,
description="The time the process has been running.",
unit="s",
)

View File

@@ -0,0 +1,191 @@
# Copyright The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Final
from opentelemetry.metrics import Histogram, Meter
RPC_CLIENT_DURATION: Final = "rpc.client.duration"
"""
Measures the duration of outbound RPC
Instrument: histogram
Unit: ms
Note: While streaming RPCs may record this metric as start-of-batch
to end-of-batch, it's hard to interpret in practice.
**Streaming**: N/A.
"""
def create_rpc_client_duration(meter: Meter) -> Histogram:
"""Measures the duration of outbound RPC"""
return meter.create_histogram(
name=RPC_CLIENT_DURATION,
description="Measures the duration of outbound RPC.",
unit="ms",
)
RPC_CLIENT_REQUEST_SIZE: Final = "rpc.client.request.size"
"""
Measures the size of RPC request messages (uncompressed)
Instrument: histogram
Unit: By
Note: **Streaming**: Recorded per message in a streaming batch.
"""
def create_rpc_client_request_size(meter: Meter) -> Histogram:
"""Measures the size of RPC request messages (uncompressed)"""
return meter.create_histogram(
name=RPC_CLIENT_REQUEST_SIZE,
description="Measures the size of RPC request messages (uncompressed).",
unit="By",
)
RPC_CLIENT_REQUESTS_PER_RPC: Final = "rpc.client.requests_per_rpc"
"""
Deprecated: Removed, no replacement at this time.
"""
def create_rpc_client_requests_per_rpc(meter: Meter) -> Histogram:
"""Measures the number of messages received per RPC"""
return meter.create_histogram(
name=RPC_CLIENT_REQUESTS_PER_RPC,
description="Measures the number of messages received per RPC.",
unit="{count}",
)
RPC_CLIENT_RESPONSE_SIZE: Final = "rpc.client.response.size"
"""
Measures the size of RPC response messages (uncompressed)
Instrument: histogram
Unit: By
Note: **Streaming**: Recorded per response in a streaming batch.
"""
def create_rpc_client_response_size(meter: Meter) -> Histogram:
"""Measures the size of RPC response messages (uncompressed)"""
return meter.create_histogram(
name=RPC_CLIENT_RESPONSE_SIZE,
description="Measures the size of RPC response messages (uncompressed).",
unit="By",
)
RPC_CLIENT_RESPONSES_PER_RPC: Final = "rpc.client.responses_per_rpc"
"""
Deprecated: Removed, no replacement at this time.
"""
def create_rpc_client_responses_per_rpc(meter: Meter) -> Histogram:
"""Measures the number of messages sent per RPC"""
return meter.create_histogram(
name=RPC_CLIENT_RESPONSES_PER_RPC,
description="Measures the number of messages sent per RPC.",
unit="{count}",
)
RPC_SERVER_DURATION: Final = "rpc.server.duration"
"""
Measures the duration of inbound RPC
Instrument: histogram
Unit: ms
Note: While streaming RPCs may record this metric as start-of-batch
to end-of-batch, it's hard to interpret in practice.
**Streaming**: N/A.
"""
def create_rpc_server_duration(meter: Meter) -> Histogram:
"""Measures the duration of inbound RPC"""
return meter.create_histogram(
name=RPC_SERVER_DURATION,
description="Measures the duration of inbound RPC.",
unit="ms",
)
RPC_SERVER_REQUEST_SIZE: Final = "rpc.server.request.size"
"""
Measures the size of RPC request messages (uncompressed)
Instrument: histogram
Unit: By
Note: **Streaming**: Recorded per message in a streaming batch.
"""
def create_rpc_server_request_size(meter: Meter) -> Histogram:
"""Measures the size of RPC request messages (uncompressed)"""
return meter.create_histogram(
name=RPC_SERVER_REQUEST_SIZE,
description="Measures the size of RPC request messages (uncompressed).",
unit="By",
)
RPC_SERVER_REQUESTS_PER_RPC: Final = "rpc.server.requests_per_rpc"
"""
Deprecated: Removed, no replacement at this time.
"""
def create_rpc_server_requests_per_rpc(meter: Meter) -> Histogram:
"""Measures the number of messages received per RPC"""
return meter.create_histogram(
name=RPC_SERVER_REQUESTS_PER_RPC,
description="Measures the number of messages received per RPC.",
unit="{count}",
)
RPC_SERVER_RESPONSE_SIZE: Final = "rpc.server.response.size"
"""
Measures the size of RPC response messages (uncompressed)
Instrument: histogram
Unit: By
Note: **Streaming**: Recorded per response in a streaming batch.
"""
def create_rpc_server_response_size(meter: Meter) -> Histogram:
"""Measures the size of RPC response messages (uncompressed)"""
return meter.create_histogram(
name=RPC_SERVER_RESPONSE_SIZE,
description="Measures the size of RPC response messages (uncompressed).",
unit="By",
)
RPC_SERVER_RESPONSES_PER_RPC: Final = "rpc.server.responses_per_rpc"
"""
Deprecated: Removed, no replacement at this time.
"""
def create_rpc_server_responses_per_rpc(meter: Meter) -> Histogram:
"""Measures the number of messages sent per RPC"""
return meter.create_histogram(
name=RPC_SERVER_RESPONSES_PER_RPC,
description="Measures the number of messages sent per RPC.",
unit="{count}",
)

View File

@@ -0,0 +1,681 @@
# Copyright The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import (
Callable,
Final,
Generator,
Iterable,
Optional,
Sequence,
Union,
)
from opentelemetry.metrics import (
CallbackOptions,
Counter,
Meter,
ObservableGauge,
Observation,
UpDownCounter,
)
# pylint: disable=invalid-name
CallbackT = Union[
Callable[[CallbackOptions], Iterable[Observation]],
Generator[Iterable[Observation], CallbackOptions, None],
]
SYSTEM_CPU_FREQUENCY: Final = "system.cpu.frequency"
"""
Operating frequency of the logical CPU in Hertz
Instrument: gauge
Unit: Hz
"""
def create_system_cpu_frequency(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Operating frequency of the logical CPU in Hertz"""
return meter.create_observable_gauge(
name=SYSTEM_CPU_FREQUENCY,
callbacks=callbacks,
description="Operating frequency of the logical CPU in Hertz.",
unit="Hz",
)
SYSTEM_CPU_LOGICAL_COUNT: Final = "system.cpu.logical.count"
"""
Reports the number of logical (virtual) processor cores created by the operating system to manage multitasking
Instrument: updowncounter
Unit: {cpu}
Note: Calculated by multiplying the number of sockets by the number of cores per socket, and then by the number of threads per core.
"""
def create_system_cpu_logical_count(meter: Meter) -> UpDownCounter:
"""Reports the number of logical (virtual) processor cores created by the operating system to manage multitasking"""
return meter.create_up_down_counter(
name=SYSTEM_CPU_LOGICAL_COUNT,
description="Reports the number of logical (virtual) processor cores created by the operating system to manage multitasking.",
unit="{cpu}",
)
SYSTEM_CPU_PHYSICAL_COUNT: Final = "system.cpu.physical.count"
"""
Reports the number of actual physical processor cores on the hardware
Instrument: updowncounter
Unit: {cpu}
Note: Calculated by multiplying the number of sockets by the number of cores per socket.
"""
def create_system_cpu_physical_count(meter: Meter) -> UpDownCounter:
"""Reports the number of actual physical processor cores on the hardware"""
return meter.create_up_down_counter(
name=SYSTEM_CPU_PHYSICAL_COUNT,
description="Reports the number of actual physical processor cores on the hardware.",
unit="{cpu}",
)
SYSTEM_CPU_TIME: Final = "system.cpu.time"
"""
Seconds each logical CPU spent on each mode
Instrument: counter
Unit: s
"""
def create_system_cpu_time(meter: Meter) -> Counter:
"""Seconds each logical CPU spent on each mode"""
return meter.create_counter(
name=SYSTEM_CPU_TIME,
description="Seconds each logical CPU spent on each mode.",
unit="s",
)
SYSTEM_CPU_UTILIZATION: Final = "system.cpu.utilization"
"""
For each logical CPU, the utilization is calculated as the change in cumulative CPU time (cpu.time) over a measurement interval, divided by the elapsed time
Instrument: gauge
Unit: 1
"""
def create_system_cpu_utilization(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""For each logical CPU, the utilization is calculated as the change in cumulative CPU time (cpu.time) over a measurement interval, divided by the elapsed time"""
return meter.create_observable_gauge(
name=SYSTEM_CPU_UTILIZATION,
callbacks=callbacks,
description="For each logical CPU, the utilization is calculated as the change in cumulative CPU time (cpu.time) over a measurement interval, divided by the elapsed time.",
unit="1",
)
SYSTEM_DISK_IO: Final = "system.disk.io"
"""
Disk bytes transferred
Instrument: counter
Unit: By
"""
def create_system_disk_io(meter: Meter) -> Counter:
"""Disk bytes transferred"""
return meter.create_counter(
name=SYSTEM_DISK_IO,
description="Disk bytes transferred.",
unit="By",
)
SYSTEM_DISK_IO_TIME: Final = "system.disk.io_time"
"""
Time disk spent activated
Instrument: counter
Unit: s
Note: The real elapsed time ("wall clock") used in the I/O path (time from operations running in parallel are not counted). Measured as:
- Linux: Field 13 from [procfs-diskstats](https://www.kernel.org/doc/Documentation/ABI/testing/procfs-diskstats)
- Windows: The complement of
["Disk\\% Idle Time"](https://learn.microsoft.com/archive/blogs/askcore/windows-performance-monitor-disk-counters-explained#windows-performance-monitor-disk-counters-explained)
performance counter: `uptime * (100 - "Disk\\% Idle Time") / 100`.
"""
def create_system_disk_io_time(meter: Meter) -> Counter:
"""Time disk spent activated"""
return meter.create_counter(
name=SYSTEM_DISK_IO_TIME,
description="Time disk spent activated.",
unit="s",
)
SYSTEM_DISK_LIMIT: Final = "system.disk.limit"
"""
The total storage capacity of the disk
Instrument: updowncounter
Unit: By
"""
def create_system_disk_limit(meter: Meter) -> UpDownCounter:
"""The total storage capacity of the disk"""
return meter.create_up_down_counter(
name=SYSTEM_DISK_LIMIT,
description="The total storage capacity of the disk.",
unit="By",
)
SYSTEM_DISK_MERGED: Final = "system.disk.merged"
"""
The number of disk reads/writes merged into single physical disk access operations
Instrument: counter
Unit: {operation}
"""
def create_system_disk_merged(meter: Meter) -> Counter:
"""The number of disk reads/writes merged into single physical disk access operations"""
return meter.create_counter(
name=SYSTEM_DISK_MERGED,
description="The number of disk reads/writes merged into single physical disk access operations.",
unit="{operation}",
)
SYSTEM_DISK_OPERATION_TIME: Final = "system.disk.operation_time"
"""
Sum of the time each operation took to complete
Instrument: counter
Unit: s
Note: Because it is the sum of time each request took, parallel-issued requests each contribute to make the count grow. Measured as:
- Linux: Fields 7 & 11 from [procfs-diskstats](https://www.kernel.org/doc/Documentation/ABI/testing/procfs-diskstats)
- Windows: "Avg. Disk sec/Read" perf counter multiplied by "Disk Reads/sec" perf counter (similar for Writes).
"""
def create_system_disk_operation_time(meter: Meter) -> Counter:
"""Sum of the time each operation took to complete"""
return meter.create_counter(
name=SYSTEM_DISK_OPERATION_TIME,
description="Sum of the time each operation took to complete.",
unit="s",
)
SYSTEM_DISK_OPERATIONS: Final = "system.disk.operations"
"""
Disk operations count
Instrument: counter
Unit: {operation}
"""
def create_system_disk_operations(meter: Meter) -> Counter:
"""Disk operations count"""
return meter.create_counter(
name=SYSTEM_DISK_OPERATIONS,
description="Disk operations count.",
unit="{operation}",
)
SYSTEM_FILESYSTEM_LIMIT: Final = "system.filesystem.limit"
"""
The total storage capacity of the filesystem
Instrument: updowncounter
Unit: By
"""
def create_system_filesystem_limit(meter: Meter) -> UpDownCounter:
"""The total storage capacity of the filesystem"""
return meter.create_up_down_counter(
name=SYSTEM_FILESYSTEM_LIMIT,
description="The total storage capacity of the filesystem.",
unit="By",
)
SYSTEM_FILESYSTEM_USAGE: Final = "system.filesystem.usage"
"""
Reports a filesystem's space usage across different states
Instrument: updowncounter
Unit: By
Note: The sum of all `system.filesystem.usage` values over the different `system.filesystem.state` attributes
SHOULD equal the total storage capacity of the filesystem, that is `system.filesystem.limit`.
"""
def create_system_filesystem_usage(meter: Meter) -> UpDownCounter:
"""Reports a filesystem's space usage across different states"""
return meter.create_up_down_counter(
name=SYSTEM_FILESYSTEM_USAGE,
description="Reports a filesystem's space usage across different states.",
unit="By",
)
SYSTEM_FILESYSTEM_UTILIZATION: Final = "system.filesystem.utilization"
"""
Fraction of filesystem bytes used
Instrument: gauge
Unit: 1
"""
def create_system_filesystem_utilization(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Fraction of filesystem bytes used"""
return meter.create_observable_gauge(
name=SYSTEM_FILESYSTEM_UTILIZATION,
callbacks=callbacks,
description="Fraction of filesystem bytes used.",
unit="1",
)
SYSTEM_LINUX_MEMORY_AVAILABLE: Final = "system.linux.memory.available"
"""
An estimate of how much memory is available for starting new applications, without causing swapping
Instrument: updowncounter
Unit: By
Note: This is an alternative to `system.memory.usage` metric with `state=free`.
Linux starting from 3.14 exports "available" memory. It takes "free" memory as a baseline, and then factors in kernel-specific values.
This is supposed to be more accurate than just "free" memory.
For reference, see the calculations [here](https://superuser.com/a/980821).
See also `MemAvailable` in [/proc/meminfo](https://man7.org/linux/man-pages/man5/proc.5.html).
"""
def create_system_linux_memory_available(meter: Meter) -> UpDownCounter:
"""An estimate of how much memory is available for starting new applications, without causing swapping"""
return meter.create_up_down_counter(
name=SYSTEM_LINUX_MEMORY_AVAILABLE,
description="An estimate of how much memory is available for starting new applications, without causing swapping.",
unit="By",
)
SYSTEM_LINUX_MEMORY_SLAB_USAGE: Final = "system.linux.memory.slab.usage"
"""
Reports the memory used by the Linux kernel for managing caches of frequently used objects
Instrument: updowncounter
Unit: By
Note: The sum over the `reclaimable` and `unreclaimable` state values in `linux.memory.slab.usage` SHOULD be equal to the total slab memory available on the system.
Note that the total slab memory is not constant and may vary over time.
See also the [Slab allocator](https://blogs.oracle.com/linux/post/understanding-linux-kernel-memory-statistics) and `Slab` in [/proc/meminfo](https://man7.org/linux/man-pages/man5/proc.5.html).
"""
def create_system_linux_memory_slab_usage(meter: Meter) -> UpDownCounter:
"""Reports the memory used by the Linux kernel for managing caches of frequently used objects"""
return meter.create_up_down_counter(
name=SYSTEM_LINUX_MEMORY_SLAB_USAGE,
description="Reports the memory used by the Linux kernel for managing caches of frequently used objects.",
unit="By",
)
SYSTEM_MEMORY_LIMIT: Final = "system.memory.limit"
"""
Total virtual memory available in the system
Instrument: updowncounter
Unit: By
"""
def create_system_memory_limit(meter: Meter) -> UpDownCounter:
"""Total virtual memory available in the system"""
return meter.create_up_down_counter(
name=SYSTEM_MEMORY_LIMIT,
description="Total virtual memory available in the system.",
unit="By",
)
SYSTEM_MEMORY_SHARED: Final = "system.memory.shared"
"""
Shared memory used (mostly by tmpfs)
Instrument: updowncounter
Unit: By
Note: Equivalent of `shared` from [`free` command](https://man7.org/linux/man-pages/man1/free.1.html) or
`Shmem` from [`/proc/meminfo`](https://man7.org/linux/man-pages/man5/proc.5.html)".
"""
def create_system_memory_shared(meter: Meter) -> UpDownCounter:
"""Shared memory used (mostly by tmpfs)"""
return meter.create_up_down_counter(
name=SYSTEM_MEMORY_SHARED,
description="Shared memory used (mostly by tmpfs).",
unit="By",
)
SYSTEM_MEMORY_USAGE: Final = "system.memory.usage"
"""
Reports memory in use by state
Instrument: updowncounter
Unit: By
"""
def create_system_memory_usage(meter: Meter) -> UpDownCounter:
"""Reports memory in use by state"""
return meter.create_up_down_counter(
name=SYSTEM_MEMORY_USAGE,
description="Reports memory in use by state.",
unit="By",
)
SYSTEM_MEMORY_UTILIZATION: Final = "system.memory.utilization"
"""
Percentage of memory bytes in use
Instrument: gauge
Unit: 1
"""
def create_system_memory_utilization(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Percentage of memory bytes in use"""
return meter.create_observable_gauge(
name=SYSTEM_MEMORY_UTILIZATION,
callbacks=callbacks,
description="Percentage of memory bytes in use.",
unit="1",
)
SYSTEM_NETWORK_CONNECTION_COUNT: Final = "system.network.connection.count"
"""
The number of connections
Instrument: updowncounter
Unit: {connection}
"""
def create_system_network_connection_count(meter: Meter) -> UpDownCounter:
"""The number of connections"""
return meter.create_up_down_counter(
name=SYSTEM_NETWORK_CONNECTION_COUNT,
description="The number of connections.",
unit="{connection}",
)
SYSTEM_NETWORK_CONNECTIONS: Final = "system.network.connections"
"""
Deprecated: Replaced by `system.network.connection.count`.
"""
def create_system_network_connections(meter: Meter) -> UpDownCounter:
"""Deprecated, use `system.network.connection.count` instead"""
return meter.create_up_down_counter(
name=SYSTEM_NETWORK_CONNECTIONS,
description="Deprecated, use `system.network.connection.count` instead.",
unit="{connection}",
)
SYSTEM_NETWORK_DROPPED: Final = "system.network.dropped"
"""
Deprecated: Replaced by `system.network.packet.dropped`.
"""
def create_system_network_dropped(meter: Meter) -> Counter:
"""Count of packets that are dropped or discarded even though there was no error"""
return meter.create_counter(
name=SYSTEM_NETWORK_DROPPED,
description="Count of packets that are dropped or discarded even though there was no error.",
unit="{packet}",
)
SYSTEM_NETWORK_ERRORS: Final = "system.network.errors"
"""
Count of network errors detected
Instrument: counter
Unit: {error}
Note: Measured as:
- Linux: the `errs` column in `/proc/net/dev` ([source](https://web.archive.org/web/20180321091318/http://www.onlamp.com/pub/a/linux/2000/11/16/LinuxAdmin.html)).
- Windows: [`InErrors`/`OutErrors`](https://docs.microsoft.com/windows/win32/api/netioapi/ns-netioapi-mib_if_row2)
from [`GetIfEntry2`](https://docs.microsoft.com/windows/win32/api/netioapi/nf-netioapi-getifentry2).
"""
def create_system_network_errors(meter: Meter) -> Counter:
"""Count of network errors detected"""
return meter.create_counter(
name=SYSTEM_NETWORK_ERRORS,
description="Count of network errors detected.",
unit="{error}",
)
SYSTEM_NETWORK_IO: Final = "system.network.io"
"""
The number of bytes transmitted and received
Instrument: counter
Unit: By
"""
def create_system_network_io(meter: Meter) -> Counter:
"""The number of bytes transmitted and received"""
return meter.create_counter(
name=SYSTEM_NETWORK_IO,
description="The number of bytes transmitted and received.",
unit="By",
)
SYSTEM_NETWORK_PACKET_COUNT: Final = "system.network.packet.count"
"""
The number of packets transferred
Instrument: counter
Unit: {packet}
"""
def create_system_network_packet_count(meter: Meter) -> Counter:
"""The number of packets transferred"""
return meter.create_counter(
name=SYSTEM_NETWORK_PACKET_COUNT,
description="The number of packets transferred.",
unit="{packet}",
)
SYSTEM_NETWORK_PACKET_DROPPED: Final = "system.network.packet.dropped"
"""
Count of packets that are dropped or discarded even though there was no error
Instrument: counter
Unit: {packet}
Note: Measured as:
- Linux: the `drop` column in `/proc/net/dev` ([source](https://web.archive.org/web/20180321091318/http://www.onlamp.com/pub/a/linux/2000/11/16/LinuxAdmin.html))
- Windows: [`InDiscards`/`OutDiscards`](https://docs.microsoft.com/windows/win32/api/netioapi/ns-netioapi-mib_if_row2)
from [`GetIfEntry2`](https://docs.microsoft.com/windows/win32/api/netioapi/nf-netioapi-getifentry2).
"""
def create_system_network_packet_dropped(meter: Meter) -> Counter:
"""Count of packets that are dropped or discarded even though there was no error"""
return meter.create_counter(
name=SYSTEM_NETWORK_PACKET_DROPPED,
description="Count of packets that are dropped or discarded even though there was no error.",
unit="{packet}",
)
SYSTEM_NETWORK_PACKETS: Final = "system.network.packets"
"""
Deprecated: Replaced by `system.network.packet.count`.
"""
def create_system_network_packets(meter: Meter) -> Counter:
"""The number of packets transferred"""
return meter.create_counter(
name=SYSTEM_NETWORK_PACKETS,
description="The number of packets transferred.",
unit="{packet}",
)
SYSTEM_PAGING_FAULTS: Final = "system.paging.faults"
"""
The number of page faults
Instrument: counter
Unit: {fault}
"""
def create_system_paging_faults(meter: Meter) -> Counter:
"""The number of page faults"""
return meter.create_counter(
name=SYSTEM_PAGING_FAULTS,
description="The number of page faults.",
unit="{fault}",
)
SYSTEM_PAGING_OPERATIONS: Final = "system.paging.operations"
"""
The number of paging operations
Instrument: counter
Unit: {operation}
"""
def create_system_paging_operations(meter: Meter) -> Counter:
"""The number of paging operations"""
return meter.create_counter(
name=SYSTEM_PAGING_OPERATIONS,
description="The number of paging operations.",
unit="{operation}",
)
SYSTEM_PAGING_USAGE: Final = "system.paging.usage"
"""
Unix swap or windows pagefile usage
Instrument: updowncounter
Unit: By
"""
def create_system_paging_usage(meter: Meter) -> UpDownCounter:
"""Unix swap or windows pagefile usage"""
return meter.create_up_down_counter(
name=SYSTEM_PAGING_USAGE,
description="Unix swap or windows pagefile usage.",
unit="By",
)
SYSTEM_PAGING_UTILIZATION: Final = "system.paging.utilization"
"""
Swap (unix) or pagefile (windows) utilization
Instrument: gauge
Unit: 1
"""
def create_system_paging_utilization(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Swap (unix) or pagefile (windows) utilization"""
return meter.create_observable_gauge(
name=SYSTEM_PAGING_UTILIZATION,
callbacks=callbacks,
description="Swap (unix) or pagefile (windows) utilization.",
unit="1",
)
SYSTEM_PROCESS_COUNT: Final = "system.process.count"
"""
Total number of processes in each state
Instrument: updowncounter
Unit: {process}
"""
def create_system_process_count(meter: Meter) -> UpDownCounter:
"""Total number of processes in each state"""
return meter.create_up_down_counter(
name=SYSTEM_PROCESS_COUNT,
description="Total number of processes in each state.",
unit="{process}",
)
SYSTEM_PROCESS_CREATED: Final = "system.process.created"
"""
Total number of processes created over uptime of the host
Instrument: counter
Unit: {process}
"""
def create_system_process_created(meter: Meter) -> Counter:
"""Total number of processes created over uptime of the host"""
return meter.create_counter(
name=SYSTEM_PROCESS_CREATED,
description="Total number of processes created over uptime of the host.",
unit="{process}",
)
SYSTEM_UPTIME: Final = "system.uptime"
"""
The time the system has been running
Instrument: gauge
Unit: s
Note: Instrumentations SHOULD use a gauge with type `double` and measure uptime in seconds as a floating point number with the highest precision available.
The actual accuracy would depend on the instrumentation and operating system.
"""
def create_system_uptime(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""The time the system has been running"""
return meter.create_observable_gauge(
name=SYSTEM_UPTIME,
callbacks=callbacks,
description="The time the system has been running.",
unit="s",
)

View File

@@ -0,0 +1,233 @@
# Copyright The OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import (
Callable,
Final,
Generator,
Iterable,
Optional,
Sequence,
Union,
)
from opentelemetry.metrics import (
CallbackOptions,
Meter,
ObservableGauge,
Observation,
UpDownCounter,
)
# pylint: disable=invalid-name
CallbackT = Union[
Callable[[CallbackOptions], Iterable[Observation]],
Generator[Iterable[Observation], CallbackOptions, None],
]
VCS_CHANGE_COUNT: Final = "vcs.change.count"
"""
The number of changes (pull requests/merge requests/changelists) in a repository, categorized by their state (e.g. open or merged)
Instrument: updowncounter
Unit: {change}
"""
def create_vcs_change_count(meter: Meter) -> UpDownCounter:
"""The number of changes (pull requests/merge requests/changelists) in a repository, categorized by their state (e.g. open or merged)"""
return meter.create_up_down_counter(
name=VCS_CHANGE_COUNT,
description="The number of changes (pull requests/merge requests/changelists) in a repository, categorized by their state (e.g. open or merged).",
unit="{change}",
)
VCS_CHANGE_DURATION: Final = "vcs.change.duration"
"""
The time duration a change (pull request/merge request/changelist) has been in a given state
Instrument: gauge
Unit: s
"""
def create_vcs_change_duration(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""The time duration a change (pull request/merge request/changelist) has been in a given state"""
return meter.create_observable_gauge(
name=VCS_CHANGE_DURATION,
callbacks=callbacks,
description="The time duration a change (pull request/merge request/changelist) has been in a given state.",
unit="s",
)
VCS_CHANGE_TIME_TO_APPROVAL: Final = "vcs.change.time_to_approval"
"""
The amount of time since its creation it took a change (pull request/merge request/changelist) to get the first approval
Instrument: gauge
Unit: s
"""
def create_vcs_change_time_to_approval(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""The amount of time since its creation it took a change (pull request/merge request/changelist) to get the first approval"""
return meter.create_observable_gauge(
name=VCS_CHANGE_TIME_TO_APPROVAL,
callbacks=callbacks,
description="The amount of time since its creation it took a change (pull request/merge request/changelist) to get the first approval.",
unit="s",
)
VCS_CHANGE_TIME_TO_MERGE: Final = "vcs.change.time_to_merge"
"""
The amount of time since its creation it took a change (pull request/merge request/changelist) to get merged into the target(base) ref
Instrument: gauge
Unit: s
"""
def create_vcs_change_time_to_merge(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""The amount of time since its creation it took a change (pull request/merge request/changelist) to get merged into the target(base) ref"""
return meter.create_observable_gauge(
name=VCS_CHANGE_TIME_TO_MERGE,
callbacks=callbacks,
description="The amount of time since its creation it took a change (pull request/merge request/changelist) to get merged into the target(base) ref.",
unit="s",
)
VCS_CONTRIBUTOR_COUNT: Final = "vcs.contributor.count"
"""
The number of unique contributors to a repository
Instrument: gauge
Unit: {contributor}
"""
def create_vcs_contributor_count(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""The number of unique contributors to a repository"""
return meter.create_observable_gauge(
name=VCS_CONTRIBUTOR_COUNT,
callbacks=callbacks,
description="The number of unique contributors to a repository.",
unit="{contributor}",
)
VCS_REF_COUNT: Final = "vcs.ref.count"
"""
The number of refs of type branch or tag in a repository
Instrument: updowncounter
Unit: {ref}
"""
def create_vcs_ref_count(meter: Meter) -> UpDownCounter:
"""The number of refs of type branch or tag in a repository"""
return meter.create_up_down_counter(
name=VCS_REF_COUNT,
description="The number of refs of type branch or tag in a repository.",
unit="{ref}",
)
VCS_REF_LINES_DELTA: Final = "vcs.ref.lines_delta"
"""
The number of lines added/removed in a ref (branch) relative to the ref from the `vcs.ref.base.name` attribute
Instrument: gauge
Unit: {line}
Note: This metric should be reported for each `vcs.line_change.type` value. For example if a ref added 3 lines and removed 2 lines,
instrumentation SHOULD report two measurements: 3 and 2 (both positive numbers).
If number of lines added/removed should be calculated from the start of time, then `vcs.ref.base.name` SHOULD be set to an empty string.
"""
def create_vcs_ref_lines_delta(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""The number of lines added/removed in a ref (branch) relative to the ref from the `vcs.ref.base.name` attribute"""
return meter.create_observable_gauge(
name=VCS_REF_LINES_DELTA,
callbacks=callbacks,
description="The number of lines added/removed in a ref (branch) relative to the ref from the `vcs.ref.base.name` attribute.",
unit="{line}",
)
VCS_REF_REVISIONS_DELTA: Final = "vcs.ref.revisions_delta"
"""
The number of revisions (commits) a ref (branch) is ahead/behind the branch from the `vcs.ref.base.name` attribute
Instrument: gauge
Unit: {revision}
Note: This metric should be reported for each `vcs.revision_delta.direction` value. For example if branch `a` is 3 commits behind and 2 commits ahead of `trunk`,
instrumentation SHOULD report two measurements: 3 and 2 (both positive numbers) and `vcs.ref.base.name` is set to `trunk`.
"""
def create_vcs_ref_revisions_delta(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""The number of revisions (commits) a ref (branch) is ahead/behind the branch from the `vcs.ref.base.name` attribute"""
return meter.create_observable_gauge(
name=VCS_REF_REVISIONS_DELTA,
callbacks=callbacks,
description="The number of revisions (commits) a ref (branch) is ahead/behind the branch from the `vcs.ref.base.name` attribute.",
unit="{revision}",
)
VCS_REF_TIME: Final = "vcs.ref.time"
"""
Time a ref (branch) created from the default branch (trunk) has existed. The `ref.type` attribute will always be `branch`
Instrument: gauge
Unit: s
"""
def create_vcs_ref_time(
meter: Meter, callbacks: Optional[Sequence[CallbackT]]
) -> ObservableGauge:
"""Time a ref (branch) created from the default branch (trunk) has existed. The `ref.type` attribute will always be `branch`"""
return meter.create_observable_gauge(
name=VCS_REF_TIME,
callbacks=callbacks,
description="Time a ref (branch) created from the default branch (trunk) has existed. The `ref.type` attribute will always be `branch`.",
unit="s",
)
VCS_REPOSITORY_COUNT: Final = "vcs.repository.count"
"""
The number of repositories in an organization
Instrument: updowncounter
Unit: {repository}
"""
def create_vcs_repository_count(meter: Meter) -> UpDownCounter:
"""The number of repositories in an organization"""
return meter.create_up_down_counter(
name=VCS_REPOSITORY_COUNT,
description="The number of repositories in an organization.",
unit="{repository}",
)