Skip to content

Commit 345bc29

Browse files
committed
Merge remote-tracking branch 'origin/name-generator' into name-generator
2 parents ff41f3d + 3bf8e71 commit 345bc29

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ jaeger:
4040
4141
## Name generation options
4242
43-
You can specify just the suffix, if you name generator service is named as `jaeger.name.generator.*` or if you have any other naming scheme you can put the whole name into the configuration.
43+
You can configure custom name generators based on regular expression pattern, which will be evaluated for operation name.
44+
45+
Configuration for this feature looks like key-value list, where key - regexp pattern, value - custom name generator DI service id (see details below).
46+
47+
Name generator should implement an 'TODO' interface.
48+
As a custom name generator you can specify a full DI service id, or just the suffix if your name generator service is named as `jaeger.name.generator.*`.
4449
Keys are considered body of the regular expression pattern, do not put any modifiers (e.g. `/i`, `/g`) or slashes; `route` of the request or `name` of the command should match to use alternative generator.
4550
Expressions are checked top to bottom, if no match is found, default generator will be used
4651

@@ -52,6 +57,7 @@ jaeger:
5257
name_generator:
5358
max_length: 32
5459
command:
60+
'^app:report:.+': 'my_service_generator_alias'
5561
.* : 'controller'
5662
request:
5763
'user_routes_\w+': 'my_service_generator_alias'

src/DependencyInjection/JaegerExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function load(array $configs, ContainerBuilder $container)
4343
);
4444
}
4545
}
46-
foreach ($config['name_generator']['command'] as $item => $customGeneratorId) {
46+
foreach ($config['name_generator']['command'] as $pattern => $customGeneratorId) {
4747
$regexp = \sprintf('/%s/', $item);
4848
$shortenedGeneratorId = \sprintf('jaeger.name.generator.%s', $customGeneratorId);
4949
if ($container->has($shortenedGeneratorId)) {

src/Name/Generator/NameGeneratorChain.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ public function generate(): string
2323
{
2424
$queue = clone $this->queue;
2525
while (false === $queue->isEmpty()) {
26-
if ('' !== ($name = $queue->extract()->generate())) {
26+
/** @var NameGeneratorInterface $generator */
27+
$generator = $queue->extract();
28+
$name = $generator->generate()
29+
if ('' !== $name) {
2730
return $name;
2831
}
2932
}

0 commit comments

Comments
 (0)