Closed fmiqbal closed 1 year ago
Thank you for the suggestion. I don't think this will be too difficult to add, but it will be a few days before I have time to really get into it. From what I have found, when using an API Key, the Authorization
header will specify ApiKey
rather than Bearer
as it does when using a secret token. I think it might be easier to have the configuration determine which type to use and then pass that to the Connector.
@fmiqbal There is an 8.2-dev branch which should provide support for API Keys. I intend to some testing before merging this, but my testing will be limited to secret token. I don't have an Elastic instance currently configured for API Keys. Can you pull that branch and test it?
I've tried these cases, all seems good
This also doesn't break this package https://github.com/arkaitzgarro/elastic-apm-laravel,
only need to manipulate these 2 envs
Tested on Laravel 10.10.0
ELASTIC_APM_API_KEY="VkFyV0ZZZ0JEclk5ZGxMVUIMmVGaEZOMndUZmk3SUFTS2dqaXhzZw=="
ELASTIC_APM_SECRET_TOKEN="gKdBZN5cxH9ZQBGanhRPSHsBQw"
Thank you for all of that testing. That's a big help. I've done some simple testing as well and am ready to merge this after updating the documentation.
This has been completed with the release of version 8.2.0
Currently as I understand from the docs and the code
https://github.com/nipwaayoni/elastic-apm-php-agent/blob/73ff8e7c10f6116199a5c160df0ec5574869c3c2/src/Middleware/Connector.php#L245-L260
there are no support for API Key authentication https://www.elastic.co/guide/en/apm/guide/current/api-key.html
The API Key use
Authorization: ApiKey
and it took precendence if secret token is also set on APM Server,I am also playing around with code, and got some success, but I am not really confident with putting $apiKey in the construct, (although secretToken is also set this way)