worldia/instrumentation-bundle

Installs: 52 330

Dependents: 0

Suggesters: 0

Security: 0

Stars: 24

Watchers: 6

Forks: 10

Open Issues: 7

Type:symfony-bundle


README

Features

Tracing

  • Using the official OpenTelemetry SDK
  • Minimal auto-instrumentation for requests, console commands, consumers and doctrine
  • Trace context propagation from incoming requests to consumers, outgoing http calls and databases (using sqlcommenter)
  • Configurable blacklisting of requests by path to avoid useless traces, eg. /metrics or /_healthz
  • Automatic log inclusion with configurable log level and channels

Metrics

  • Using the Prometheus Client
  • Minimal auto-instrumentation for common request, consumer and message metrics (see list of provided default metrics).
  • Autoconfigurable metric providers, see below.

Logging

  • Adds trace context to logs for correlation, with customizable keys.

Baggage

  • Using the official OpenTelemetry SDK
  • Baggage propagation from incoming requests to consumers and outgoing http calls

Health

  • A simple endpoint to expose application health (default: /_healthz)
  • Autoconfigurable healthcheck interface to add healthchecks to be made for global application health

Installation and configuration

composer require worldia/instrumentation-bundle <your-exporter>

You will aso need to install an exporter implementation and APCu is required by the prometheus exporter.


Add to ```bundles.php```:
```php
return [
    // Other bundles
    Instrumentation\InstrumentationBundle::class => ['all' => true],
];

Minimal configuration
See the complete configuration reference here or run bin/console config:dump-reference instrumentation.

// docker-compose.yaml

services:
  php:
    image: php:8.1
    environment:
      - OTEL_PHP_TRACES_PROCESSOR=batch
      - OTEL_TRACES_SAMPLER=parentbased_always_on
      - OTEL_TRACES_EXPORTER=otlp
      - OTEL_EXPORTER_OTLP_PROTOCOL=grpc
      - OTEL_EXPORTER_OTLP_ENDPOINT=http://jaeger:4317
  jaeger:
    image: jaegertracing/all-in-one:latest
    environment:
      COLLECTOR_OTLP_ENABLED: "true"
// instrumentation.yaml

instrumentation: ~

Usage