Skip to content

Commit 0fa3b5e

Browse files
committed
fix: rename parameter prefixes from c10k to ckrack in configuration files
1 parent 628bbaf commit 0fa3b5e

7 files changed

Lines changed: 85 additions & 44 deletions

File tree

README.md

Lines changed: 61 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,48 @@
22

33
Symfony bundle for Messenger lifecycle logging, suitable for monitoring.
44

5+
## Overview
6+
7+
This bundle subscribes to Symfony Messenger lifecycle events and emits
8+
structured logs that are easy to correlate in monitoring and debugging tools.
9+
10+
### What It Adds
11+
12+
- A UUIDv7 is assigned when a message is queued.
13+
- The same UUID is reused across queueing, receiving, handling, failures, and retries.
14+
- Each log entry includes the message class and a normalized `stamps` array.
15+
- Transport metadata such as receiver names, retry counts, and failure-transport
16+
details are included when available.
17+
18+
### Supported Lifecycle Events
19+
20+
The bundle logs queueing, receiving, success, failure, and retry events. If the
21+
installed Messenger version supports `WorkerMessageSkipEvent`, skipped messages
22+
are logged as well.
23+
524
## Installation
625

26+
### Package Installation
27+
728
```bash
829
composer require ckrack/messenger-logging-bundle
930
```
1031

32+
### Bundle Registration
33+
1134
If you are not using Symfony Flex, register the bundle manually in
1235
`config/bundles.php`.
1336

37+
### Supported Versions
38+
1439
The bundle targets Symfony `6.4`, `7.4`, and `8.0`.
1540

1641
## Configuration
1742

43+
### Basic Configuration
44+
1845
```yaml
19-
c10k_messenger_logging:
46+
ckrack_messenger_logging:
2047
enabled: true
2148
log_channel: messenger
2249
log_levels:
@@ -26,49 +53,56 @@ c10k_messenger_logging:
2653
failed: error
2754
retried: warning
2855
skipped: warning
29-
stamp_normalizers: { }
56+
stamp_normalizers: {}
3057
```
3158
59+
### Log Levels
60+
3261
All PSR-3 log levels are supported. If failure logs are too noisy in a
3362
retry-heavy environment, you can set `failed: info`.
3463

64+
### Dedicated Log Channel
65+
3566
If `log_channel` is set, only the logs emitted by this bundle are sent to that
3667
Monolog channel. Other project logs remain unaffected unless they are
3768
explicitly configured to use the same channel. Without `log_channel`, the
3869
default logger behavior remains unchanged.
3970

40-
The bundle subscribes to Messenger events and ensures that each message
41-
receives a UUIDv7 when it is queued. The same UUID then appears in the logs for
42-
queueing, receiving, success, failure, and retry, together with the message
43-
class and a normalized `stamps` array.
71+
## Stamp Normalization
72+
73+
### Default Behavior
74+
75+
The bundle normalizes a safe subset of Messenger stamp data and includes it in
76+
the `stamps` field of each log entry. Built-in normalizers cover
77+
`BusNameStamp`, `DelayStamp`, `HandledStamp`, `RedeliveryStamp`,
78+
`RouterContextStamp`, `SentStamp`, `TransportNamesStamp`, and
79+
`ValidationStamp`.
4480

45-
Stamp normalization is explicit. The bundle ships dedicated normalizers for a
46-
safe subset of Messenger stamps such as `BusNameStamp`, `DelayStamp`,
47-
`HandledStamp`, `RedeliveryStamp`, `RouterContextStamp`, `SentStamp`,
48-
`TransportNamesStamp`, and `ValidationStamp`. Unknown stamps are still listed
49-
by class name, but their `context` remains empty unless a normalizer is
50-
registered for them. This avoids reflecting every public getter on every stamp,
51-
which can expose sensitive data or large payloads such as handler results.
81+
Unknown stamps are still listed by class name, but their `context` remains
82+
empty unless a normalizer is registered for them. This avoids reflecting every
83+
public getter on every stamp, which can expose sensitive data or large payloads
84+
such as handler results.
85+
86+
### Custom Normalizers
5287

5388
Custom normalizers are discovered automatically when they implement
5489
`C10k\MessengerLoggingBundle\Logging\StampNormalizerInterface` and are
5590
registered as autoconfigured services. The bundle tags them with
56-
`c10k_messenger_logging.stamp_normalizer` and maps them by supported stamp
91+
`ckrack_messenger_logging.stamp_normalizer` and maps them by supported stamp
5792
class.
5893

5994
You can also wire an explicit `StampClass -> NormalizerClass` mapping via
6095
configuration, which is useful for overrides:
6196

6297
```yaml
63-
c10k_messenger_logging:
98+
ckrack_messenger_logging:
6499
stamp_normalizers:
65100
App\Messenger\CustomStamp: App\Messenger\Logging\CustomStampNormalizer
66101
```
67102

68-
If the installed Messenger version supports `WorkerMessageSkipEvent`, skipped
69-
messages are logged as well.
103+
## Logged Lifecycle
70104

