vortos / vortos-tracing
Vortos tracing — OpenTelemetry distributed tracing integration
Requires
- php: >=8.2
- symfony/service-contracts: ^3.0
- vortos/vortos-foundation: ^1.0
- vortos/vortos-observability: ^1.0
Suggests
- open-telemetry/api: Required for OpenTelemetryTracer
- open-telemetry/exporter-otlp: Required for OTLP trace export
- open-telemetry/sdk: Required for OpenTelemetry SDK instrumentation
- dev-main
- v1.0.0-alpha-91
- v1.0.0-alpha-90
- v1.0.0-alpha-89
- v1.0.0-alpha-86
- v1.0.0-alpha-85
- v1.0.0-alpha-80
- v1.0.0-alpha-78
- v1.0.0-alpha-76
- v1.0.0-alpha-75
- v1.0.0-alpha-74
- v1.0.0-alpha-72
- v1.0.0-alpha-71
- v1.0.0-alpha-70
- v1.0.0-alpha-69
- v1.0.0-alpha-68
- v1.0.0-alpha-67
- v1.0.0-alpha-66
- v1.0.0-alpha-65
- v1.0.0-alpha-64
- v1.0.0-alpha-63
- v1.0.0-alpha-62
- v1.0.0-alpha-61
- v1.0.0-alpha-60
- v1.0.0-alpha-59
- v1.0.0-alpha-58
- v1.0.0-alpha-57
- v1.0.0-alpha-56
- v1.0.0-alpha-55
- v1.0.0-alpha-54
- v1.0.0-alpha-53
- v1.0.0-alpha-52
- v1.0.0-alpha-51
- v1.0.0-alpha-50
- v1.0.0-alpha-49
- v1.0.0-alpha-47
- v1.0.0-alpha-46
- v1.0.0-alpha-45
- v1.0.0-alpha-44
- v1.0.0-alpha-43
- v1.0.0-alpha-42
- v1.0.0-alpha-40
- v1.0.0-alpha-39
- v1.0.0-alpha-38
- v1.0.0-alpha-37
- v1.0.0-alpha-36
- v1.0.0-alpha-34
- v1.0.0-alpha-33
- v1.0.0-alpha-31
- v1.0.0-alpha-30
- v1.0.0-alpha-29
- v1.0.0-alpha-28
- v1.0.0-alpha-27
- v1.0.0-alpha-26
- v1.0.0-alpha-25
- v1.0.0-alpha-24
- v1.0.0-alpha-23
- v1.0.0-alpha-22
- v1.0.0-alpha-21
- v1.0.0-alpha-20
- v1.0.0-alpha-18
- v1.0.0-alpha-17
- v1.0.0-alpha-16
- v1.0.0-alpha-15
- v1.0.0-alpha-14
- v1.0.0-alpha-13
- v1.0.0-alpha-12
- v1.0.0-alpha-11
- v1.0.0-alpha-9
- v1.0.0-alpha-8
- v1.0.0-alpha-7
- v1.0.0-alpha-6
- v1.0.0-alpha-5
- v1.0.0-alpha-4
- v1.0.0-alpha-3
- v1.0.0-alpha-2
- v1.0.0-alpha
This package is auto-updated.
Last update: 2026-05-14 19:16:14 UTC
README
The tracing module provides a small framework abstraction with NoOp defaults and OpenTelemetry support for production deployments.
Defaults
TracingAdapter::NoOpis the default and performs no export work.- Development uses
AlwaysOnsampling. - Production uses ratio sampling at
0.1. - Sampling is parent-based and trace-level, so child spans follow the root or remote parent decision.
- Incoming
traceparentheaders are not trusted by default. - HTTP instrumentation avoids query strings.
- Messaging propagation uses W3C trace context headers.
- Baggage is supported for small, non-sensitive, low-cardinality values.
Enable OpenTelemetry
Install the required packages:
composer require open-telemetry/api open-telemetry/sdk open-telemetry/exporter-otlp
Configure OTLP:
use Vortos\Tracing\Config\TracingAdapter; use Vortos\Tracing\Config\TracingSampler; use Vortos\Tracing\DependencyInjection\VortosTracingConfig; return static function (VortosTracingConfig $config): void { $config ->adapter(TracingAdapter::OpenTelemetry) ->service( name: $_ENV['OTEL_SERVICE_NAME'] ?? $_ENV['APP_NAME'] ?? 'checkout-api', version: $_ENV['APP_VERSION'] ?? '', environment: $_ENV['APP_ENV'] ?? 'prod', ) ->otlp( endpoint: $_ENV['OTEL_EXPORTER_OTLP_TRACES_ENDPOINT'] ?? 'http://otel-collector:4318/v1/traces', headers: [], timeoutMs: 2000, ) ->sampler(TracingSampler::Ratio, rate: 0.1) ->trustRemoteContext(false); };
The OpenTelemetry adapter requires the SDK and OTLP exporter. If they are missing, configuration fails instead of silently running without export.
Controller Attributes
use Vortos\Tracing\Attribute\DisableTracing; use Vortos\Tracing\Attribute\TraceWith; #[TraceWith(spanName: 'checkout.place_order', sampleRate: 1.0)] public function checkout(): Response { // ... } #[DisableTracing] public function health(): Response { // ... }
TraceWith customizes the HTTP span name and can override the sample rate for that endpoint. DisableTracing prevents controller-level HTTP span creation.
Baggage
Use baggage only for safe routing context, for example tenant id:
$tracer->setBaggageItem('tenant.id', $tenantId);
Never put PII, secrets, session ids, JWTs, emails, phone numbers, payment data, or high-cardinality values in baggage. Baggage is propagated to downstream services.