Skip to content

Commit aa6397a

Browse files
Akochavishalevrsrikanthccv
authored
Audit and test opentelemetry-instrumentation-elasticsearch NoOpTracer… (#1616)
* Audit and test opentelemetry-instrumentation-elasticsearch NoOpTracerProvider * wip * wip * wip * wip * wip --------- Co-authored-by: Shalev Roda <[email protected]> Co-authored-by: Srikanth Chekuri <[email protected]>
1 parent 52d01f9 commit aa6397a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,26 @@ def response_hook(span, response):
463463
spans[0].attributes[response_attribute_name],
464464
)
465465

466+
def test_no_op_tracer_provider(self, request_mock):
467+
ElasticsearchInstrumentor().uninstrument()
468+
ElasticsearchInstrumentor().instrument(
469+
tracer_provider=trace.NoOpTracerProvider()
470+
)
471+
response_payload = '{"found": false, "timed_out": true, "took": 7}'
472+
request_mock.return_value = (
473+
1,
474+
{},
475+
response_payload,
476+
)
477+
es = Elasticsearch()
478+
res = es.get(index="test-index", doc_type="_doc", id=1)
479+
self.assertEqual(
480+
res.get("found"), json.loads(response_payload).get("found")
481+
)
482+
483+
spans_list = self.get_finished_spans()
484+
self.assertEqual(len(spans_list), 0)
485+
466486
def test_body_sanitization(self, _):
467487
self.assertEqual(
468488
sanitize_body(sanitization_queries.interval_query),

0 commit comments

Comments
 (0)