The OpenTelemetry PHP Library
This project currently lives in a pre-alpha status. Our current release is not production ready; it has been created in order to receive feedback from the community.
We keep the OpenTelemetry Specification Matrix up to date in order to show which features are available and which have not yet been implemented.
Most of our communication is done on gitter.im in the opentelemetry-php channel.
Our meetings are held weekly on zoom on Wednesdays at 10:30am PST / 1:30pm EST.
A Google calendar invite with the included zoom link can be found here
Our open issues can all be found in the github issues tab. Feel free to reach out in gitter if you have any additional questions about these issues; we are always happy to talk through implementation details.
The recommended way to install the library is through Composer:
1.) You'll need to add a
bash "minimum-stability": "dev"
To your project's
composer.jsonfile, as this utility has not reached a stable release status quite yet.
2.) Install the dependency with composer:
$ composer require open-telemetry/opentelemetry
We use docker and docker-compose to perform a lot of our static analysis and testing.
If you're planning to develop for this library, it'll help to install
Docker Composesubmenus respectively.
In order to generate proto files for use with this repository, we can perform a
From the root directory. This wil create a
/protofolder in the root directory of the repository.
To ensure that your code is stylish, you can execute
make stylefrom your bash compatible shell. This process will print out the fixes that it is making to your associated files. Usually this process is performed as part of a code checkin. This process runs during CI and is a required check. Code that doesn't follow this style pattern will emit a failure in CI.
We use Phan for static analysis. Currently our phan configuration is just a standard default analysis configuration. You can use our phan docker wrapper to easily perform static analysis on your changes.
make phanfrom your bash compatible shell. This process will return 0 on success. Usually this process is performed as part of a code checkin. This process runs during CI and is a required check. Code that doesn't match the standards that we have defined in our phan config will emit a failure in CI.
To make sure the tests in this repo work as you expect, you can use the included docker test wrapper.
make testfrom your bash compatible shell. This will output the test output as well as a test coverage analysis. Code that doesn't pass our currently defined tests will emit a failure in CI
You can use the examples/AlwaysOnZipkinExample.php file to test out the reference implementation we have for zipkin. This example perfoms a sample trace with a grouping of 5 spans and POSTs the result to a local zipkin instance.
You can also use the examples/AlwaysOnJaegerExample.php file to test out the reference implementation we have for jaegar. This example perfoms a sample trace with a grouping of 5 spans and POSTs the result to a local jaegar instance.
The PHP for both examples should execute by itself (if you have a zipkin or jaegar instance running on localhost), but if you'd like a no-fuss way to test this out with docker and docker-compose, you can perform the following simple steps:
1.) Install the necessary dependencies by running
make install. This will install the composer dependencies and store them in
make trace examples.
Exported spans can be seen in zipkin at http://127.0.0.1:9411
Exported spans can also be seen in jaeger at http://127.0.0.1:16686
You can use the examples/prometheus/PrometheusMetricsExample.php file to test out the reference implementation we have. This example will create a counter that will be scraped by local Prometheus instance.
The easy way to test the example out with docker and docker-compose is:
make metrics-prometheus-example. Make sure that local ports 8080, 6379 and 9090 are available.
2.) Open local Prometheus instance: http://localhost:9090
3.) Go to Graph section, type "opentelemetryprometheuscounter" in the search field or select it in the dropdown menu. You will see the counter value. Every other time you run
make metrics-prometheus-examplewill increment the counter but remember that Prometheus scrapes values once in 10 seconds.
4.) In order to stop docker containers for this example just run
Versioning rationale can be found in the Versioning Documentation