Skip to content

Commit

Permalink
support: add deps for opentelemetry
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Login <batazor@evrone.com>
  • Loading branch information
batazor committed Feb 23, 2023
1 parent 3a7815a commit d0b3b5d
Show file tree
Hide file tree
Showing 3 changed files with 1,760 additions and 308 deletions.
24 changes: 24 additions & 0 deletions internal/services/support/autoload_sdk.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

putenv('OTEL_PHP_AUTOLOAD_ENABLED=true');
putenv('OTEL_TRACES_EXPORTER=otlp');
putenv('OTEL_EXPORTER_OTLP_PROTOCOL=grpc');
putenv('OTEL_METRICS_EXPORTER=otlp');
putenv('OTEL_EXPORTER_OTLP_METRICS_PROTOCOL=grpc');
putenv('OTEL_EXPORTER_OTLP_ENDPOINT=http://grafana-tempo.grafana:4317');
putenv('OTEL_PHP_TRACES_PROCESSOR=batch');
putenv('OTEL_PROPAGATORS=b3,baggage,tracecontext');

echo 'autoloading SDK example starting...' . PHP_EOL;

// Composer autoloader will execute SDK/_autoload.php which will register global instrumentation from environment configuration
require dirname(__DIR__) . '/vendor/autoload.php';

$instrumentation = new \OpenTelemetry\API\Common\Instrumentation\CachedInstrumentation('shortlink-support');

$instrumentation->tracer()->spanBuilder('root')->startSpan()->end();
$instrumentation->meter()->createCounter('cnt')->add(1);

echo 'Finished!' . PHP_EOL;
14 changes: 14 additions & 0 deletions internal/services/support/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,19 @@
"require-dev": {
"behat/behat": "^3.12",
"rector/rector": "^0.15.18"
},
"require": {
"open-telemetry/api": "^0.0.17",
"open-telemetry/sdk": "^0.0.17",
"symfony/http-client": "^6.2",
"guzzlehttp/promises": "^1.5",
"php-http/message-factory": "^1.0",
"nyholm/psr7": "^1.5",
"open-telemetry/sdk-contrib": "^0.0.17"
},
"config": {
"allow-plugins": {
"php-http/discovery": true
}
}
}
Loading

0 comments on commit d0b3b5d

Please sign in to comment.