@@ -11,6 +11,7 @@ The **SchemaContextBundle** provides a lightweight way to manage dynamic schema
1111- Injects schema and baggage info into Messenger messages via a middleware.
1212- Rehydrates schema and baggage on message consumption via a middleware.
1313- Provide decorator for Http clients to propagate baggage header
14+ - Optional: Adds baggage context to Monolog log records via a processor
1415
1516---
1617
@@ -34,10 +35,10 @@ Add this config to `config/packages/schema_context.yaml`:
3435
3536``` yaml
3637schema_context :
37- app_name : ' %env(APP_NAME)%' # Application name
38- header_name : ' X-Tenant' # Request header to extract schema name
39- default_schema : ' public' # Default schema to fallback to
40- allowed_app_names : ['develop', 'staging', 'test'] # App names where schema context is allowed to change
38+ app_name : ' %env(APP_NAME)%' # Application name
39+ header_name : ' X-Tenant' # Request header to extract schema name
40+ default_schema : ' public' # Default schema to fallback to
41+ allowed_app_names : ['develop', 'staging', 'test'] # App names where schema context is allowed to change
4142` ` `
4243### 2. Set Environment Parameters
4344If you're using .env, define the app name:
@@ -63,11 +64,11 @@ public function index(BaggageSchemaResolver $schemaResolver)
6364Decorate your http client in your service configuration:
6465``` yaml
6566services :
66- baggage_aware_payment_http_client :
67- class : Macpaw\SchemaContextBundle\HttpClient\BaggageAwareHttpClient
68- decorates : payment_http_client # http client to decorate
69- arguments :
70- - ' @baggage_aware_payment_http_client.inner'
67+ baggage_aware_payment_http_client :
68+ class : Macpaw\SchemaContextBundle\HttpClient\BaggageAwareHttpClient
69+ decorates : payment_http_client # http client to decorate
70+ arguments :
71+ - ' @baggage_aware_payment_http_client.inner'
7172` ` `
7273
7374### A Note on Testing
@@ -76,27 +77,40 @@ If you are replacing or mocking HTTP clients in your test environment, for examp
7677
7778` ` ` yaml
7879when@test:
79- services:
80- baggage_aware_payment_http_client:
81- class: Macpaw\S chemaContextBundle\H ttpClient\B aggageAwareHttpClient
80+ services:
81+ baggage_aware_payment_http_client:
82+ class: Macpaw\S chemaContextBundle\H ttpClient\B aggageAwareHttpClient
8283` ` `
8384
8485# # Messenger Integration
8586The bundle provides a middleware that automatically :
8687
8788* Adds a BaggageSchemaStamp to dispatched messages
88-
8989* Restores the schema and baggage context on message handling
9090
9191Enable the middleware in your `messenger.yaml` :
9292
93- ` ` ` yaml
93+ ` ` ` yaml
9494framework:
95- messenger:
96- buses:
97- messenger.bus.default:
98- middleware:
99- - Macpaw\S chemaContextBundle\M essenger\M iddleware\B aggageSchemaMiddleware
95+ messenger:
96+ buses:
97+ messenger.bus.default:
98+ middleware:
99+ - Macpaw\S chemaContextBundle\M essenger\M iddleware\B aggageSchemaMiddleware
100+ ` ` `
101+
102+ # # Optional: Monolog Integration
103+ The bundle provides an optional processor that automatically adds baggage context to your log records :
104+
105+ * Adds baggage information to the `extra` field of log records
106+
107+ To enable the processor, add it to your service configuration :
108+
109+ ` ` ` yaml
110+ services:
111+ Macpaw\S chemaContextBundle\M onolog\B aggageProcessor:
112+ tags:
113+ - { name: monolog.processor }
100114` ` `
101115
102116# # Testing
0 commit comments