https://github.com/signoz/sample-php-app
Sample PHP app instrumented using OpenTelemetry
https://github.com/signoz/sample-php-app
Last synced: 4 months ago
JSON representation
Sample PHP app instrumented using OpenTelemetry
- Host: GitHub
- URL: https://github.com/signoz/sample-php-app
- Owner: SigNoz
- Created: 2022-05-11T08:46:00.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-03T06:11:19.000Z (over 2 years ago)
- Last Synced: 2025-03-22T01:04:15.323Z (7 months ago)
- Language: PHP
- Homepage:
- Size: 1.25 MB
- Stars: 8
- Watchers: 6
- Forks: 10
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Sample PHP App
Sample includes various types of examples:
1. [Simple Examples](#simple-examples)
1. [Console Exporter](#console-exporter)
2. [Send trace to collector (HTTP)](#send-trace-to-collector-http)
3. [Send trace to collector (gRPC)](#send-trace-to-collector-grpc)
2. [Distributed Tracing](#distributed-tracing)## Simple Examples
### Prerequisites
- Running instance of [SigNoz](https://signoz.io/docs/install/docker/)
- PHP 7.4+
- [Composer](https://getcomposer.org/download/) and installed dependencies
```bash
# cd to the root of the project and run
composer install
```
- For running gRPC example, gRPC PHP extension is required.
```bash
# install gRPC PHP extension
sudo pecl install grpc
```### Console Exporter
```bash
php src/console-exporter.php
```### Send trace to collector (HTTP)
In case of SigNoz not running on host machine, override the `OTEL_EXPORTER_OTLP_ENDPOINT` to the correct URL.
For example:```bash
export OTEL_EXPORTER_OTLP_ENDPOINT=http://signoz.company.com:4318
```To generate traces, run:
```bash
php src/collector-http.php
```### Send trace to collector (gRPC)
In case of SigNoz not running on host machine, override the `OTEL_EXPORTER_OTLP_ENDPOINT` to the correct URL.
For example:```bash
export OTEL_EXPORTER_OTLP_ENDPOINT=http://signoz.company.com:4317
```To generate traces, run:
```bash
php src/collector-grpc.php
```## Distributed Tracing
### Prerequisites
- Running instance of [SigNoz](https://signoz.io/docs/install/docker/)
- [Docker](https://docs.docker.com/get-docker/)
- [Docker Compose](https://docs.docker.com/compose/install/)### Running Distributed tracing example
In case of SigNoz not running on host machine, override the `OTEL_EXPORTER_OTLP_ENDPOINT`
in `docker-compose.yaml` to the correct URL. For example:```yaml
x-otel-common:
&otel-common
OTEL_EXPORTER_OTLP_TRACES_PROTOCOL: grpc
OTEL_EXPORTER_OTLP_ENDPOINT: signoz.company.com:4317
```To generate distributed traces, run:
```bash
# navigate to the distributed-tracing
cd distributed-tracingdocker-compose run service-one composer install
docker-compose up# in a separate terminal
$ curl localhost:8000/users/otel
```#### Trace visualization on SigNoz

#### Application Metrics
