-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
28 lines (21 loc) · 916 Bytes
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
use OpenTelemetry\API\Common\Signal\Signals;
use OpenTelemetry\Contrib\Grpc\GrpcTransportFactory;
use OpenTelemetry\Contrib\Otlp\MetricExporter;
use OpenTelemetry\SDK\Common\Export\Stream\StreamTransport;
use OpenTelemetry\SDK\Common\Time\ClockFactory;
use OpenTelemetry\SDK\Metrics\Data\Temporality;
use OpenTelemetry\SDK\Metrics\MeterProvider;
use OpenTelemetry\SDK\Metrics\MetricReader\ExportingReader;
use OpenTelemetry\Contrib\Otlp\OtlpUtil;
require 'vendor/autoload.php';
$transport = (new GrpcTransportFactory())->create('http://localhost:4317' . OtlpUtil::method(Signals::METRICS));
$exporter = new MetricExporter($transport);
$reader = new ExportingReader($exporter, ClockFactory::getDefault());
$meter = MeterProvider::builder()
->addReader($reader)
->build()
->getMeter('example');
$counter = $meter->createCounter('http_requests');
$counter->add(1);
$reader->collect();