Skip to content

Commit

Permalink
Audit and test opentelemetry-instrumentation-elasticsearch NoOpTracer…
Browse files Browse the repository at this point in the history
…Provider
  • Loading branch information
Akochavi committed Feb 1, 2023
1 parent bbe7578 commit 6aee863
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from elasticsearch import Elasticsearch
from elasticsearch_dsl import Search

from opentelemetry import trace as trace_api
import opentelemetry.instrumentation.elasticsearch
from opentelemetry import trace
from opentelemetry.instrumentation.elasticsearch import (
Expand Down Expand Up @@ -413,3 +414,18 @@ def response_hook(span, response):
json.dumps(response_payload),
spans[0].attributes[response_attribute_name],
)

def test_no_op_tracer_provider(self, request_mock):
ElasticsearchInstrumentor().uninstrument()
ElasticsearchInstrumentor().instrument(tracer_provider=trace_api.NoOpTracerProvider())

request_mock.return_value = (
1,
{},
'{"found": false, "timed_out": true, "took": 7}',
)
es = Elasticsearch()
es.get(index="test-index", doc_type="_doc", id=1)

spans_list = self.get_finished_spans()
self.assertEqual(len(spans_list), 0)

0 comments on commit 6aee863

Please sign in to comment.