71-
## Example Lifecycle
105+
### Example Message Flow
72106

73107
The example below shows how a single message can appear in the logs when it is
74108
queued, fails once, is retried, and is eventually handled successfully. The
@@ -135,16 +169,23 @@ retry_count: 1</pre></td>
135169
</tbody>
136170
</table>
137171

138-
Each entry also contains the normalized `stamps` array, plus fields such as
172+
### Additional Context Fields
173+
174+
Each entry also contains the normalized `stamps` array. Depending on the
175+
envelope state, the bundle may also include fields such as
139176
`transport_message_id`, `from_failed_transport`, and
140-
`failed_transport_original_receiver_name` when those details are available.
177+
`failed_transport_original_receiver_name`.
141178

142179
## Local development
143180

181+
### Prerequisites
182+
144183
- Docker with Compose V2
145184
- pre-commit
146185
- GNU Make
147186

187+
### Common Commands
188+
148189
```bash
149190
make setup
150191
make check

src/DependencyInjection/C10kMessengerLoggingExtension.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ public function load(array $configs, ContainerBuilder $container): void
3535
$container->registerForAutoconfiguration(StampNormalizerInterface::class)
3636
->addTag(StampNormalizerInterface::SERVICE_TAG);
3737

38-
$container->setParameter('c10k_messenger_logging.enabled', $enabled);
39-
$container->setParameter('c10k_messenger_logging.log_channel', $logChannel);
40-
$container->setParameter('c10k_messenger_logging.stamp_normalizers', $stampNormalizers);
38+
$container->setParameter('ckrack_messenger_logging.enabled', $enabled);
39+
$container->setParameter('ckrack_messenger_logging.log_channel', $logChannel);
40+
$container->setParameter('ckrack_messenger_logging.stamp_normalizers', $stampNormalizers);
4141

4242
foreach ($logLevels as $event => $logLevel) {
4343
$container->setParameter(
44-
'c10k_messenger_logging.log_levels.'.$event,
44+
'ckrack_messenger_logging.log_levels.'.$event,
4545
$logLevel,
4646
);
4747
}

src/DependencyInjection/Compiler/RegisterStampNormalizersPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function process(ContainerBuilder $container): void
2626
}
2727

2828
/** @var array<class-string<StampInterface>, class-string<StampNormalizerInterface>> $configuredNormalizers */
29-
$configuredNormalizers = $container->getParameter('c10k_messenger_logging.stamp_normalizers');
29+
$configuredNormalizers = $container->getParameter('ckrack_messenger_logging.stamp_normalizers');
3030
$normalizers = [];
3131
$registeredBy = [];
3232

src/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ final class Configuration implements ConfigurationInterface
2424

2525
public function getConfigTreeBuilder(): TreeBuilder
2626
{
27-
$treeBuilder = new TreeBuilder('c10k_messenger_logging');
27+
$treeBuilder = new TreeBuilder('ckrack_messenger_logging');
2828

2929
/** @var ArrayNodeDefinition $rootNode */
3030
$rootNode = $treeBuilder->getRootNode();

src/Logging/StampNormalizerInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
interface StampNormalizerInterface
1010
{
11-
public const SERVICE_TAG = 'c10k_messenger_logging.stamp_normalizer';
11+
public const SERVICE_TAG = 'ckrack_messenger_logging.stamp_normalizer';
1212

1313
/**
1414
* @return class-string<StampInterface>

src/Resources/config/services.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,23 @@
3030
);
3131
$services->set(SendMessageToTransportsEventSubscriber::class)
3232
->arg('$logger', service('logger')->nullOnInvalid())
33-
->arg('$logLevel', param('c10k_messenger_logging.log_levels.queued'));
33+
->arg('$logLevel', param('ckrack_messenger_logging.log_levels.queued'));
3434
$services->set(WorkerMessageReceivedEventSubscriber::class)
3535
->arg('$logger', service('logger')->nullOnInvalid())
36-
->arg('$logLevel', param('c10k_messenger_logging.log_levels.received'));
36+
->arg('$logLevel', param('ckrack_messenger_logging.log_levels.received'));
3737
$services->set(WorkerMessageHandledEventSubscriber::class)
3838
->arg('$logger', service('logger')->nullOnInvalid())
39-
->arg('$logLevel', param('c10k_messenger_logging.log_levels.handled'));
39+
->arg('$logLevel', param('ckrack_messenger_logging.log_levels.handled'));
4040
$services->set(WorkerMessageFailedEventSubscriber::class)
4141
->arg('$logger', service('logger')->nullOnInvalid())
42-
->arg('$logLevel', param('c10k_messenger_logging.log_levels.failed'));
42+
->arg('$logLevel', param('ckrack_messenger_logging.log_levels.failed'));
4343
$services->set(WorkerMessageRetriedEventSubscriber::class)
4444
->arg('$logger', service('logger')->nullOnInvalid())
45-
->arg('$logLevel', param('c10k_messenger_logging.log_levels.retried'));
45+
->arg('$logLevel', param('ckrack_messenger_logging.log_levels.retried'));
4646

4747
if (class_exists(WorkerMessageSkipEvent::class)) {
4848
$services->set(WorkerMessageSkipEventSubscriber::class)
4949
->arg('$logger', service('logger')->nullOnInvalid())
50-
->arg('$logLevel', param('c10k_messenger_logging.log_levels.skipped'));
50+
->arg('$logLevel', param('ckrack_messenger_logging.log_levels.skipped'));
5151
}
5252
};

tests/DependencyInjection/C10kMessengerLoggingExtensionTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ public function testItLoadsServicesWhenEnabled(): void
3737

3838
$extension->load([], $container);
3939

40-
self::assertTrue($container->hasParameter('c10k_messenger_logging.enabled'));
41-
self::assertTrue($container->getParameter('c10k_messenger_logging.enabled'));
42-
self::assertNull($container->getParameter('c10k_messenger_logging.log_channel'));
40+
self::assertTrue($container->hasParameter('ckrack_messenger_logging.enabled'));
41+
self::assertTrue($container->getParameter('ckrack_messenger_logging.enabled'));
42+
self::assertNull($container->getParameter('ckrack_messenger_logging.log_channel'));
4343
self::assertTrue($container->hasDefinition(MessengerLogContextBuilder::class));
44-
self::assertSame([], $container->getParameter('c10k_messenger_logging.stamp_normalizers'));
44+
self::assertSame([], $container->getParameter('ckrack_messenger_logging.stamp_normalizers'));
4545
self::assertTrue($container->hasDefinition(SendMessageToTransportsEventSubscriber::class));
4646
self::assertTrue($container->hasDefinition(WorkerMessageReceivedEventSubscriber::class));
4747
self::assertTrue($container->hasDefinition(WorkerMessageHandledEventSubscriber::class));
@@ -51,8 +51,8 @@ public function testItLoadsServicesWhenEnabled(): void
5151
class_exists(WorkerMessageSkipEvent::class),
5252
$container->hasDefinition(WorkerMessageSkipEventSubscriber::class),
5353
);
54-
self::assertSame('info', $container->getParameter('c10k_messenger_logging.log_levels.queued'));
55-
self::assertSame('error', $container->getParameter('c10k_messenger_logging.log_levels.failed'));
54+
self::assertSame('info', $container->getParameter('ckrack_messenger_logging.log_levels.queued'));
55+
self::assertSame('error', $container->getParameter('ckrack_messenger_logging.log_levels.failed'));
5656
self::assertSame([], $container->getDefinition(SendMessageToTransportsEventSubscriber::class)->getTag('monolog.logger'));
5757
}
5858

@@ -63,7 +63,7 @@ public function testItSkipsServicesWhenDisabled(): void
6363

6464
$extension->load([['enabled' => false]], $container);
6565

66-
self::assertFalse($container->getParameter('c10k_messenger_logging.enabled'));
66+
self::assertFalse($container->getParameter('ckrack_messenger_logging.enabled'));
6767
}
6868

6969
public function testItLoadsCustomLogLevels(): void
@@ -73,8 +73,8 @@ public function testItLoadsCustomLogLevels(): void
7373

7474
$extension->load([['log_levels' => ['queued' => 'debug', 'failed' => 'info']]], $container);
7575

76-
self::assertSame('debug', $container->getParameter('c10k_messenger_logging.log_levels.queued'));
77-
self::assertSame('info', $container->getParameter('c10k_messenger_logging.log_levels.failed'));
76+
self::assertSame('debug', $container->getParameter('ckrack_messenger_logging.log_levels.queued'));
77+
self::assertSame('info', $container->getParameter('ckrack_messenger_logging.log_levels.failed'));
7878
}
7979

8080
public function testItLoadsCustomStampNormalizerConfiguration(): void
@@ -95,7 +95,7 @@ public function testItLoadsCustomStampNormalizerConfiguration(): void
9595

9696
self::assertSame(
9797
['App\\Messenger\\CustomStamp' => 'App\\Messenger\\Logging\\CustomStampNormalizer'],
98-
$container->getParameter('c10k_messenger_logging.stamp_normalizers'),
98+
$container->getParameter('ckrack_messenger_logging.stamp_normalizers'),
9999
);
100100
}
101101

@@ -106,7 +106,7 @@ public function testItAddsConfiguredLogChannelToAllSubscribers(): void
106106

107107
$extension->load([['log_channel' => 'messenger']], $container);
108108

109-
self::assertSame('messenger', $container->getParameter('c10k_messenger_logging.log_channel'));
109+
self::assertSame('messenger', $container->getParameter('ckrack_messenger_logging.log_channel'));
110110

111111
foreach ($this->expectedSubscriberServiceIds() as $subscriberServiceId) {
112112
self::assertSame(

0 commit comments

Comments
 (0)