Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
lmolkova committed Jul 26, 2024
1 parent 3993617 commit 8475de1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,18 @@

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],
]
from opentelemetry.metrics import Counter, UpDownCounter

PROCESS_CONTEXT_SWITCHES: Final = "process.context_switches"
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,18 @@

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],
]
from opentelemetry.metrics import Counter, UpDownCounter

SYSTEM_CPU_FREQUENCY: Final = "system.cpu.frequency"
"""
Expand Down
13 changes: 7 additions & 6 deletions scripts/semconv/templates/registry/semantic_metrics.j2
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@
{% if ctx.filter == "any" %}
from opentelemetry.metrics import Meter

{%- set instruments = ["counter", "histogram", "updowncounter"]-%}
{%- for i in instruments -%}
{%- if ctx.metrics | selectattr("instrument", "equalto", i) | list | count > 0 %}
from opentelemetry.metrics import {{i | map_text("py_instrument_to_type")}}
{%- endif -%}
{%- endfor-%}

{%- if ctx.metrics | selectattr("instrument", "equalto", "gauge") | list | count > 0 %}
from typing import Callable, Generator, Iterable, Optional, Sequence, Union
from opentelemetry.metrics import CallbackOptions, ObservableGauge, Observation
Expand All @@ -53,12 +60,6 @@ CallbackT = Union[
]
{%- endif %}

{%- set instruments = ["counter", "histogram", "updowncounter"]-%}
{%- for i in instruments -%}
{%- if ctx.metrics | selectattr("instrument", "equalto", i) | list | count > 0 %}
from opentelemetry.metrics import {{i | map_text("py_instrument_to_type")}}
{%- endif -%}
{%- endfor-%}
{%- endif -%}
{%- endmacro-%}

Expand Down

0 comments on commit 8475de1

Please sign in to comment.