affordablemobiles / open-telemetry-operations-php
Open-Telemetry Exporters for Google Cloud Operations Suite
v1.0.6
2024-04-23 16:26 UTC
Requires
- php: ^8.3
- nyholm/psr7: ^1.8
- open-telemetry/sdk: ~1
- symfony/http-client: ^7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.52
README
Provides OpenTelemetry PHP exporters for Google Cloud Platform operation suite products.
Installation
Available via composer as affordablemobiles/opentelemetry-operations-php
.
Usage
Example usage:
use AffordableMobiles\GServerlessSupportLaravel\Trace\Propagator\CloudTracePropagator; use AffordableMobiles\OpenTelemetry\CloudTrace\SpanExporterFactory; use OpenTelemetry\SDK\Sdk; use OpenTelemetry\SDK\Trace\Sampler\AlwaysOnSampler; use OpenTelemetry\SDK\Trace\Sampler\ParentBased; use OpenTelemetry\SDK\Trace\SpanProcessor\SimpleSpanProcessor; use OpenTelemetry\SDK\Trace\TracerProviderBuilder; $propagator = CloudTracePropagator::getInstance(); $spanProcessor = new SimpleSpanProcessor( (new SpanExporterFactory())->create(), ); $sampler = new ParentBased( new AlwaysOnSampler(), ); $tracerProvider = (new TracerProviderBuilder()) ->addSpanProcessor($spanProcessor) ->setSampler($sampler) ->build() ; Sdk::builder() ->setTracerProvider($tracerProvider) ->setPropagator($propagator) ->setAutoShutdown(true) ->buildAndRegisterGlobal() ;