Skip to content

Commit 78874df

Browse files
Fix install of Python 3.10 on GitHub Actions (#1609)
* Fix install of Python 3.10 on GitHub Actions In PR #1604 the Python version was upgraded to Python 3.10 to fix a local issue on M1 MacBooks. The GitHub Action workflows now exit with the following message for the docker-tests, spellcheck and lint checks, skipping these checks. ``` lint create: /home/runner/work/opentelemetry-python-contrib/opentelemetry-python-contrib/.tox/lint SKIPPED: InterpreterNotFound: python3.10 ___________________________________ summary ____________________________________ SKIPPED: lint: InterpreterNotFound: python3.10 congratulations :) ``` Upgrade the Python version in the GitHub Actions workflow to fix this. * Fix YAML interpretation of Python 3.10 * Upgrade Docker tests dependencies Upgrade the asyncpg and psycopg2 packages, they don't work on Python 3.10. This also fixes running these tests no M1 MacBooks. * Fix linter issues merged into main They went unnoticed while the CI didn't fail on the lint task not working. --------- Co-authored-by: Srikanth Chekuri <[email protected]>
1 parent d8788b6 commit 78874df

File tree

50 files changed

+36
-89
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+36
-89
lines changed

.github/workflows/test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ jobs:
102102
steps:
103103
- name: Checkout Contrib Repo @ SHA - ${{ github.sha }}
104104
uses: actions/checkout@v2
105-
- name: Set up Python 3.9
105+
- name: Set up Python 3.10
106106
uses: actions/setup-python@v2
107107
with:
108-
python-version: 3.9
108+
python-version: "3.10"
109109
- name: Install tox
110110
run: pip install tox==3.27.1
111111
- name: Install libsnappy-dev

exporter/opentelemetry-exporter-prometheus-remote-write/example/sampleapp.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
# Callback to gather cpu usage
4848
def get_cpu_usage_callback(observer):
49-
for (number, percent) in enumerate(psutil.cpu_percent(percpu=True)):
49+
for number, percent in enumerate(psutil.cpu_percent(percpu=True)):
5050
labels = {"cpu_number": str(number)}
5151
yield Observation(percent, labels)
5252

exporter/opentelemetry-exporter-prometheus-remote-write/src/opentelemetry/exporter/prometheus_remote_write/__init__.py

-2
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,6 @@ def _sanitize_string(string: str, type_: str) -> str:
300300
return sanitized
301301

302302
def _parse_histogram_data_point(self, data_point, name):
303-
304303
sample_attr_pairs = []
305304

306305
base_attrs = list(data_point.attributes.items())
@@ -341,7 +340,6 @@ def handle_bucket(value, bound=None, name_override=None):
341340
return sample_attr_pairs
342341

343342
def _parse_data_point(self, data_point, name=None):
344-
345343
attrs = tuple(data_point.attributes.items()) + (
346344
("__name__", self._sanitize_string(name, "name")),
347345
)

exporter/opentelemetry-exporter-prometheus-remote-write/src/opentelemetry/exporter/prometheus_remote_write/gen/remote_pb2.py

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

exporter/opentelemetry-exporter-prometheus-remote-write/src/opentelemetry/exporter/prometheus_remote_write/gen/types_pb2.py

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

exporter/opentelemetry-exporter-prometheus-remote-write/tests/test_prometheus_remote_write_exporter.py

-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ def test_regex_invalid(prom_rw):
5656

5757

5858
def test_parse_data_point(prom_rw):
59-
6059
attrs = {"Foo": "Bar", "Baz": 42}
6160
timestamp = 1641946016139533244
6261
value = 242.42

instrumentation/opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg/aiopg_integration.py

-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ def get_traced_cursor_proxy(cursor, db_api_integration, *args, **kwargs):
127127

128128
# pylint: disable=abstract-method
129129
class AsyncCursorTracerProxy(AsyncProxyObject):
130-
131130
# pylint: disable=unused-argument
132131
def __init__(self, cursor, *args, **kwargs):
133132
super().__init__(cursor)

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,8 @@ def collect_request_attributes(scope):
334334

335335
def collect_custom_request_headers_attributes(scope):
336336
"""returns custom HTTP request headers to be added into SERVER span as span attributes
337-
Refer specification https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/http.md#http-request-and-response-headers"""
337+
Refer specification https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/http.md#http-request-and-response-headers
338+
"""
338339

339340
sanitize = SanitizeValue(
340341
get_custom_headers(
@@ -359,7 +360,8 @@ def collect_custom_request_headers_attributes(scope):
359360

360361
def collect_custom_response_headers_attributes(message):
361362
"""returns custom HTTP response headers to be added into SERVER span as span attributes
362-
Refer specification https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/http.md#http-request-and-response-headers"""
363+
Refer specification https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/http.md#http-request-and-response-headers
364+
"""
363365

364366
sanitize = SanitizeValue(
365367
get_custom_headers(

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

-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ def _uninstrument(self, **__):
131131
unwrap(asyncpg.Connection, method)
132132

133133
async def _do_execute(self, func, instance, args, kwargs):
134-
135134
exception = None
136135
params = getattr(instance, "_params", {})
137136
name = args[0] if args[0] else params.get("database", "postgresql")

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

+8-13
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,7 @@ def custom_event_context_extractor(lambda_event):
8181
from opentelemetry.instrumentation.aws_lambda.version import __version__
8282
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
8383
from opentelemetry.instrumentation.utils import unwrap
84-
from opentelemetry.metrics import (
85-
MeterProvider,
86-
get_meter_provider,
87-
)
84+
from opentelemetry.metrics import MeterProvider, get_meter_provider
8885
from opentelemetry.propagate import get_global_textmap
8986
from opentelemetry.propagators.aws.aws_xray_propagator import (
9087
TRACE_HEADER_KEY,
@@ -282,7 +279,7 @@ def _instrument(
282279
disable_aws_context_propagation: bool = False,
283280
meter_provider: MeterProvider = None,
284281
):
285-
def _instrumented_lambda_handler_call(
282+
def _instrumented_lambda_handler_call( # noqa pylint: disable=too-many-branches
286283
call_wrapped, instance, args, kwargs
287284
):
288285
orig_handler_name = ".".join(
@@ -366,23 +363,21 @@ def _instrumented_lambda_handler_call(
366363
# NOTE: `force_flush` before function quit in case of Lambda freeze.
367364
_tracer_provider.force_flush(flush_timeout)
368365
except Exception: # pylint: disable=broad-except
369-
logger.exception(
370-
f"TracerProvider failed to flush traces"
371-
)
366+
logger.exception("TracerProvider failed to flush traces")
372367
else:
373-
logger.warning("TracerProvider was missing `force_flush` method. This is necessary in case of a Lambda freeze and would exist in the OTel SDK implementation.")
368+
logger.warning(
369+
"TracerProvider was missing `force_flush` method. This is necessary in case of a Lambda freeze and would exist in the OTel SDK implementation."
370+
)
374371

375372
_meter_provider = meter_provider or get_meter_provider()
376373
if hasattr(_meter_provider, "force_flush"):
377-
rem = flush_timeout - (time.time()-now)*1000
374+
rem = flush_timeout - (time.time() - now) * 1000
378375
if rem > 0:
379376
try:
380377
# NOTE: `force_flush` before function quit in case of Lambda freeze.
381378
_meter_provider.force_flush(rem)
382379
except Exception: # pylint: disable=broad-except
383-
logger.exception(
384-
f"MeterProvider failed to flush metrics"
385-
)
380+
logger.exception("MeterProvider failed to flush metrics")
386381
else:
387382
logger.warning(
388383
"MeterProvider was missing `force_flush` method. This is necessary in case of a Lambda freeze and would exist in the OTel SDK implementation."

instrumentation/opentelemetry-instrumentation-aws-lambda/tests/test_aws_lambda_instrumentation_manual.py

-1
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ def custom_event_context_extractor(lambda_event):
302302
test_env_patch.stop()
303303

304304
def test_lambda_no_error_with_invalid_flush_timeout(self):
305-
306305
test_env_patch = mock.patch.dict(
307306
"os.environ",
308307
{

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

-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ def _common_request( # pylint: disable=too-many-locals
119119
args,
120120
kwargs,
121121
):
122-
123122
endpoint_name = getattr(instance, "host").split(".")[0]
124123

125124
with self._tracer.start_as_current_span(
@@ -166,7 +165,6 @@ def _common_request( # pylint: disable=too-many-locals
166165
return result
167166

168167
def _patched_query_request(self, original_func, instance, args, kwargs):
169-
170168
return self._common_request(
171169
("operation_name", "params", "path", "verb"),
172170
["operation_name", "params", "path"],

instrumentation/opentelemetry-instrumentation-boto/tests/test_boto_instrumentation.py

-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ def test_s3_put(self):
187187

188188
@mock_lambda_deprecated
189189
def test_unpatch(self):
190-
191190
lamb = boto.awslambda.connect_to_region("us-east-2")
192191

193192
BotoInstrumentor().uninstrument()

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

-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ def instrument_consumer(consumer: Consumer, tracer_provider=None)
120120

121121

122122
class AutoInstrumentedProducer(Producer):
123-
124123
# This method is deliberately implemented in order to allow wrapt to wrap this function
125124
def produce(
126125
self, topic, value=None, *args, **kwargs

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

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ def _enrich_span(
7373
offset: Optional[int] = None,
7474
operation: Optional[MessagingOperationValues] = None,
7575
):
76-
7776
if not span.is_recording():
7877
return
7978

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

-1
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,6 @@ def get_traced_cursor_proxy(cursor, db_api_integration, *args, **kwargs):
471471

472472
# pylint: disable=abstract-method
473473
class TracedCursorProxy(wrapt.ObjectProxy):
474-
475474
# pylint: disable=unused-argument
476475
def __init__(self, cursor, *args, **kwargs):
477476
wrapt.ObjectProxy.__init__(self, cursor)

instrumentation/opentelemetry-instrumentation-dbapi/tests/test_dbapi_integration.py

-2
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ def test_executemany(self):
236236
)
237237

238238
def test_executemany_comment(self):
239-
240239
connect_module = mock.MagicMock()
241240
connect_module.__version__ = mock.MagicMock()
242241
connect_module.__libpq_version__ = 123
@@ -262,7 +261,6 @@ def test_executemany_comment(self):
262261
)
263262

264263
def test_executemany_flask_integration_comment(self):
265-
266264
connect_module = mock.MagicMock()
267265
connect_module.__version__ = mock.MagicMock()
268266
connect_module.__libpq_version__ = 123

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

-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ def instrumentation_dependencies(self) -> Collection[str]:
286286
return _instruments
287287

288288
def _instrument(self, **kwargs):
289-
290289
# FIXME this is probably a pattern that will show up in the rest of the
291290
# ext. Find a better way of implementing this.
292291
if environ.get(OTEL_PYTHON_DJANGO_INSTRUMENT) == "False":

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

-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ def wrapper(wrapped, _, args, kwargs):
201201
op_name,
202202
kind=SpanKind.CLIENT,
203203
) as span:
204-
205204
if callable(request_hook):
206205
request_hook(span, method, url, kwargs)
207206

instrumentation/opentelemetry-instrumentation-elasticsearch/tests/test_elasticsearch.py

-1
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,6 @@ def test_request_hook(self, request_mock):
323323
request_hook_kwargs_attribute = "request_hook.kwargs"
324324

325325
def request_hook(span, method, url, kwargs):
326-
327326
attributes = {
328327
request_hook_method_attribute: method,
329328
request_hook_url_attribute: url,

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

-1
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,6 @@ def _teardown_request(exc):
456456

457457

458458
class _InstrumentedFlask(flask.Flask):
459-
460459
_excluded_urls = None
461460
_tracer_provider = None
462461
_request_hook = None

instrumentation/opentelemetry-instrumentation-flask/tests/test_sqlcommenter.py

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ def tearDown(self):
3636
FlaskInstrumentor().uninstrument()
3737

3838
def test_sqlcommenter_enabled_default(self):
39-
4039
self.app = flask.Flask(__name__)
4140
self.app.route("/sqlcommenter")(self._sqlcommenter_endpoint)
4241
client = Client(self.app, Response)

instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/_server.py

-3
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ def _set_remote_context(self, servicer_context):
221221
def _start_span(
222222
self, handler_call_details, context, set_status_on_exception=False
223223
):
224-
225224
# standard attributes
226225
attributes = {
227226
SpanAttributes.RPC_SYSTEM: "grpc",
@@ -283,7 +282,6 @@ def intercept_service(self, continuation, handler_call_details):
283282

284283
def telemetry_wrapper(behavior, request_streaming, response_streaming):
285284
def telemetry_interceptor(request_or_iterator, context):
286-
287285
# handle streaming responses specially
288286
if response_streaming:
289287
return self._intercept_server_stream(
@@ -327,7 +325,6 @@ def telemetry_interceptor(request_or_iterator, context):
327325
def _intercept_server_stream(
328326
self, behavior, handler_call_details, request_or_iterator, context
329327
):
330-
331328
with self._set_remote_context(context):
332329
with self._start_span(
333330
handler_call_details, context, set_status_on_exception=False

instrumentation/opentelemetry-instrumentation-grpc/tests/_server.py

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ def ClientStreamingMethod(self, request_iterator, context):
4646

4747
def ServerStreamingMethod(self, request, context):
4848
if request.request_data == "error":
49-
5049
context.abort(
5150
code=grpc.StatusCode.INVALID_ARGUMENT,
5251
details="server stream error",

instrumentation/opentelemetry-instrumentation-grpc/tests/test_aio_server_interceptor.py

-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ async def test_create_two_spans(self):
205205
class TwoSpanServicer(GRPCTestServerServicer):
206206
# pylint:disable=C0103
207207
async def SimpleMethod(self, request, context):
208-
209208
# create another span
210209
tracer = trace.get_tracer(__name__)
211210
with tracer.start_as_current_span("child") as child:

instrumentation/opentelemetry-instrumentation-grpc/tests/test_server_interceptor.py

-2
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ def test_create_two_spans(self):
217217
class TwoSpanServicer(GRPCTestServerServicer):
218218
# pylint:disable=C0103
219219
def SimpleMethod(self, request, context):
220-
221220
# create another span
222221
tracer = trace.get_tracer(__name__)
223222
with tracer.start_as_current_span("child") as child:
@@ -347,7 +346,6 @@ def test_create_two_spans_streaming(self):
347346
class TwoSpanServicer(GRPCTestServerServicer):
348347
# pylint:disable=C0103
349348
def ServerStreamingMethod(self, request, context):
350-
351349
# create another span
352350
tracer = trace.get_tracer(__name__)
353351
with tracer.start_as_current_span("child") as child:

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

-2
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,6 @@ async def handle_async_request(
425425

426426

427427
class _InstrumentedClient(httpx.Client):
428-
429428
_tracer_provider = None
430429
_request_hook = None
431430
_response_hook = None
@@ -445,7 +444,6 @@ def __init__(self, *args, **kwargs):
445444

446445

447446
class _InstrumentedAsyncClient(httpx.AsyncClient):
448-
449447
_tracer_provider = None
450448
_request_hook = None
451449
_response_hook = None

instrumentation/opentelemetry-instrumentation-kafka-python/src/opentelemetry/instrumentation/kafka/utils.py

-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ def _wrap_next(
204204
consume_hook: ConsumeHookT,
205205
) -> Callable:
206206
def _traced_next(func, instance, args, kwargs):
207-
208207
record = func(*args, **kwargs)
209208

210209
if record:

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

-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ def instrumentation_dependencies(self) -> Collection[str]:
8282
return _instruments
8383

8484
def _instrument(self, **kwargs):
85-
8685
provider = kwargs.get("tracer_provider", None) or get_tracer_provider()
8786
old_factory = logging.getLogRecordFactory()
8887
LoggingInstrumentor._old_factory = old_factory

instrumentation/opentelemetry-instrumentation-psycopg2/tests/test_psycopg2_integration.py

-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525

2626
class MockCursor:
27-
2827
execute = mock.MagicMock(spec=types.MethodType)
2928
execute.__name__ = "execute"
3029

@@ -47,7 +46,6 @@ def __exit__(self, *args):
4746

4847

4948
class MockConnection:
50-
5149
commit = mock.MagicMock(spec=types.MethodType)
5250
commit.__name__ = "commit"
5351

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

-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ def _wrap_cmd(tracer, cmd, wrapped, instance, args, kwargs):
127127

128128

129129
def _get_query_string(arg):
130-
131130
"""Return the query values given the first argument to a pymemcache command.
132131
133132
If there are multiple query values, they are joined together

0 commit comments

Comments
 (0)