Skip to content

Commit c29d0a7

Browse files
authored
Add filter_global_tags_callback to DogStatsd config
1 parent 44dbeca commit c29d0a7

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/DogStatsd.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ class DogStatsd
9090
* metric_prefix,
9191
* disable_telemetry,
9292
* container_id,
93-
* origin_detection
94-
* flush_failure_handler
93+
* origin_detection,
94+
* flush_failure_handler,
95+
* filter_global_tags_callback
9596
*
9697
* @param array{
9798
* host?: string,
@@ -105,7 +106,8 @@ class DogStatsd
105106
* disable_telemetry?: bool,
106107
* container_id?: string,
107108
* origin_detection?: bool,
108-
* flush_failure_handler?: callable
109+
* flush_failure_handler?: callable,
110+
* filter_global_tags_callback?: (callable(array<array-key, mixed>): array<array-key, mixed>),
109111
* } $config
110112
*/
111113
public function __construct(array $config = array())
@@ -162,6 +164,9 @@ public function __construct(array $config = array())
162164
if (getenv('DD_VERSION')) {
163165
$this->globalTags['version'] = getenv('DD_VERSION');
164166
}
167+
if (isset($config['filter_global_tags_callback'])) {
168+
$this->globalTags = call_user_func($config['filter_global_tags_callback'], $this->globalTags);
169+
}
165170

166171
$this->metricPrefix = isset($config['metric_prefix']) ? "$config[metric_prefix]." : '';
167172

0 commit comments

Comments
 (0)