Handle elasticsearch client native instrumentation
Describe your environment
Elasticsearch client added native opentelemetry instrumentation in 8.13.0 and so currently without manual intervention it is possible to have our instrumentation and the client one create spans concurrently.
Steps to reproduce
Add opentelemetry instrumentation using elasticsearch client 8.13.0
What is the expected behavior?
Only the elasticsearch client creates spans.
What is the actual behavior?
Both client and opentelemetry instrumentation creates their own spans.
Additional context
Java opentelemetry instrumentation disables its instrumentation if a new enough elasticsearch client is found https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/9337/
Since we are hooking into transport perform_request we can check if one of its kwargs is otel_span (https://github.com/elastic/elasticsearch-py/blob/main/elasticsearch/_sync/client/_base.py#L271) and if its enabled attribute is True (https://github.com/elastic/elasticsearch-py/blob/main/elasticsearch/_otel.py#L46).
Before fixing this we need to make tests pass with elasticsearch 7 and 8