Skip to content

Commit

Permalink
feat: opentelemetry logger
Browse files Browse the repository at this point in the history
  • Loading branch information
basert committed Nov 13, 2024
1 parent d35f2f0 commit 79f5f48
Show file tree
Hide file tree
Showing 4 changed files with 247 additions and 31 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"phpunit/phpunit": "^9.5.25",
"laravel/pint": "^1.2",
"phpstan/phpstan": "^1.10",
"phpbench/phpbench": "^1.2"
"phpbench/phpbench": "^1.2",
"utopia-php/logger": "0.6.*"
},
"config": {
"allow-plugins": {
Expand Down
114 changes: 84 additions & 30 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/Telemetry/Adapter/OpenTelemetry.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
use OpenTelemetry\API\Metrics\HistogramInterface;
use OpenTelemetry\API\Metrics\MeterInterface;
use OpenTelemetry\API\Metrics\UpDownCounterInterface;
use OpenTelemetry\API\Signals;
use OpenTelemetry\Contrib\Otlp\ContentTypes;
use OpenTelemetry\Contrib\Otlp\HttpEndpointResolver;
use OpenTelemetry\Contrib\Otlp\MetricExporter;
use OpenTelemetry\Contrib\Otlp\OtlpHttpTransportFactory;
use OpenTelemetry\SDK\Common\Attribute\Attributes;
Expand Down Expand Up @@ -63,6 +65,7 @@ protected function initMeter(MetricExporterInterface $exporter, AttributesInterf

protected function createExporter(string $endpoint): MetricExporterInterface
{
$endpoint = HttpEndpointResolver::create()->resolveToString($endpoint, Signals::METRICS);
$transport = (new OtlpHttpTransportFactory())->create($endpoint, ContentTypes::PROTOBUF);
return new MetricExporter($transport, Temporality::CUMULATIVE);
}
Expand Down
Loading

0 comments on commit 79f5f48

Please sign in to comment.