diff --git a/instrumentation/opentelemetry-instrumentation-elasticsearch/tests/test_elasticsearch.py b/instrumentation/opentelemetry-instrumentation-elasticsearch/tests/test_elasticsearch.py index f7168b39d2..c69ba70fdd 100644 --- a/instrumentation/opentelemetry-instrumentation-elasticsearch/tests/test_elasticsearch.py +++ b/instrumentation/opentelemetry-instrumentation-elasticsearch/tests/test_elasticsearch.py @@ -463,6 +463,26 @@ def response_hook(span, response): spans[0].attributes[response_attribute_name], ) + def test_no_op_tracer_provider(self, request_mock): + ElasticsearchInstrumentor().uninstrument() + ElasticsearchInstrumentor().instrument( + tracer_provider=trace.NoOpTracerProvider() + ) + response_payload = '{"found": false, "timed_out": true, "took": 7}' + request_mock.return_value = ( + 1, + {}, + response_payload, + ) + es = Elasticsearch() + res = es.get(index="test-index", doc_type="_doc", id=1) + self.assertEqual( + res.get("found"), json.loads(response_payload).get("found") + ) + + spans_list = self.get_finished_spans() + self.assertEqual(len(spans_list), 0) + def test_body_sanitization(self, _): self.assertEqual( sanitize_body(sanitization_queries.interval_query),