Skip to content

Commit

Permalink
fix OTEL API use
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaqq committed Jan 24, 2025
1 parent 17cf5fb commit 44fde41
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ops/pebble.py
Original file line number Diff line number Diff line change
Expand Up @@ -2248,7 +2248,7 @@ def _services_action(
)

services = list(services)
tracer.get_current_span().set_attribute('services', services) # type: ignore
opentelemetry.trace.get_current_span().set_attribute('services', services)
for s in services:
if not isinstance(s, str):
raise TypeError(f'service names must be str, not {type(s).__name__}')
Expand Down Expand Up @@ -2365,7 +2365,7 @@ def add_layer(self, label: str, layer: Union[str, LayerDict, Layer], *, combine:
"""
if not isinstance(label, str):
raise TypeError(f'label must be a str, not {type(label).__name__}')
tracer.get_current_span().set_attribute('label', label) # type: ignore
opentelemetry.trace.get_current_span().set_attribute('label', label)

if isinstance(layer, str):
layer_yaml = layer
Expand Down Expand Up @@ -3059,8 +3059,8 @@ def send_signal(self, sig: Union[int, str], services: Iterable[str]):
if isinstance(sig, int):
sig = signal.Signals(sig).name

tracer.get_current_span().set_attribute('signal', sig) # type: ignore
tracer.get_current_span().set_attribute('services', services) # type: ignore
opentelemetry.trace.get_current_span().set_attribute('signal', sig)
opentelemetry.trace.get_current_span().set_attribute('services', services)
body = {
'signal': sig,
'services': services,
Expand Down
5 changes: 5 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ allowlist_externals = cp
deps =
PyYAML==6.*
websocket-client==1.*
opentelemetry-api~=1.21
pyright==1.1.385
pytest~=7.2
typing_extensions~=4.2
Expand All @@ -99,6 +100,7 @@ passenv =
deps =
PyYAML==6.*
websocket-client==1.*
opentelemetry-api~=1.21
pytest~=7.2
pytest-xdist~=3.6
typing_extensions~=4.2
Expand All @@ -120,6 +122,7 @@ passenv =
deps =
PyYAML==6.*
websocket-client==1.*
opentelemetry-api~=1.21
coverage[toml]~=7.0
pytest~=7.2
typing_extensions~=4.2
Expand All @@ -144,6 +147,7 @@ passenv =
deps =
PyYAML==6.*
websocket-client==1.*
opentelemetry-api~=1.21
pytest~=7.2
pytest-benchmark~=5.0
typing_extensions~=4.2
Expand All @@ -163,6 +167,7 @@ setenv =
deps =
PyYAML==6.*
websocket-client==1.*
opentelemetry-api~=1.21
coverage[toml]~=7.0
pytest~=7.2
typing_extensions~=4.2
Expand Down

0 comments on commit 44fde41

Please sign in to comment.