Skip to content

Commit

Permalink
chore: make tracer a private member
Browse files Browse the repository at this point in the history
  • Loading branch information
jjaakola-aiven committed Dec 20, 2024
1 parent d945983 commit f3fbb70
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/karapace/coordinator/master_coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self, config: Config) -> None:
self._thread: Thread = Thread(target=self._start_loop, daemon=True)
self._loop: asyncio.AbstractEventLoop | None = None
self._schema_reader_stopper: SchemaReaderStoppper | None = None
self.tracer = Tracer()
self._tracer = Tracer()

def set_stoppper(self, schema_reader_stopper: SchemaReaderStoppper) -> None:
self._schema_reader_stopper = schema_reader_stopper
Expand Down Expand Up @@ -149,8 +149,8 @@ def init_schema_coordinator(self) -> SchemaCoordinator:
return schema_coordinator

def get_coordinator_status(self) -> SchemaCoordinatorStatus:
with self.tracer.get_tracer().start_as_current_span(
self.tracer.get_name_from_caller_with_class(self, self.get_coordinator_status)
with self._tracer.get_tracer().start_as_current_span(
self._tracer.get_name_from_caller_with_class(self, self.get_coordinator_status)
):
assert self._sc is not None
generation = self._sc.generation if self._sc is not None else OffsetCommitRequest.DEFAULT_GENERATION_ID
Expand Down
6 changes: 3 additions & 3 deletions src/karapace/kafka/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(
bootstrap_servers: Iterable[str] | str,
**params: Unpack[KafkaClientParams],
) -> None:
self.tracer = Tracer()
self._tracer = Tracer()
super().__init__(bootstrap_servers, **params)

def new_topic(
Expand Down Expand Up @@ -188,7 +188,7 @@ def get_offsets(self, topic: str, partition_id: int) -> dict[str, int]:
return {"beginning_offset": startoffset.offset, "end_offset": endoffset.offset}

def describe_topics(self, topics: TopicCollection) -> dict[str, Future]:
with self.tracer.get_tracer().start_as_current_span(
self.tracer.get_name_from_caller_with_class(self, self.describe_topics)
with self._tracer.get_tracer().start_as_current_span(
self._tracer.get_name_from_caller_with_class(self, self.describe_topics)
):
return super().describe_topics(topics)
6 changes: 3 additions & 3 deletions src/karapace/offset_watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ def __init__(self) -> None:
# be performed with this condition acquired
self._condition = Condition()
self._greatest_offset = -1 # Would fail if initially this is 0 as it will be first offset ever.
self.tracer = Tracer()
self._tracer = Tracer()

def greatest_offset(self) -> int:
with self.tracer.get_tracer().start_as_current_span(
self.tracer.get_name_from_caller_with_class(self, self.greatest_offset)
with self._tracer.get_tracer().start_as_current_span(
self._tracer.get_name_from_caller_with_class(self, self.greatest_offset)
):
return self._greatest_offset

Expand Down
14 changes: 7 additions & 7 deletions src/schema_registry/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def __init__(
self._offset_watcher = offset_watcher
self.stats = StatsClient(config=config)
self.kafka_error_handler: KafkaErrorHandler = KafkaErrorHandler(config=config)
self.tracer = Tracer()
self._tracer = Tracer()

# Thread synchronization objects
# - offset is used by the REST API to wait until this thread has
Expand Down Expand Up @@ -278,8 +278,8 @@ def run(self) -> None:
LOG.warning("Unexpected exception in schema reader loop - %s", e)

async def is_healthy(self) -> bool:
with self.tracer.get_tracer().start_as_current_span(
self.tracer.get_name_from_caller_with_class(self, self.is_healthy)
with self._tracer.get_tracer().start_as_current_span(
self._tracer.get_name_from_caller_with_class(self, self.is_healthy)
):
if (
self.consecutive_unexpected_errors >= UNHEALTHY_CONSECUTIVE_ERRORS
Expand Down Expand Up @@ -374,14 +374,14 @@ def _is_ready(self) -> bool:
return ready

def highest_offset(self) -> int:
with self.tracer.get_tracer().start_as_current_span(
self.tracer.get_name_from_caller_with_class(self, self.highest_offset)
with self._tracer.get_tracer().start_as_current_span(
self._tracer.get_name_from_caller_with_class(self, self.highest_offset)
):
return max(self._highest_offset, self._offset_watcher.greatest_offset())

def ready(self) -> bool:
with self.tracer.get_tracer().start_as_current_span(
self.tracer.get_name_from_caller_with_class(self, self.ready)
with self._tracer.get_tracer().start_as_current_span(
self._tracer.get_name_from_caller_with_class(self, self.ready)
) as span:
span.add_event("Acquiring ready lock")
with self._ready_lock:
Expand Down
2 changes: 1 addition & 1 deletion src/schema_registry/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class KarapaceSchemaRegistry:
def __init__(self, config: Config) -> None:
# TODO: compatibility was previously in mutable dict, fix the runtime config to be distinct from static config.
self.config = config
self.tracer = Tracer()
self._tracer = Tracer()
self._key_formatter = KeyFormatter()

offset_watcher = OffsetWatcher()
Expand Down

0 comments on commit f3fbb70

Please sign in to comment.