From 74d6450f8f577168148dd40aadcf2991303d9a31 Mon Sep 17 00:00:00 2001 From: Shayan Patel Date: Thu, 6 Jun 2024 11:59:17 +0000 Subject: [PATCH] Update charm tracing lib to v1.7 --- lib/charms/tempo_k8s/v1/charm_tracing.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/charms/tempo_k8s/v1/charm_tracing.py b/lib/charms/tempo_k8s/v1/charm_tracing.py index 7c118856a..9549ff346 100644 --- a/lib/charms/tempo_k8s/v1/charm_tracing.py +++ b/lib/charms/tempo_k8s/v1/charm_tracing.py @@ -147,7 +147,7 @@ def my_tracing_endpoint(self) -> Optional[str]: # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 6 +LIBPATCH = 7 PYDEPS = ["opentelemetry-exporter-otlp-proto-http==1.21.0"] @@ -540,11 +540,13 @@ def wrapped_function(*args, **kwargs): # type: ignore name = getattr(callable, "__qualname__", getattr(callable, "__name__", str(callable))) with _span(f"{'(static) ' if static else ''}{qualifier} call: {name}"): # type: ignore if static: - # fixme: do we or don't we need [1:]? - # The _trace_callable decorator doesn't always play nice with @staticmethods. - # Sometimes it will receive 'self', sometimes it won't. - # return callable(*args, **kwargs) # type: ignore - return callable(*args[1:], **kwargs) # type: ignore + # The _trace_callable decorator doesn't play super nice with @staticmethods. + # if you call MyObj().mystaticmethod we'll receive the MyObj instance as first argument, + # if you call MyObj.mystaticmethod we won't. + try: + inspect.signature(callable).bind(*args, **kwargs) + except TypeError: + return callable(*args[1:], **kwargs) # type: ignore return callable(*args, **kwargs) # type: ignore # wrapped_function.__signature__ = sig