Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
# -- Project information -----------------------------------------------------

project = "OpenTelemetry Python"
copyright = "OpenTelemetry Authors" # pylint: disable=redefined-builtin
_copyright = "OpenTelemetry Authors" # pylint: disable=redefined-builtin
author = "OpenTelemetry Authors"


Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-api/src/opentelemetry/baggage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ def _is_valid_value(value: object) -> bool:
parts = str(value).split(";")
is_valid_value = _VALUE_PATTERN.fullmatch(parts[0]) is not None
if len(parts) > 1: # one or more properties metadata
for property in parts[1:]:
if _PROPERT_PATTERN.fullmatch(property) is None:
for _property in parts[1:]:
if _PROPERT_PATTERN.fullmatch(_property) is None:
is_valid_value = False
break
return is_valid_value
Expand Down
25 changes: 15 additions & 10 deletions opentelemetry-sdk/tests/metrics/test_exemplarfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,23 @@

class TestAlwaysOnExemplarFilter(TestCase):
def test_should_sample(self):
filter = AlwaysOnExemplarFilter()
self.assertTrue(filter.should_sample(10, 0, {}, Context()))
self.assertTrue(
AlwaysOnExemplarFilter().should_sample(10, 0, {}, Context())
)


class TestAlwaysOffExemplarFilter(TestCase):
def test_should_sample(self):
filter = AlwaysOffExemplarFilter()
self.assertFalse(filter.should_sample(10, 0, {}, Context()))
self.assertFalse(
AlwaysOffExemplarFilter().should_sample(10, 0, {}, Context())
)


class TestTraceBasedExemplarFilter(TestCase):
TRACE_ID = int("d4cda95b652f4a1592b449d5929fda1b", 16)
SPAN_ID = int("6e0c63257de34c92", 16)

def test_should_not_sample_without_trace(self):
filter = TraceBasedExemplarFilter()
span_context = SpanContext(
trace_id=self.TRACE_ID,
span_id=self.SPAN_ID,
Expand All @@ -38,14 +39,16 @@ def test_should_not_sample_without_trace(self):
)
span = trace.NonRecordingSpan(span_context)
ctx = trace.set_span_in_context(span)
self.assertFalse(filter.should_sample(10, 0, {}, ctx))
self.assertFalse(
TraceBasedExemplarFilter().should_sample(10, 0, {}, ctx)
)

def test_should_not_sample_with_invalid_span(self):
filter = TraceBasedExemplarFilter()
self.assertFalse(filter.should_sample(10, 0, {}, Context()))
self.assertFalse(
TraceBasedExemplarFilter().should_sample(10, 0, {}, Context())
)

def test_should_sample_when_trace_is_sampled(self):
filter = TraceBasedExemplarFilter()
span_context = SpanContext(
trace_id=self.TRACE_ID,
span_id=self.SPAN_ID,
Expand All @@ -55,4 +58,6 @@ def test_should_sample_when_trace_is_sampled(self):
)
span = trace.NonRecordingSpan(span_context)
ctx = trace.set_span_in_context(span)
self.assertTrue(filter.should_sample(10, 0, {}, ctx))
self.assertTrue(
TraceBasedExemplarFilter().should_sample(10, 0, {}, ctx)
)
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ select = [
"PLC", # pylint convention
"PLE", # pylint error
"Q", # flake8-quotes
"A", # flake8-builtins
]

ignore = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ def start_span(
context = SpanContextShim(span.get_span_context())
return SpanShim(self, context, span)

def inject(self, span_context, format: object, carrier: object):
def inject(self, span_context, _format: object, carrier: object):
"""Injects ``span_context`` into ``carrier``.

See base class for more details.
Expand All @@ -703,7 +703,7 @@ def inject(self, span_context, format: object, carrier: object):
# TODO: Support Format.BINARY once it is supported in
# opentelemetry-python.

if format not in self._supported_formats:
if _format not in self._supported_formats:
raise UnsupportedFormatException

propagator = get_global_textmap()
Expand All @@ -715,7 +715,7 @@ def inject(self, span_context, format: object, carrier: object):
ctx = set_span_in_context(span)
propagator.inject(carrier, context=ctx)

def extract(self, format: object, carrier: object):
def extract(self, _format: object, carrier: object):
"""Returns an ``opentracing.SpanContext`` instance extracted from a
``carrier``.

Expand All @@ -737,7 +737,7 @@ def extract(self, format: object, carrier: object):
# uses the configured propagators in opentelemetry.propagators.
# TODO: Support Format.BINARY once it is supported in
# opentelemetry-python.
if format not in self._supported_formats:
if _format not in self._supported_formats:
raise UnsupportedFormatException

propagator = get_global_textmap()
Expand Down