Skip to content

Commit 4853f4b

Browse files
refactor: Remove dead code
Signed-off-by: Fabrizio Demaria <fabrizio.f.demaria@gmail.com>
1 parent 02dc4b0 commit 4853f4b

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

confidence/telemetry.py

+4-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import base64
22
from queue import Queue
3-
from typing import Optional, TypeVar, cast
3+
from typing import Optional, cast
44
from typing_extensions import TypeAlias
55

66
from confidence.telemetry_pb2 import (
@@ -15,15 +15,12 @@
1515
ProtoTraceId: TypeAlias = ProtoLibraryTraces.ProtoTraceId
1616
ProtoStatus: TypeAlias = ProtoLibraryTraces.ProtoTrace.ProtoRequestTrace.ProtoStatus
1717

18-
T = TypeVar("T")
19-
QueueType = Queue
20-
2118

2219
class Telemetry:
2320
_instance: Optional["Telemetry"] = None
2421
_initialized: bool = False
2522
version: str
26-
_traces_queue: "QueueType[ProtoTrace]"
23+
_traces_queue: Queue[ProtoTrace]
2724
_disabled: bool
2825

2926
def __new__(cls, version: str, disabled: bool = False) -> "Telemetry":
@@ -36,7 +33,7 @@ def __new__(cls, version: str, disabled: bool = False) -> "Telemetry":
3633
def __init__(self, version: str, disabled: bool = False) -> None:
3734
if not self._initialized:
3835
self.version = version
39-
self._traces_queue = cast("QueueType[ProtoTrace]", Queue())
36+
self._traces_queue = Queue()
4037
self._disabled = disabled
4138
self._initialized = True
4239

@@ -56,23 +53,19 @@ def add_trace(
5653
def get_monitoring_header(self) -> str:
5754
if self._disabled:
5855
return ""
59-
# Get all current traces atomically
6056
current_traces = []
6157
while not self._traces_queue.empty():
6258
try:
6359
current_traces.append(self._traces_queue.get_nowait())
64-
except Exception: # Specify the exception type
60+
except Exception:
6561
break
6662

67-
# Create monitoring data with the captured traces
6863
monitoring = ProtoMonitoring()
6964
library_traces = monitoring.library_traces.add()
7065
library_traces.library = ProtoLibrary.PROTO_LIBRARY_CONFIDENCE
7166
library_traces.library_version = self.version
7267
library_traces.traces.extend(current_traces)
7368
monitoring.platform = ProtoPlatform.PROTO_PLATFORM_PYTHON
74-
75-
# Serialize to protobuf and base64 encode
7669
serialized = monitoring.SerializeToString()
7770
encoded = base64.b64encode(serialized).decode()
7871
return encoded

0 commit comments

Comments
 (0)