From de5428415d9dbc6d86f3a355cd815ad475e89e5a Mon Sep 17 00:00:00 2001 From: Riccardo Magliocchetti Date: Tue, 19 Mar 2024 15:20:20 +0100 Subject: [PATCH] Please the linter --- .../instrumentation/elasticsearch/__init__.py | 6 +++--- .../tests/test_elasticsearch.py | 19 ++++++++++++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/__init__.py b/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/__init__.py index 8f3842deb2..0f5056de83 100644 --- a/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-elasticsearch/src/opentelemetry/instrumentation/elasticsearch/__init__.py @@ -247,9 +247,9 @@ def wrapper(wrapped, _, args, kwargs): if body: # Don't set db.statement for bulk requests, as it can be very large if isinstance(body, dict): - attributes[SpanAttributes.DB_STATEMENT] = sanitize_body( - body - ) + attributes[ + SpanAttributes.DB_STATEMENT + ] = sanitize_body(body) if params: attributes["elasticsearch.params"] = str(params) if doc_id: diff --git a/instrumentation/opentelemetry-instrumentation-elasticsearch/tests/test_elasticsearch.py b/instrumentation/opentelemetry-instrumentation-elasticsearch/tests/test_elasticsearch.py index 8c5e91b922..adb16a7a0a 100644 --- a/instrumentation/opentelemetry-instrumentation-elasticsearch/tests/test_elasticsearch.py +++ b/instrumentation/opentelemetry-instrumentation-elasticsearch/tests/test_elasticsearch.py @@ -491,7 +491,24 @@ def test_bulk(self, request_mock): request_mock.return_value = (1, {}, "") es = Elasticsearch() - es.bulk([dict(_op_type="index", _index="sw", _doc_type="_doc", _id=1, doc={"name": "adam"})] * 2) + es.bulk( + [ + { + "_op_type": "index", + "_index": "sw", + "_doc_type": "_doc", + "_id": 1, + "doc": {"name": "adam"}, + }, + { + "_op_type": "index", + "_index": "sw", + "_doc_type": "_doc", + "_id": 1, + "doc": {"name": "adam"}, + }, + ] + ) spans_list = self.get_finished_spans() self.assertEqual(len(spans_list), 1)