Skip to content

Commit 27edcc6

Browse files
committed
Initial Commit
1 parent 0bd4f6e commit 27edcc6

12 files changed

+7031
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
vendor
2+
*.bak

README.md

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<!-- ## Usage
2+
3+
This package provides two middlewares for APM functionality:
4+
5+
1. `apm-metrics`: Collects metrics for each request
6+
2. `apm-tracing`: Creates a span for each request and adds basic HTTP information
7+
8+
You can add these middlewares to your routes or middleware groups in your Laravel application:
9+
10+
```php
11+
// In app/Http/Kernel.php
12+
13+
protected $middlewareGroups = [
14+
'web' => [
15+
// ... other middlewares
16+
\Middleware\LaravelApm\Middleware\MetricsMiddleware::class,
17+
\Middleware\LaravelApm\Middleware\TracingMiddleware::class,
18+
],
19+
];
20+
21+
// Or for specific routes in your routes file:
22+
Route::middleware(['apm-metrics', 'apm-tracing'])->group(function () {
23+
// Your routes here
24+
}); -->
25+
26+
# Installing and Setting Up Our OpenTelemetry Logging Package
27+
28+
This guide will walk you through the process of installing and configuring our OpenTelemetry logging package in your Laravel project.
29+
30+
## Prerequisites
31+
32+
- Laravel project (version 8.x or higher recommended)
33+
- Composer
34+
- PHP 7.4 or higher
35+
36+
## Installation
37+
38+
1. Install the package using Composer:
39+
40+
```bash
41+
composer require Middleware/laravel-apm
42+
```
43+
44+
2. Publish the package configuration:
45+
46+
```bash
47+
php artisan vendor:publish --provider="Middleware\LaravelAPM\LaravelAPMServiceProvider"
48+
```
49+
This will create a config/opentelemetry.php file in your project.
50+
51+
## Configuration
52+
53+
1. Open `config/laravel-apm.php` and adjust the settings as needed:
54+
55+
```bash
56+
return [
57+
'endpoint' => env('APM_EXPORTER_OTLP_ENDPOINT', 'http://localhost:9320'),
58+
'service_name' => env('APM_SERVICE_NAME', 'laravel-app'),
59+
'content_type' => 'application/x-protobuf',
60+
'headers' => [
61+
'Content-Type' => 'application/x-protobuf'
62+
],
63+
];
64+
```
65+
66+
2. Update your `.env` file with the appropriate values:
67+
68+
```bash
69+
APM_SERVICE_NAME=your-app-name
70+
```
71+
72+
## Usage
73+
74+
To use the OpenTelemetry logger in your Laravel application:
75+
76+
1. Update your `config/logging.php` to include our custom channel:

composer.json

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "middleware/laravel-apm",
3+
"description": "Middleware integration for Laravel",
4+
"type": "library",
5+
"minimum-stability": "dev",
6+
"prefer-stable": true,
7+
"version": "1.0.0",
8+
"autoload": {
9+
"psr-4": {
10+
"Middleware\\LaravelApm\\": "src/"
11+
}
12+
},
13+
"authors": [
14+
{
15+
"name": "Hardik Choksi",
16+
"email": "[email protected]"
17+
}
18+
],
19+
"require": {
20+
"php": "^7.3|^8.0|^8.1",
21+
"laravel/framework": "^8.0|^9.0|^10.0",
22+
"open-telemetry/opentelemetry": "^1.0",
23+
"open-telemetry/exporter-otlp": "^1.0",
24+
"open-telemetry/opentelemetry-auto-laravel": "^0.0.26",
25+
"open-telemetry/opentelemetry-logger-monolog": "^1.0",
26+
"guzzlehttp/promises": "^2.0",
27+
"php-http/httplug": "^2.4"
28+
},
29+
"config": {
30+
"allow-plugins": {
31+
"php-http/discovery": true
32+
}
33+
},
34+
"extra": {
35+
"laravel": {
36+
"providers": [
37+
"Middleware\\LaravelApm\\LaravelApmServiceProvider"
38+
],
39+
"aliases": {
40+
"LaravelApm": "Middleware\\LaravelApm\\Facades\\LaravelApm"
41+
}
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)