Skip to content

Commit

Permalink
chore: update charm libraries (#170)
Browse files Browse the repository at this point in the history
* chore: update charm libraries

* ruff is the new black

---------

Co-authored-by: Pietro Pasotti <starfire.daemon@gmail.com>
  • Loading branch information
observability-noctua-bot and PietroPasotti authored Aug 19, 2024
1 parent 579b10c commit 87703e8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

LIBID = "e6f580481c1b4388aa4d2cdf412a47fa"
LIBAPI = 0
LIBPATCH = 5
LIBPATCH = 6

DEFAULT_RELATION_NAME = "grafana-cloud-config"

Expand Down Expand Up @@ -53,15 +53,9 @@ def __init__(self, charm, relation_name = DEFAULT_RELATION_NAME):
self.framework.observe(event, self._on_relation_broken)

def _on_relation_changed(self, event):
if not self._charm.unit.is_leader():
return

self.on.cloud_config_available.emit() # pyright: ignore

def _on_relation_broken(self, event):
if not self._charm.unit.is_leader():
return

self.on.cloud_config_revoked.emit() # pyright: ignore

def _is_not_empty(self, s):
Expand Down
17 changes: 14 additions & 3 deletions lib/charms/tempo_k8s/v1/charm_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ def _remove_stale_otel_sdk_packages():

_remove_stale_otel_sdk_packages()


import functools
import inspect
import logging
Expand Down Expand Up @@ -271,7 +270,7 @@ def _remove_stale_otel_sdk_packages():
# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version

LIBPATCH = 14
LIBPATCH = 15

PYDEPS = ["opentelemetry-exporter-otlp-proto-http==1.21.0"]

Expand All @@ -281,7 +280,6 @@ def _remove_stale_otel_sdk_packages():
# set this to 0 if you are debugging/developing this library source
dev_logger.setLevel(logging.CRITICAL)


_CharmType = Type[CharmBase] # the type CharmBase and any subclass thereof
_C = TypeVar("_C", bound=_CharmType)
_T = TypeVar("_T", bound=type)
Expand Down Expand Up @@ -333,9 +331,22 @@ def _get_tracer() -> Optional[Tracer]:
try:
return tracer.get()
except LookupError:
# fallback: this course-corrects for a user error where charm_tracing symbols are imported
# from different paths (typically charms.tempo_k8s... and lib.charms.tempo_k8s...)
try:
ctx: Context = copy_context()
if context_tracer := _get_tracer_from_context(ctx):
logger.warning(
"Tracer not found in `tracer` context var. "
"Verify that you're importing all `charm_tracing` symbols from the same module path. \n"
"For example, DO"
": `from charms.lib...charm_tracing import foo, bar`. \n"
"DONT: \n"
" \t - `from charms.lib...charm_tracing import foo` \n"
" \t - `from lib...charm_tracing import bar` \n"
"For more info: https://python-notes.curiousefficiency.org/en/latest/python"
"_concepts/import_traps.html#the-double-import-trap"
)
return context_tracer.get()
else:
return None
Expand Down

0 comments on commit 87703e8

Please sign in to comment.