• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

FriendsOfOpenTelemetry / opentelemetry-bundle / 7752973069

02 Feb 2024 07:53AM UTC coverage: 35.071% (-29.5%) from 64.527%
7752973069

Pull #38

github

web-flow
Merge d1463331b into ad4a4f326
Pull Request #38: Refactor services injection

99 of 459 new or added lines in 44 files covered. (21.57%)

314 existing lines in 33 files now uncovered.

740 of 2110 relevant lines covered (35.07%)

2.37 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
/src/OpenTelemetry/Trace/ZipkinExporterEndpoint.php
1
<?php
2

3
namespace FriendsOfOpenTelemetry\OpenTelemetryBundle\OpenTelemetry\Trace;
4

5
use FriendsOfOpenTelemetry\OpenTelemetryBundle\OpenTelemetry\Exporter\ExporterDsn;
6
use FriendsOfOpenTelemetry\OpenTelemetryBundle\OpenTelemetry\Exporter\ExporterEndpointInterface;
7
use FriendsOfOpenTelemetry\OpenTelemetryBundle\OpenTelemetry\Trace\SpanExporter\TraceExporterEnum;
8
use FriendsOfOpenTelemetry\OpenTelemetryBundle\OpenTelemetry\Transport\TransportEnum;
9
use Http\Discovery\Psr17FactoryDiscovery;
10
use Psr\Http\Message\UriFactoryInterface;
11

12
final class ZipkinExporterEndpoint implements ExporterEndpointInterface
13
{
14
    private UriFactoryInterface $uriFactory;
15
    private ?TransportEnum $transport;
16

17
    private function __construct(
18
        private readonly ExporterDsn $dsn,
19
        ?UriFactoryInterface $uriFactory = null,
20
    ) {
21
        if (TraceExporterEnum::Zipkin !== TraceExporterEnum::fromDsn($this->dsn)) {
12✔
22
            throw new \InvalidArgumentException('Unsupported DSN exporter for this endpoint.');
2✔
23
        }
24
        $this->uriFactory = $uriFactory ?? Psr17FactoryDiscovery::findUriFactory();
10✔
25
        $this->transport = TransportEnum::fromDsn($this->dsn);
10✔
26
    }
27

28
    public static function fromDsn(ExporterDsn $dsn): self
29
    {
30
        return new self($dsn);
12✔
31
    }
32

33
    public function __toString()
34
    {
35
        $uri = $this->uriFactory->createUri();
10✔
36
        $uri = $uri
10✔
37
            ->withScheme($this->transport->getScheme())
10✔
38
            ->withHost($this->dsn->getHost())
10✔
39
            ->withPort($this->dsn->getPort() ?? 9411)
10✔
40
            ->withPath($this->dsn->getPath() ?? '/api/v2/spans');
10✔
41

42
        if (null !== $this->dsn->getUser()) {
10✔
43
            $uri = $uri->withUserInfo($this->dsn->getUser(), $this->dsn->getPassword());
2✔
44
        }
45

46
        return (string) $uri;
10✔
47
    }
48

49
    public function getTransport(): ?string
50
    {
UNCOV
51
        return $this->transport->value;
×
52
    }
53

54
    public function getExporter(): string
55
    {
UNCOV
56
        return 'zipkin';
×
57
    }
58
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc