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
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def get_contrib_job_datas(tox_envs: list) -> list:

contrib_job_datas.append(
{
"ui_name": (f"{groups['name']}" f"{contrib_requirements}"),
"ui_name": (f"{groups['name']}{contrib_requirements}"),
"tox_env": tox_env,
}
)
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.6.9
rev: v0.14.1
hooks:
# Run the linter.
- id: ruff
Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `opentelemetry-instrumentation-aiohttp-server`: delay initialization of tracer, meter and excluded urls to instrumentation for testability
([#3836](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3836))
- `opentelemetry-instrumentation-elasticsearch`: Enhance elasticsearch query body sanitization
([#3919](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3919))
([#3919](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3919))
- build: bump ruff to 0.14.1
([#3842](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3842))


## Version 1.38.0/0.59b0 (2025-10-16)
Expand Down
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ ruamel.yaml==0.17.21
flaky==3.7.0
pre-commit==3.7.0; python_version >= '3.9'
pre-commit==3.5.0; python_version < '3.9'
ruff==0.6.9
ruff==0.14.1
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ def test_parse_metric(metric, prom_rw):
"bool_value": True,
}

assert (
len(metric.data.data_points) == 1
), "We can only support a single datapoint in tests"
assert len(metric.data.data_points) == 1, (
"We can only support a single datapoint in tests"
)
series = prom_rw._parse_metric(metric, tuple(attributes.items()))
timestamp = metric.data.data_points[0].time_unix_nano // 1_000_000
for single_series in series:
Expand Down
2 changes: 1 addition & 1 deletion gen-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
astor==0.8.1
jinja2==3.1.6
markupsafe==2.0.1
ruff==0.6.9
ruff==0.14.1
requests
tomli
tomli_w
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ def get_span_named(self, name):
def assert_has_span_named(self, name):
span = self.get_span_named(name)
finished_spans = [span.name for span in self.get_finished_spans()]
assert (
span is not None
), f'Could not find span named "{name}"; finished spans: {finished_spans}'
assert span is not None, (
f'Could not find span named "{name}"; finished spans: {finished_spans}'
)

def assert_does_not_have_span_named(self, name):
span = self.get_span_named(name)
Expand All @@ -192,9 +192,9 @@ def get_events_named(self, event_name):
def assert_has_event_named(self, name):
event = self.get_event_named(name)
finished_logs = self.get_finished_logs()
assert (
event is not None
), f'Could not find event named "{name}"; finished logs: {finished_logs}'
assert event is not None, (
f'Could not find event named "{name}"; finished logs: {finished_logs}'
)

def assert_does_not_have_event_named(self, name):
event = self.get_event_named(name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def _instrument(self, **kwargs):
)

def _uninstrument(self, **kwargs):
import openai # pylint: disable=import-outside-toplevel
import openai # pylint: disable=import-outside-toplevel # noqa: PLC0415

unwrap(openai.resources.chat.completions.Completions, "create")
unwrap(openai.resources.chat.completions.AsyncCompletions, "create")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ def _methods_to_wrap(
):
# This import is very slow, do it lazily in case instrument() is not called
# pylint: disable=import-outside-toplevel
from google.cloud.aiplatform_v1.services.prediction_service import (
from google.cloud.aiplatform_v1.services.prediction_service import ( # noqa: PLC0415
async_client,
client,
)
from google.cloud.aiplatform_v1beta1.services.prediction_service import (
from google.cloud.aiplatform_v1beta1.services.prediction_service import ( # noqa: PLC0415
async_client as async_client_v1beta1,
)
from google.cloud.aiplatform_v1beta1.services.prediction_service import (
from google.cloud.aiplatform_v1beta1.services.prediction_service import ( # noqa: PLC0415
client as client_v1beta1,
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import pytest
from tests.shared_test_utils import (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these should be imported from .shared_test_utils import

ask_about_weather,
ask_about_weather_function_response,
)

from opentelemetry.instrumentation.vertexai import VertexAIInstrumentor
from opentelemetry.sdk._logs._internal.export.in_memory_log_exporter import (
Expand All @@ -7,10 +11,6 @@
from opentelemetry.sdk.trace.export.in_memory_span_exporter import (
InMemorySpanExporter,
)
from tests.shared_test_utils import (
ask_about_weather,
ask_about_weather_function_response,
)


@pytest.mark.vcr()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

import fsspec
import pytest
from tests.shared_test_utils import (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

ask_about_weather,
ask_about_weather_function_response,
)

from opentelemetry.instrumentation.vertexai import VertexAIInstrumentor
from opentelemetry.sdk._logs._internal.export.in_memory_log_exporter import (
Expand All @@ -12,10 +16,6 @@
from opentelemetry.sdk.trace.export.in_memory_span_exporter import (
InMemorySpanExporter,
)
from tests.shared_test_utils import (
ask_about_weather,
ask_about_weather_function_response,
)


def test_function_call_choice(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,9 @@ async def command1() -> None:
async def command2() -> None:
pass

async def run_both() -> (
tuple[asyncclick.testing.Result, asyncclick.testing.Result]
):
async def run_both() -> tuple[
asyncclick.testing.Result, asyncclick.testing.Result
]:
runner = CliRunner()
task1 = asyncio.create_task(runner.invoke(command1))
task2 = asyncio.create_task(runner.invoke(command2))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,9 @@ def remove_none_values(body):

def assert_log_parent(log, span):
if span:
assert (
log.log_record.trace_id == span.get_span_context().trace_id
), f"{span.get_span_context().trace_id} does not equal {log.log_record.trace_id}"
assert log.log_record.trace_id == span.get_span_context().trace_id, (
f"{span.get_span_context().trace_id} does not equal {log.log_record.trace_id}"
)
assert log.log_record.span_id == span.get_span_context().span_id
assert (
log.log_record.trace_flags == span.get_span_context().trace_flags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@ def test_fastapi_unhandled_exception(self):
"""If the application has an unhandled error the instrumentation should capture that a 500 response is returned."""
try:
resp = self._client.get("/error")
assert (
resp.status_code == 500
), resp.content # pragma: no cover, for debugging this test if an exception is _not_ raised
assert resp.status_code == 500, (
resp.content
) # pragma: no cover, for debugging this test if an exception is _not_ raised
except UnhandledException:
pass
else:
Expand Down Expand Up @@ -2442,9 +2442,9 @@ def test_fastapi_unhandled_exception_both_semconv(self):
"""If the application has an unhandled error the instrumentation should capture that a 500 response is returned."""
try:
resp = self._client.get("/error")
assert (
resp.status_code == 500
), resp.content # pragma: no cover, for debugging this test if an exception is _not_ raised
assert resp.status_code == 500, (
resp.content
) # pragma: no cover, for debugging this test if an exception is _not_ raised
except UnhandledException:
pass
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ def response_hook_test(span, environ, response_headers):
request_hook=request_hook_test, response_hook=response_hook_test
)
# pylint: disable=import-outside-toplevel,reimported,redefined-outer-name
from flask import Flask
from flask import Flask # noqa: PLC0415

self.app = Flask(__name__)

Expand Down Expand Up @@ -949,7 +949,7 @@ def setUp(self):

FlaskInstrumentor().instrument(tracer_provider=tracer_provider)
# pylint: disable=import-outside-toplevel,reimported,redefined-outer-name
from flask import Flask
from flask import Flask # noqa: PLC0415

self.app = Flask(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ def client_interceptor(
Returns:
An invocation-side interceptor object.
"""
from . import _client
from . import _client # noqa: PLC0415

tracer = trace.get_tracer(
__name__,
Expand Down Expand Up @@ -614,7 +614,7 @@ def server_interceptor(tracer_provider=None, filter_=None):
Returns:
A service-side interceptor object.
"""
from . import _server
from . import _server # noqa: PLC0415

tracer = trace.get_tracer(
__name__,
Expand All @@ -637,7 +637,7 @@ def aio_client_interceptors(
Returns:
An invocation-side interceptor object.
"""
from . import _aio_client
from . import _aio_client # noqa: PLC0415

tracer = trace.get_tracer(
__name__,
Expand Down Expand Up @@ -683,7 +683,7 @@ def aio_server_interceptor(tracer_provider=None, filter_=None):
Returns:
A service-side interceptor object.
"""
from . import _aio_server
from . import _aio_server # noqa: PLC0415

tracer = trace.get_tracer(
__name__,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def intercept_channel(channel, *interceptors):
TypeError: If an interceptor derives from neither UnaryClientInterceptor
nor StreamClientInterceptor.
"""
from . import _interceptor
from . import _interceptor # noqa: PLC0415

return _interceptor.intercept_channel(channel, *interceptors)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ def test_instrument_api(self) -> None:
_QueueConsumerGeneratorInfo.__init__, BoundFunctionWrapper
)
)
assert hasattr(
instrumentation, "__opentelemetry_tracer_provider"
), "Tracer not stored for the object!"
assert hasattr(instrumentation, "__opentelemetry_tracer_provider"), (
"Tracer not stored for the object!"
)
instrumentation.uninstrument()
self.assertFalse(
isinstance(BlockingConnection.channel, BoundFunctionWrapper)
Expand Down Expand Up @@ -115,9 +115,9 @@ def test_instrument_channel(
instrument_channel_functions: mock.MagicMock,
):
PikaInstrumentor.instrument_channel(channel=self.channel)
assert hasattr(
self.channel, "_is_instrumented_by_opentelemetry"
), "channel is not marked as instrumented!"
assert hasattr(self.channel, "_is_instrumented_by_opentelemetry"), (
"channel is not marked as instrumented!"
)
instrument_channel_consumers.assert_called_once()
instrument_basic_consume.assert_called_once()
instrument_channel_functions.assert_called_once()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ def make_client(self, *mock_socket_values, **kwargs):
current_port = TEST_PORT

# pylint: disable=import-outside-toplevel
from pymemcache.client.hash import HashClient
from pymemcache.client.hash import HashClient # noqa: PLC0415

# pylint: disable=attribute-defined-outside-init
self.client = HashClient([], **kwargs)
Expand Down
Loading