Skip to content

Commit

Permalink
sort metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
lmolkova committed Jun 9, 2024
1 parent aa435b6 commit f997ff5
Show file tree
Hide file tree
Showing 13 changed files with 569 additions and 557 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# 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
Expand Down Expand Up @@ -31,36 +32,36 @@ def create_container_cpu_time(meter: Meter) -> Counter:
)


CONTAINER_MEMORY_USAGE = "container.memory.usage"
CONTAINER_DISK_IO = "container.disk.io"
"""
Memory usage of the container.
Disk bytes for the container.
Instrument: counter
Unit: By
"""


def create_container_memory_usage(meter: Meter) -> Counter:
"""Memory usage of the container."""
def create_container_disk_io(meter: Meter) -> Counter:
"""Disk bytes for the container."""
return meter.create_counter(
name="container.memory.usage",
description="Memory usage of the container.",
name="container.disk.io",
description="Disk bytes for the container.",
unit="By",
)


CONTAINER_DISK_IO = "container.disk.io"
CONTAINER_MEMORY_USAGE = "container.memory.usage"
"""
Disk bytes for the container.
Memory usage of the container.
Instrument: counter
Unit: By
"""


def create_container_disk_io(meter: Meter) -> Counter:
"""Disk bytes for the container."""
def create_container_memory_usage(meter: Meter) -> Counter:
"""Memory usage of the container."""
return meter.create_counter(
name="container.disk.io",
description="Disk bytes for the container.",
name="container.memory.usage",
description="Memory usage of the container.",
unit="By",
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# 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
Expand All @@ -14,23 +15,6 @@

from opentelemetry.metrics import Counter, Histogram, Meter, UpDownCounter

DB_CLIENT_OPERATION_DURATION = "db.client.operation.duration"
"""
Duration of database client operations.
Instrument: histogram
Unit: s
"""


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_CONNECTION_COUNT = "db.client.connection.count"
"""
The number of connections that are currently in state described by the `state` attribute
Expand All @@ -48,6 +32,23 @@ def create_db_client_connection_count(meter: Meter) -> UpDownCounter:
)


DB_CLIENT_CONNECTION_CREATE_TIME = "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 = "db.client.connection.idle.max"
"""
The maximum number of idle open connections allowed
Expand Down Expand Up @@ -135,19 +136,19 @@ def create_db_client_connection_timeouts(meter: Meter) -> Counter:
)


DB_CLIENT_CONNECTION_CREATE_TIME = "db.client.connection.create_time"
DB_CLIENT_CONNECTION_USE_TIME = "db.client.connection.use_time"
"""
The time it took to create a new connection
The time between borrowing a connection and returning it to the pool
Instrument: histogram
Unit: s
"""


def create_db_client_connection_create_time(meter: Meter) -> Histogram:
"""The time it took to create a new connection"""
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.create_time",
description="The time it took to create a new connection",
name="db.client.connection.use_time",
description="The time between borrowing a connection and returning it to the pool",
unit="s",
)

Expand All @@ -169,35 +170,18 @@ def create_db_client_connection_wait_time(meter: Meter) -> Histogram:
)


DB_CLIENT_CONNECTION_USE_TIME = "db.client.connection.use_time"
DB_CLIENT_CONNECTIONS_CREATE_TIME = "db.client.connections.create_time"
"""
The time between borrowing a connection and returning it to the pool
Instrument: histogram
Unit: s
Deprecated: Replaced by `db.client.connection.create_time`. Note: the unit also changed from `ms` to `s`.
"""


def create_db_client_connection_use_time(meter: Meter) -> Histogram:
"""The time between borrowing a connection and returning it to the pool"""
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.connection.use_time",
description="The time between borrowing a connection and returning it to the pool",
unit="s",
)


DB_CLIENT_CONNECTIONS_USAGE = "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}",
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",
)


Expand Down Expand Up @@ -280,17 +264,32 @@ def create_db_client_connections_timeouts(meter: Meter) -> Counter:
)


DB_CLIENT_CONNECTIONS_CREATE_TIME = "db.client.connections.create_time"
DB_CLIENT_CONNECTIONS_USAGE = "db.client.connections.usage"
"""
Deprecated: Replaced by `db.client.connection.create_time`. Note: the unit also changed from `ms` to `s`.
Deprecated: Replaced by `db.client.connection.count`.
"""


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`."""
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 = "db.client.connections.use_time"
"""
Deprecated: Replaced by `db.client.connection.use_time`. Note: the unit also changed from `ms` to `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.create_time",
description="Deprecated, use `db.client.connection.create_time` instead. Note: the unit also changed from `ms` to `s`.",
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",
)

Expand All @@ -310,16 +309,18 @@ def create_db_client_connections_wait_time(meter: Meter) -> Histogram:
)


DB_CLIENT_CONNECTIONS_USE_TIME = "db.client.connections.use_time"
DB_CLIENT_OPERATION_DURATION = "db.client.operation.duration"
"""
Deprecated: Replaced by `db.client.connection.use_time`. Note: the unit also changed from `ms` to `s`.
Duration of database client operations.
Instrument: histogram
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`."""
def create_db_client_operation_duration(meter: Meter) -> Histogram:
"""Duration of database client operations."""
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",
name="db.client.operation.duration",
description="Duration of database client operations.",
unit="s",
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# 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
Expand Down
Loading

0 comments on commit f997ff5

Please sign in to comment.