Skip to content

Commit db84ba5

Browse files
authored
refactor: remove redundant pylint disable from celery instrumentation (#3839)
1 parent 1f17cc1 commit db84ba5

26 files changed

Lines changed: 28 additions & 31 deletions

File tree

.pylintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ disable=missing-docstring,
8080
missing-module-docstring, # temp-pylint-upgrade
8181
import-error, # needed as a workaround as reported here: https://github.com/open-telemetry/opentelemetry-python-contrib/issues/290
8282
cyclic-import,
83-
not-context-manager
83+
not-context-manager,
84+
attribute-defined-outside-init
8485

8586
# Enable the message, report, category or checker with the given id(s). You can
8687
# either give multiple identifier separated by comma (,) or put this option

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2121
([#4335](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4335))
2222
- Expand `AGENTS.md` with instrumentation/GenAI guidance and add PR review instructions.
2323
([#4457](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4457))
24+
- Remove redundant `pylint: disable=attribute-defined-outside-init` comments and add rule to global `.pylintrc` disable list
25+
([#3839](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3839))
2426
- `opentelemetry-exporter-richconsole`: Add support for suppressing resource information
2527
([#3898](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3898))
2628

instrumentation/opentelemetry-instrumentation-aiohttp-server/src/opentelemetry/instrumentation/aiohttp_server/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ def __init__(self, *args, **kwargs):
550550

551551

552552
class AioHttpServerInstrumentor(BaseInstrumentor):
553-
# pylint: disable=protected-access,attribute-defined-outside-init
553+
# pylint: disable=protected-access
554554
"""An instrumentor for aiohttp.web.Application
555555
556556
See `BaseInstrumentor`

instrumentation/opentelemetry-instrumentation-asyncio/src/opentelemetry/instrumentation/asyncio/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ def instrumentation_dependencies(self) -> Collection[str]:
120120
return _instruments
121121

122122
def _instrument(self, **kwargs):
123-
# pylint: disable=attribute-defined-outside-init
124123
self._tracer = get_tracer(
125124
__name__, __version__, kwargs.get("tracer_provider")
126125
)

instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,9 +465,10 @@ def _instrument(self, **kwargs):
465465
)
466466
)
467467
return
468-
# pylint: disable=attribute-defined-outside-init
468+
469469
# Convert slash-delimited paths to dot-delimited for valid Python imports
470470
lambda_handler = lambda_handler.replace("/", ".")
471+
471472
(
472473
self._wrapped_module_name,
473474
self._wrapped_function_name,

instrumentation/opentelemetry-instrumentation-boto3sqs/src/opentelemetry/instrumentation/boto3sqs/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ def set(self, carrier: CarrierT, key: str, value: str) -> None:
8282
boto3sqs_setter = Boto3SQSSetter()
8383

8484

85-
# pylint: disable=attribute-defined-outside-init
8685
class Boto3SQSInstrumentor(BaseInstrumentor):
8786
received_messages_spans: Dict[str, Span] = {}
8887
current_span_related_to_token: Span = None
@@ -177,7 +176,7 @@ def _safe_end_processing_span(receipt_handle: str) -> None:
177176
@staticmethod
178177
def _extract_queue_name_from_url(queue_url: str) -> str:
179178
# A Queue name cannot have the `/` char, therefore we can return the part after the last /
180-
return queue_url.split("/")[-1]
179+
return queue_url.rsplit("/", maxsplit=1)[-1]
181180

182181
def _create_processing_span(
183182
self,

instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ def response_hook(span, service_name, operation_name, result):
140140
suppress_http_instrumentation,
141141
unwrap,
142142
)
143+
from opentelemetry.metrics import Instrument
143144
from opentelemetry.propagators.aws.aws_xray_propagator import (
144145
TRACE_HEADER_KEY,
145146
AwsXRayPropagator,
@@ -181,7 +182,15 @@ def instrumentation_dependencies(self) -> Collection[str]:
181182
return _instruments_botocore
182183

183184
def _instrument(self, **kwargs):
184-
# pylint: disable=attribute-defined-outside-init
185+
# tracers are lazy initialized per-extension in _get_tracer
186+
self._tracers = {}
187+
# loggers are lazy initialized per-extension in _get_logger
188+
self._loggers = {}
189+
# meters are lazy initialized per-extension in _get_meter
190+
self._meters = {}
191+
# metrics are lazy initialized per-extension in _get_metrics
192+
self._metrics: Dict[str, Dict[str, Instrument]] = {}
193+
185194
self.request_hook = kwargs.get("request_hook")
186195
self.response_hook = kwargs.get("response_hook")
187196

instrumentation/opentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/extensions/bedrock.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,6 @@ def before_service_call(
460460
span.update_name(f"{operation_name} {request_model}")
461461

462462
# this is used to calculate the operation duration metric, duration may be skewed by request_hook
463-
# pylint: disable=attribute-defined-outside-init
464463
self._operation_start = default_timer()
465464

466465
# pylint: disable=no-self-use,too-many-locals

instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ def instrumentation_dependencies(self) -> Collection[str]:
124124
def _instrument(self, **kwargs):
125125
tracer_provider = kwargs.get("tracer_provider")
126126

127-
# pylint: disable=attribute-defined-outside-init
128127
self._tracer = trace.get_tracer(
129128
__name__,
130129
__version__,

instrumentation/opentelemetry-instrumentation-confluent-kafka/src/opentelemetry/instrumentation/confluent_kafka/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ class ConfluentKafkaInstrumentor(BaseInstrumentor):
219219
See `BaseInstrumentor`
220220
"""
221221

222-
# pylint: disable=attribute-defined-outside-init
223222
@staticmethod
224223
def instrument_producer(
225224
producer: Producer, tracer_provider=None

0 commit comments

Comments
 (0)