-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathMetricsConfigBuilder.php
More file actions
57 lines (49 loc) · 1.31 KB
/
MetricsConfigBuilder.php
File metadata and controls
57 lines (49 loc) · 1.31 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
declare(strict_types=1);
namespace ValkeyGlide\OpenTelemetry;
use ValkeyGlideException;
/**
* Builder for MetricsConfig.
*/
class MetricsConfigBuilder
{
private ?string $endpoint = null;
/**
* Sets the endpoint.
*
* @param string $endpoint The metrics endpoint URL.
* @return self This builder instance for method chaining.
*/
public function endpoint(string $endpoint): self
{
if (empty($endpoint)) {
throw new ValkeyGlideException("Metrics endpoint cannot be empty");
}
$this->endpoint = $endpoint;
return $this;
}
/**
* Gets the endpoint.
*
* @return string The metrics endpoint URL.
*/
public function getEndpoint(): string
{
if ($this->endpoint === null) {
throw new ValkeyGlideException("Metrics endpoint is required when metrics config is provided");
}
return $this->endpoint;
}
/**
* Builds the MetricsConfig.
*
* @return MetricsConfig The immutable metrics configuration.
*/
public function build(): MetricsConfig
{
if ($this->endpoint === null) {
throw new ValkeyGlideException("Metrics endpoint is required when metrics config is provided");
}
return new MetricsConfig($this);
}
}