-
Notifications
You must be signed in to change notification settings - Fork 974
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
Add the x-elastic-client-meta header #1089
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woo this looks awesome! 🤩 One tiny comment for you :)
private function getElasticMetaHeader(array $connectionParams): string | ||
{ | ||
$clientMeta = sprintf( | ||
"es=%s,php=%s,a=%d", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add t=...
for PHP transport version is the same as client version I assume?
should be: x-elastic-client-meta: es=7.10.0,php=7.4.11,t=7.10.0,a=0,c=7.68.0
in the end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't insert the transport t
parameter because I read this in the specification: "If there is no transport library separate from the client library then the key must be omitted"
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the t
parameter since the spec was outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* Replaced array_walk with array_map In Connection::getURI, array_walk was used together with passing the values as references, to change the original array. Passing values as references is error-prone and discouraged for quite some time. Also, when using in conjunction with PHP 8.0, it will fail. array_map can do the same thing as the original array_walk implementation, but without the downsides of having side effects and having to pass values as references. * Add the x-elastic-client-meta header (#1089) * Added the x-elastic-client-meta header * Removed @ExpectedException usage in PHPUnit * Removed prestissimo plugin for composer in github action * Added .phpunit.result.cache in .gitignore * Add the t transport parameter in telemetry client header * Fixed semver format for PHP version in client telemetry header Co-authored-by: Enrico Zimuel <[email protected]>
This PR adds a
x-elastic-client-meta
header in the HTTP request to send version information about the PHP language, the client library, the cURL version, the usage of async, etc.An example of
x-elastic-client-meta
is as follows:where
es
is Elasticsearch version,php
is PHP version,a=0
means the HTTP call was sync (1=async),c
is the cURL version.This header can be disabled using the function
ClientBuilder::setElasticMetaHeader(false)
, as follows: