Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanthccv committed Nov 20, 2023
1 parent ec397e5 commit 1987535
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 26 deletions.
20 changes: 12 additions & 8 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
pylint==3.0.2
flake8~=3.7
isort~=5.8
black~=22.3.0
httpretty~=1.0
flake8==6.1.0
isort==5.12.0
black==22.3.0
httpretty==1.1.4
mypy==0.931
sphinx~=7.1
sphinx==7.1.2
sphinx-rtd-theme==2.0.0rc4
sphinx-autodoc-typehints~=1.25
sphinx-autodoc-typehints==1.25.2
pytest==7.1.3
pytest-cov~=4.1
readme-renderer~=24.0
pytest-cov==4.1.0
readme-renderer==42.0
# temporary fix. we should update the jinja, flask deps
# See https://github.com/pallets/markupsafe/issues/282
# breaking change introduced in markupsafe causes jinja, flask to break
Expand All @@ -18,3 +18,7 @@ bleach==4.1.0 # This dependency was updated to a breaking version.
codespell==2.1.0
requests==2.31.0
ruamel.yaml==0.17.21
asgiref==3.7.2
psutil==5.9.6
GitPython==3.1.40
flaky==3.7.0
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ dependencies = [
"backoff >= 1.10.0, < 3.0.0; python_version>='3.7'",
]

[project.optional-dependencies]
test = []

[project.urls]
Homepage = "https://github.com/open-telemetry/opentelemetry-python/tree/main/exporter/opentelemetry-exporter-otlp-proto-common"

Expand Down
3 changes: 3 additions & 0 deletions exporter/opentelemetry-exporter-otlp/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ dependencies = [
"opentelemetry-exporter-otlp-proto-http == 1.22.0.dev",
]

[project.optional-dependencies]
test = []

[project.entry-points.opentelemetry_logs_exporter]
otlp = "opentelemetry.exporter.otlp.proto.grpc._log_exporter:OTLPLogExporter"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_no_traceparent_header(self):
If no traceparent header is received, the vendor creates a new
trace-id and parent-id that represents the current request.
"""
output = {} # type:typing.Dict[str, typing.List[str]]
output: typing.Dict[str, typing.List[str]] = {}
span = trace.get_current_span(FORMAT.extract(output))
self.assertIsInstance(span.get_span_context(), trace.SpanContext)

Expand All @@ -66,7 +66,7 @@ def test_headers_with_tracestate(self):
span_context.trace_state, {"foo": "1", "bar": "2", "baz": "3"}
)
self.assertTrue(span_context.is_remote)
output = {} # type:typing.Dict[str, str]
output: typing.Dict[str, str] = {}
span = trace.NonRecordingSpan(span_context)

ctx = trace.set_span_in_context(span)
Expand Down Expand Up @@ -145,7 +145,7 @@ def test_no_send_empty_tracestate(self):
Empty and whitespace-only list members are allowed. Vendors MUST accept
empty tracestate headers but SHOULD avoid sending them.
"""
output = {} # type:typing.Dict[str, str]
output: typing.Dict[str, str] = {}
span = trace.NonRecordingSpan(
trace.SpanContext(self.TRACE_ID, self.SPAN_ID, is_remote=False)
)
Expand Down Expand Up @@ -177,7 +177,7 @@ def test_format_not_supported(self):

def test_propagate_invalid_context(self):
"""Do not propagate invalid trace context."""
output = {} # type:typing.Dict[str, str]
output: typing.Dict[str, str] = {}
ctx = trace.set_span_in_context(trace.INVALID_SPAN)
FORMAT.inject(output, context=ctx)
self.assertFalse("traceparent" in output)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ class BatchLogRecordProcessor(LogRecordProcessor):
- :envvar:`OTEL_BLRP_EXPORT_TIMEOUT`
"""

_queue: Deque[LogData]
_flush_request: Optional[_FlushRequest]
_log_records: List[Optional[LogData]]

def __init__(
self,
exporter: LogExporter,
Expand Down Expand Up @@ -201,20 +205,16 @@ def __init__(
self._schedule_delay_millis = schedule_delay_millis
self._max_export_batch_size = max_export_batch_size
self._export_timeout_millis = export_timeout_millis
self._queue = collections.deque(
[], max_queue_size
) # type: Deque[LogData]
self._queue = collections.deque([], max_queue_size)
self._worker_thread = threading.Thread(
name="OtelBatchLogRecordProcessor",
target=self.worker,
daemon=True,
)
self._condition = threading.Condition(threading.Lock())
self._shutdown = False
self._flush_request = None # type: Optional[_FlushRequest]
self._log_records = [
None
] * self._max_export_batch_size # type: List[Optional[LogData]]
self._flush_request = None
self._log_records = [None] * self._max_export_batch_size
self._worker_thread.start()
# Only available in *nix since py37.
if hasattr(os, "register_at_fork"):
Expand All @@ -236,7 +236,7 @@ def _at_fork_reinit(self):

def worker(self):
timeout = self._schedule_delay_millis / 1e3
flush_request = None # type: Optional[_FlushRequest]
flush_request: Optional[_FlushRequest] = None
while not self._shutdown:
with self._condition:
if self._shutdown:
Expand Down
4 changes: 3 additions & 1 deletion opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,12 @@ class SynchronousMultiSpanProcessor(SpanProcessor):
added.
"""

_span_processors: Tuple[SpanProcessor, ...]

def __init__(self):
# use a tuple to avoid race conditions when adding a new span and
# iterating through it on "on_start" and "on_end".
self._span_processors = () # type: Tuple[SpanProcessor, ...]
self._span_processors = ()
self._lock = threading.Lock()

def add_span_processor(self, span_processor: SpanProcessor) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ def is_data_points_equal(
data_point: DataPointT,
est_value_delta: Optional[float] = 0,
):
if type(expected_data_point) != type(data_point) or not isinstance(
if type(expected_data_point) != type( # noqa: E721
data_point
) or not isinstance(
expected_data_point, (HistogramDataPoint, NumberDataPoint)
):
return False
Expand Down
4 changes: 0 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,6 @@ basepython: python3
recreate = True
deps =
-r dev-requirements.txt
asgiref~=3.7
psutil~=5.9
GitPython==3.1.40
flaky~=3.7

commands_pre =
python -m pip install -e {toxinidir}/opentelemetry-api[test]
Expand Down

0 comments on commit 1987535

Please sign in to comment.