Added the support for OpenTelemetry
We introduced in #27 and 2be33cd the support of OpenTelemetry for the HTTP send request. At the moment, the support is only for synchronous HTTP call.
To enable the OpenTelemetry you need to set the ENV variable OTEL_PHP_INSTRUMENTATION_ELASTICSEARCH_ENABLED
to true.
We added the support natively in the Transport:sendRequest()
function. By default, the Transport create a span from a Tracer provider (e.g. Global) with the following attributes:
http.request.method
url.full
server.address
server.port
If the $request
sent using Transport::sendRequest($request)
is a PSR-7 ServerRequest we get the attribute with name otel-elastic-transport
and we pass to the OTel span as additional attributes. In this way, libraries like elasticsearch-php
can inject specific OTel attributes (e.g. db.operation.name
).
We created an OpenTelemetry class to provide all the configuration.