Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update charm libraries #531

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions lib/charms/tempo_k8s/v0/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,17 @@ def __init__(self, *args):
""" # noqa: W505
import json
import logging
from typing import TYPE_CHECKING, List, Literal, MutableMapping, Optional, Tuple, cast
from typing import (
TYPE_CHECKING,
Any,
Dict,
List,
Literal,
MutableMapping,
Optional,
Tuple,
cast,
)

import pydantic
from ops.charm import (
Expand All @@ -83,7 +93,7 @@ def __init__(self, *args):

# 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 = ["pydantic<2.0"]

Expand Down Expand Up @@ -457,7 +467,7 @@ def relations(self) -> List[Relation]:
return self._charm.model.relations[self._relation_name]

@property
def _relation(self) -> Relation:
def _relation(self) -> Optional[Relation]:
"""If this wraps a single endpoint, the relation bound to it, if any."""
if not self._is_single_endpoint:
objname = type(self).__name__
Expand All @@ -474,7 +484,7 @@ def is_ready(self, relation: Optional[Relation] = None):
"""Is this endpoint ready?"""
relation = relation or self._relation
if not relation:
logger.error(f"no relation on {self._relation_name}: tracing not ready")
logger.debug(f"no relation on {self._relation_name !r}: tracing not ready")
return False
if relation.data is None:
logger.error(f"relation data is None for {relation}")
Expand Down Expand Up @@ -502,7 +512,7 @@ def _on_tracing_relation_changed(self, event):
def _on_tracing_relation_broken(self, event: RelationBrokenEvent):
"""Notify the providers that the endpoint is broken."""
relation = event.relation
self.on.endpoint_removed.emit(relation)
self.on.endpoint_removed.emit(relation) # type: ignore

def get_all_endpoints(
self, relation: Optional[Relation] = None
Expand All @@ -512,7 +522,7 @@ def get_all_endpoints(
return
return TracingProviderAppData.load(relation.data[relation.app]) # type: ignore

def _get_ingester(self, relation: Relation, protocol: IngesterProtocol):
def _get_ingester(self, relation: Optional[Relation], protocol: IngesterProtocol):
ep = self.get_all_endpoints(relation)
if not ep:
return None
Expand All @@ -539,12 +549,10 @@ def tempo_endpoint(self, relation: Optional[Relation] = None) -> Optional[str]:
"""Ingester endpoint for the ``tempo`` protocol."""
return self._get_ingester(relation or self._relation, protocol="tempo")

@property
def jaeger_http_thrift_endpoint(self) -> Optional[str]:
def jaeger_http_thrift_endpoint(self, relation: Optional[Relation] = None) -> Optional[str]:
"""Ingester endpoint for the ``jaeger_http_thrift`` protocol."""
return self._get_ingester("jaeger_http_thrift")
return self._get_ingester(relation or self._relation, "jaeger_http_thrift")

@property
def jaeger_grpc_endpoint(self) -> Optional[str]:
def jaeger_grpc_endpoint(self, relation: Optional[Relation] = None) -> Optional[str]:
"""Ingester endpoint for the ``jaeger_grpc`` protocol."""
return self._get_ingester("jaeger_grpc")
return self._get_ingester(relation or self._relation, "jaeger_grpc")