Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Open Telemetry #27

Merged
merged 4 commits into from
Aug 13, 2024
Merged

Added support for Open Telemetry #27

merged 4 commits into from
Aug 13, 2024

Conversation

ezimuel
Copy link
Contributor

@ezimuel ezimuel commented Aug 12, 2024

Following the guideline reported here, I added the support for Open Telemetry in Transport::sendRequest() function.

This PR adds an elasticsearch-api tracer using the Globals::tracerProvider() of the Open Telemetry API for PHP.
In the Transport::sendRequest() I created a span with the following attributes:

http.request.method
url.full
server.address
server.port

I also added an optional parameter to the Transport::sendRequest() function as follows:

public function sendRequest(RequestInterface $request, array $opts = []): ResponseInterface

The $opts array contains additional OTel attributes that can be passed at runtime. This array will be used to fullfill the specific Elasticsearch OTel attributes like:

db.operation.name
db.elasticsearch.path_parts.<key>
db.query.text

The complete list of Elasticsearch attributes is reported here.

This PR solves #24

Copy link
Member

@picandocodigo picandocodigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Comment on lines +54 to +56
'email',
'tel',
'phone'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These (email, tel, phone) are not present in the Ruby version. Are these standard or did you add them? Maybe I should add them too for consistency across our clients.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added since I think they can be considered sensitive information. But we also offer the possibility to customize it using the ENV variable, i.e. OTEL_RUBY_INSTRUMENTATION_ELASTICSEARCH_SEARCH_QUERY_SANITIZE_KEYS.

@ezimuel ezimuel merged commit 511745d into main Aug 13, 2024
11 checks passed
@ezimuel ezimuel mentioned this pull request Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants