worldia / instrumentation-bundle
Installs: 52 307
Dependents: 0
Suggesters: 0
Security: 0
Stars: 24
Watchers: 6
Forks: 10
Open Issues: 7
Type:symfony-bundle
Requires
- monolog/monolog: ^3.0
- nyholm/dsn: ^2.0
- nyholm/psr7: ^1.5
- open-telemetry/sdk: ^1.1
- promphp/prometheus_client_php: ^2.4
- psr/http-client: ^1.0
- symfony/dependency-injection: *
Requires (Dev)
- doctrine/dbal: ^3.0
- friends-of-phpspec/phpspec-expect: ^4.0
- open-telemetry/gen-otlp-protobuf: ^1.0
- open-telemetry/transport-grpc: ^1.0
- php-http/httplug: ^2.3
- phpspec/phpspec: ^7.5
- phpstan/phpstan: ^1.4
- symfony/framework-bundle: *
- symfony/http-client: *
- symfony/messenger: *
- symfony/monolog-bundle: ^3.7
- symfony/security-core: *
- symfony/serializer: *
- symfony/twig-bundle: *
- worldia/coding-standards: ^1.0
- 1.2.1
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- dev-master / 1.0.x-dev
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 1.0.0-beta7
- 1.0.0-beta6
- 1.0.0-beta5
- 1.0.0beta4
- 1.0.0beta3
- 1.0.0.beta2
- 1.0.0beta1
- 0.0.45
- 0.0.44
- 0.0.43
- 0.0.42
- 0.0.41
- 0.0.40
- 0.0.39
- 0.0.38
- 0.0.37
- 0.0.36
- 0.0.35
- 0.0.34
- 0.0.33
- 0.0.32
- 0.0.31
- 0.0.30
- 0.0.29
- 0.0.28
- 0.0.27
- 0.0.26
- 0.0.25
- 0.0.24
- 0.0.23
- 0.0.22
- 0.0.21
- 0.0.20
- 0.0.19
- 0.0.18
- 0.0.17
- 0.0.16
- 0.0.15
- 0.0.14
- 0.0.13
- 0.0.12
- 0.0.11
- 0.0.10
- 0.0.9
- 0.0.8
- 0.0.7
- 0.0.6
- 0.0.5
- 0.0.4
- 0.0.3
- 0.0.2
- 0.0.1
- dev-chore/add-missing-method
- dev-chore/handle-deprecations
- dev-feat/http-callbacks
- dev-feat/tracing-http-with-body-callbacks
- dev-feat/use-noop-tracer-provider-if-disabled
- dev-cleanup
- dev-fix/trace-response-body
- dev-feat/filter-headers
- dev-fix/stream-tracing
- dev-chore/freeze-opentelemetry-version
- dev-feat/opentelemetry-meter-interface
- dev-fix/lint
- dev-add-operation-name-to-response-code-metric
- dev-only-set-generic-404-op-name-when-no-route-was-resolved
- dev-keep-http-response-content-even-when-throwing
- dev-null-op-tracer
- dev-fix-issue-25
This package is auto-updated.
Last update: 2024-12-20 13:23:52 UTC
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
- Tracing
- Simple tracing example
- Simple tracing example using the static API
- Add Urls to your traces in error messages
- Use upstream request id as trace id
- Customize operation (span) name for a message
- Link strategy for a message
- Propagating trace/baggage context in HTTP requests
- Add request / response bodies as span attributes for HTTP requests
- Metrics
- Adding a metric
- Using Redis as storage adapter (Recommended)
- Logging
- Health