Feature | Add middleware for OpenTelemetry #95
+1,756
−122
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR adds comprehensive OpenTelemetry (OTEL) middleware integration to the IdP API, enabling distributed tracing, metrics collection, and centralized logging through OTLP (OpenTelemetry Protocol).
Key Features
TrackRequestMiddlewarethat captures request/response metadata including timing, CloudFlare Ray ID, and baggage contextkeepsuit/laravel-opentelemetrypackage (v1.14)Files Added
app/Http/Middleware/TrackRequestMiddleware.php- Request/response tracking middlewareconfig/opentelemetry.php- OpenTelemetry configuration filedocker-compose/opentelemetry/otel-collector-config.yaml- OTEL Collector configuration.env.example- Updated with OpenTelemetry environment variablesFiles Modified
app/Http/Kernel.php- AddedTrackRequestMiddlewareto middleware stackcomposer.json- Added OpenTelemetry dependencies and PSR-compatible autoloaderscomposer.lock- Updated dependenciesdocker-compose.yml- Added Elasticsearch and OpenTelemetry Collector servicesConfiguration Highlights
Environment Variables
OTEL_SERVICE_ENABLED- Enable/disable OpenTelemetryOTEL_SERVICE_NAME- Service name (defaults to app name)OTEL_EXPORTER_OTLP_ENDPOINT- Collector endpoint (default: http://otel-collector:4318)OTEL_EXPORTER_OTLP_PROTOCOL- Protocol: grpc, http/protobuf, http/jsonOTEL_TRACES_SAMPLER_TYPE- Sampler: always_on, always_off, traceidratioOTEL_INSTRUMENTATION_*- Toggle individual instrumentationsDocker Services
Architecture
Dependencies Added
keepsuit/laravel-opentelemetry^1.14 - Laravel OpenTelemetry wrapperopen-telemetry/api^1.4 - OTEL APIopen-telemetry/sdk^1.9 - OTEL SDKopen-telemetry/exporter-otlp^1.3 - OTLP exportergoogle/protobuf^4.33 - Protocol Buffers supportcomposer/semver^3.4.4 - Version constraint handlingTask:
Ref: https://app.clickup.com/t/86b7ccrnm