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

Fix typos and some redundancy #654

Merged
merged 7 commits into from
Apr 14, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 42 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,21 @@ This project currently lives in a pre-alpha status. Our current release is not
There is a supplemental repository for OpenTelemetry PHP contributions that are not part of the core distribution of the library. Typically, these contributions are vendor specific receivers/exporters and/or components that are only useful to a relatively small number of users. This repository can be found here:
https://github.com/open-telemetry/opentelemetry-php-contrib/

We attempt to keep the [OpenTelemetry Specification Matrix](https://github.com/open-telemetry/opentelemetry-specification/blob/master/spec-compliance-matrix.md) up to date in order to show which features are available and which have not yet been implemented.
We attempt to keep the [OpenTelemetry Specification Matrix](https://github.com/open-telemetry/opentelemetry-specification/blob/master/spec-compliance-matrix.md) up to date in order to show which features are available and which have not yet been implemented.

If you find an inconsistency in the data in the matrix vs. the data in this repository, please let us know in our slack channel and we'll get it rectified.
If you find an inconsistency in the data in the matrix vs. the data in this repository, please let us know in our Slack channel, and we'll get it rectified.

## Communication
Most of our communication is done on CNCF Slack, in the [otel-php](https://cloud-native.slack.com/archives/C01NFPCV44V) channel. To sign up, create a CNCF slack account here http://slack.cncf.io/
Most of our communication is done on CNCF Slack in the channel [otel-php](https://cloud-native.slack.com/archives/C01NFPCV44V).
To sign up, create a CNCF Slack account [here](http://slack.cncf.io/)

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](https://calendar.google.com/event?action=TEMPLATE&tmeid=N2VtZXZmYnVmbzZkYjZkbTYxdjZvYTdxN21fMjAyMDA5MTZUMTczMDAwWiBrYXJlbnlyeHVAbQ&tmsrc=google.com_b79e3e90j7bbsa2n2p5an5lf60%40group.calendar.google.com&scp=ALL)

Our open issues can all be found in the [github issues tab](https://github.com/open-telemetry/opentelemetry-php/issues). Feel free to reach out on Slack if you have any additional questions about these issues; we are always happy to talk through implementation details.

## Requirements
The library requires a PHP version of 7.4.x or 8.0.x (PHP 8.1 compability is in the works)
The library currently requires a PHP version of 7.4.x or 8.0.x (PHP 8.1 compatibility is in the works)

### Dependencies

Expand All @@ -43,11 +44,11 @@ and [this link](https://packagist.org/providers/php-http/async-client-implementa

#### OPTIONAL DEPENDENCIES

#### 1.) Install PHP [ext-grpc](https://pecl.php.net/package/gRPC)
#### 1) Install PHP [ext-grpc](https://pecl.php.net/package/gRPC)

**The PHP gRPC extension is only needed, if you want to use the OTLP GRPC Exporter.**

There are basically three ways to install the gRPC extension which will be described below. Keep in mind, that whatever way
The three ways to install the gRPC extension are described below. Keep in mind, that whatever way
brettmc marked this conversation as resolved.
Show resolved Hide resolved
to install the extension you choose, the compilation can take up to 10-15 minutes. (As an alternative you can search for
a pre-compiled extension binary for your OS and PHP version, or you might be lucky and the package manager of your OS
provides a package for the extension)
Expand All @@ -63,7 +64,7 @@ provides a package for the extension)
[sudo] pickle install grpc
```
- **Manually compiling the extension**, which is not really complicated either, but you should know
what you are doing, so we won't cover it here.
what you are doing, so we won't cover it here.

> Notice: The artifact of the gRPC extension can be as large as 100mb (!!!), there are 'hacks' to reduce that size,
> which you can find [in this thread](https://github.com/grpc/grpc/issues/23626). Use at your own risk.
Expand All @@ -85,7 +86,7 @@ however most OS` package managers provide a package for the extension.
_Experimental_ support for using fibers in PHP 8.1 for Context storage requires the `ffi` extension, and can
be enabled by setting the `OTEL_PHP_FIBERS_ENABLED` environment variable to a truthy value (`1`, `true`, `on`).

Using fibers with non-`CLI` SAPIs may require pre-loading of bindings. One way to achieve this is setting [`ffi.preload`](https://www.php.net/manual/en/ffi.configuration.php#ini.ffi.preload) to `src/Context/fiber/zend_observer_fiber.h` and setting [`opcache.preload`](https://www.php.net/manual/en/opcache.preloading.php) to `vendor/autoload.php`.
Using fibers with non-`CLI` SAPIs may require preloading of bindings. One way to achieve this is setting [`ffi.preload`](https://www.php.net/manual/en/ffi.configuration.php#ini.ffi.preload) to `src/Context/fiber/zend_observer_fiber.h` and setting [`opcache.preload`](https://www.php.net/manual/en/opcache.preloading.php) to `vendor/autoload.php`.

#### 5.) Install PHP [ext-protobuf](https://pecl.php.net/package/protobuf)

Expand All @@ -98,25 +99,26 @@ The protobuf extension makes both exporters more performant. _Note: there are so
## Installation
The recommended way to install the library is through [Composer](http://getcomposer.org):

1.) Install the composer package using [Composer's installation instructions](https://getcomposer.org/doc/00-intromd#installation-linux-unix-macos).
1) Install the composer package using [Composer's installation instructions](https://getcomposer.org/doc/00-intromd#installation-linux-unix-macos).

2.) Add

2) Add
```bash
"minimum-stability": "dev"
```

To your project's `composer.json` file, as this utility has not reached a stable release status yet.

2.) Install the dependency with composer:
3) Install the dependency with composer:

```bash
$ composer require open-telemetry/opentelemetry
```

## Development
We use `docker` and `docker-compose` to perform a lot of our static analysis and testing.
For repeatability and consistency across different operating systems, we use the [3 Musketeers pattern](https://3musketeers.io/). If you're on Windows, it might be a good idea to use Git bash for following the steps below.

If you're planning to develop for this library, it'll help to install `docker engine` and `docker-compose`.
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 engine` and `docker-compose`.

You can find installation instructions for these packages can be found [here](https://docs.docker.com/install/), under the `Docker Engine` and `Docker Compose` submenus respectively.
yuktea marked this conversation as resolved.
Show resolved Hide resolved

Expand All @@ -126,7 +128,7 @@ To ensure you have all the correct packages installed locally in your dev enviro
make install
```

From your bash compatible shell. This will install all of the necessary vendored libraries that the project uses to
brettmc marked this conversation as resolved.
Show resolved Hide resolved
This will install all the necessary vendored libraries that the project uses to
the `/vendor` directory.

To update these dependencies, you can run
Expand All @@ -142,15 +144,16 @@ In order to update all the vendored libraries in the `/vendor` directory.

Once you've made the update to the codebase that you'd like to submit, you may [create a pull request](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request) to the opentelemetry-php project.
Copy link
Member

@tidal tidal Apr 5, 2022

Choose a reason for hiding this comment

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

Could you please also reduce the visual noise of this? eg.:
"If you want to submit changes to the codebase, please create a pull request."


After you open the pull request, the CI/CD pipeline will run all of the associated [github actions](https://github.com/open-telemetry/opentelemetry-php/actions/workflows/php.yml).
After you open the pull request, the CI/CD pipeline will run all the associated [github actions](https://github.com/open-telemetry/opentelemetry-php/actions/workflows/php.yml).
yuktea marked this conversation as resolved.
Show resolved Hide resolved

You can simulate the important github actions locally before you submit your PR by running the following command:
You can simulate the important GitHub actions locally before you submit your PR by running the following command:
Copy link
Member

Choose a reason for hiding this comment

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

I still feel this is wrong. This is not simulating GitHub actions, but is simply using the same commands as the CI.


```bash
make all
```
Note: Copying `.env.dist` to `.env` fixes the warning ```The "PHP_USER" variable is not set. Defaulting to a blank string.```
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is really a necessary setup step - can we move it somewhere prominent? I think the very first step after git clone?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, @brettmc, I agree. I wanted to do that but was slightly hesitant. I think it'll be placed better after the git clone


from your bash compatible shell. This does the following things:
This does the following things:

* Installs/updates all the required dependencies for the project
* Uses [php-cs-fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer) to style your code using our style preferences.
Expand Down Expand Up @@ -179,7 +182,7 @@ If you'd like to generate protobuf files for use with this repository, one can r
make protobuf
```

From your bash compatible shell in the root of this directory. This wil create a `/proto` folder in the root
Change into the root of this directory. This will create a `/proto` folder in the root
directory of the
repository.

Expand All @@ -193,27 +196,26 @@ released.
SEMCONV_VERSION=1.8.0 make semconv
```

Run it from you bash compatible shell in the root of this repository.
Run this command in the root of this repository.

## Styling
We use [PHP-CS-Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer) for our code linting and standards fixer. The associated configuration for this standards fixer can be found in the root of the repository [here](https://github.com/open-telemetry/opentelemetry-php/blob/master/.php_cs)

To ensure that your code is stylish, you can run the follwing command:
To ensure that your code is stylish, you can run the following command:
brettmc marked this conversation as resolved.
Show resolved Hide resolved
```bash
make style
```

from your bash compatible shell. This process will print out the fixes that it is making to your
This process will print out the fixes that it is making to your
Copy link
Member

Choose a reason for hiding this comment

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

Could you please remove all of this:
"to your associated files. Usually this process is performed as part of a code checkin."
This is just visual noise imo.

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.

## Static Analysis
We use [Phan](https://github.com/phan/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.
We use [Phan](https://github.com/phan/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.

To run Phan, one can run the following command:
```bash
make phan
```
from 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](https://github.com/open-telemetry/opentelemetry-php/blob/master/.phan/config.php) will emit a failure in CI.

Expand All @@ -224,12 +226,16 @@ To run Psalm, one can run the following command:
```bash
make psalm
```
from 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 [psalm config](https://github.com/open-telemetry/opentelemetry-php/blob/main/psalm.xml.dist) will emit a failure in CI.
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 [psalm config](https://github.com/open-telemetry/opentelemetry-php/blob/main/psalm.xml.dist) will emit a failure in CI.

We use [PHPStan](https://github.com/phpstan/phpstan) as our third tool for static analysis.
You can use our PHPStan docker wrapper to easily perform static analysis on your changes.

Execute `make phpstan` from your bash compatible shell. This process will return 0 on success. Usually this process is
To perform static analysis with PHPStan run:
```bash
make phpstan
```
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 [PHPStan config](https://github.com/open-telemetry/opentelemetry-php/blob/main/phpstan.neon.dist) will emit a failure
Expand All @@ -241,8 +247,7 @@ To run the test suite, execute
```bash
make test
```
from your bash compatible shell. This will output the test output as well
as a test coverage analysis (text + html - see `tests/coverage/html`). Code that doesn't pass our currently defined tests will emit a failure in CI
This will output the test output as well as a test coverage analysis (text + html - see `tests/coverage/html`). Code that doesn't pass our currently defined tests will emit a failure in CI

## PhpMetrics
To generate a report showing a variety of metrics for the library and its classes, you can run:
Expand All @@ -254,18 +259,18 @@ This will generate a HTML PhpMetrics report in the `var/metrics` directory. Make
## Examples

### Trace
You can use the [examples/AlwaysOnZipkinExample.php](/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 use the [examples/AlwaysOnZipkinExample.php](/examples/AlwaysOnZipkinExample.php) file to test out the reference implementation we have for zipkin. This example performs 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](/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.
You can also use the [examples/AlwaysOnJaegerExample.php](/examples/AlwaysOnJaegerExample.php) file to test out the reference implementation we have for Jaeger. This example performs a sample trace with a grouping of 5 spans and POSTs the result to a local Jaeger instance.

You can use the [examples/AlwaysOnZipkinToNewrelicExample.php](/examples/AlwaysOnZipkinToNewrelicExample.php) file to test out the reference implementation we have for zipkin to Newrelic. This example perfoms a sample trace with spans and POSTs the result to a Newrelic endpoint. This requires a license key (free accounts available) to be set in the environment (NEW_RELIC_INSERT_KEY) to authenticate to the backend.
You can use the [examples/AlwaysOnZipkinToNewrelicExample.php](/examples/AlwaysOnZipkinToNewrelicExample.php) file to test out the reference implementation we have for zipkin to Newrelic. This example performs a sample trace with spans and POSTs the result to a Newrelic endpoint. This requires a license key (free accounts available) to be set in the environment (NEW_RELIC_INSERT_KEY) to authenticate to the backend.

You can use the [examples/AlwaysOnNewrelicExample.php](/examples/AlwaysOnNewrelicExample.php) file to test out the reference implementation we have for Newrelic. This example perfoms a sample trace with spans and POSTs the result to a Newrelic endpoint. This requires a license key (free accounts available) set in the environment (NEW_RELIC_INSERT_KEY) to authenticate to the backend.
You can use the [examples/AlwaysOnNewrelicExample.php](/examples/AlwaysOnNewrelicExample.php) file to test out the reference implementation we have for Newrelic. This example performs a sample trace with spans and POSTs the result to a Newrelic endpoint. This requires a license key (free accounts available) set in the environment (NEW_RELIC_INSERT_KEY) to authenticate to the backend.
Copy link
Member

Choose a reason for hiding this comment

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

Could you please remove both NewRelic examples. This is not an advertisment platform for NewRelic, and the associated exporters may be moved to the contrib repo anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you please remove both NewRelic examples. This is not an advertisment platform for NewRelic, and the associated exporters may be moved to the contrib repo anyway.

@tidal , Is there a specific reason why we are choosing to remove the NewRelic examples


The PHP for all 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:
brettmc marked this conversation as resolved.
Show resolved Hide resolved

1.) Install the necessary dependencies by running `make install`. This will install the composer dependencies and store them in `/vendor`
2.) Execute the example trace using `make trace examples`.
1) Install the necessary dependencies by running `make install`. This will install the composer dependencies and store them in `/vendor`
brettmc marked this conversation as resolved.
Show resolved Hide resolved
2) Execute the example trace using `make trace examples`.

Exported spans can be seen in zipkin at [http://127.0.0.1:9411](http://127.0.0.1:9411)

Expand All @@ -276,13 +281,13 @@ You can use the [examples/prometheus/PrometheusMetricsExample.php](/examples/pro

The easy way to test the example out with docker and docker-compose is:

1.) Run `make metrics-prometheus-example`. Make sure that local ports 8080, 6379 and 9090 are available.
1) Run `make metrics-prometheus-example`. Make sure that local ports 8080, 6379 and 9090 are available.

2.) Open local Prometheus instance: http://localhost:9090
2) Open local Prometheus instance: http://localhost:9090

3.) Go to Graph section, type "opentelemetry_prometheus_counter" 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-example` will increment the counter but remember that Prometheus scrapes values once in 10 seconds.
3) Go to Graph section, type "opentelemetry_prometheus_counter" 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-example` will 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 `make stop-prometheus`
4) In order to stop docker containers for this example just run `make stop-prometheus`

## User Integration Guides
* [Integrating OpenTelemetry PHP into Laravel Applications](./docs/laravel-integration.md)
Expand Down