|
24 | 24 | - [LogRecordProcessor](#logrecordprocessor) |
25 | 25 | * [LogRecordProcessor operations](#logrecordprocessor-operations) |
26 | 26 | + [OnEmit](#onemit) |
| 27 | + + [Enabled](#enabled-1) |
27 | 28 | + [ShutDown](#shutdown) |
28 | 29 | + [ForceFlush](#forceflush-1) |
29 | 30 | * [Built-in processors](#built-in-processors) |
@@ -198,7 +199,9 @@ It consists of the following parameters: |
198 | 199 | `Enabled` MUST return `false` when: |
199 | 200 |
|
200 | 201 | - there are no registered [`LogRecordProcessors`](#logrecordprocessor), |
201 | | -- `Logger` is disabled ([`LoggerConfig.disabled`](#loggerconfig) is `true`). |
| 202 | +- `Logger` is disabled ([`LoggerConfig.disabled`](#loggerconfig) is `true`), |
| 203 | +- all registered `LogRecordProcessors` implement [`Enabled`](#enabled-1), |
| 204 | + and a call to `Enabled` on each of them returns `false`. |
202 | 205 |
|
203 | 206 | Otherwise, it SHOULD return `true`. |
204 | 207 | It MAY return `false` to support additional optimizations and features. |
@@ -345,6 +348,46 @@ A `LogRecordProcessor` may freely modify `logRecord` for the duration of |
345 | 348 | the `OnEmit` call. If `logRecord` is needed after `OnEmit` returns (i.e. for |
346 | 349 | asynchronous processing) only reads are permitted. |
347 | 350 |
|
| 351 | +#### Enabled |
| 352 | + |
| 353 | +**Status**: [Development](../document-status.md) |
| 354 | + |
| 355 | +`Enabled` is an operation that a `LogRecordProcessor` MAY implement |
| 356 | +in order to support filtering via [`Logger.Enabled`](api.md#enabled). |
| 357 | + |
| 358 | +**Parameters:** |
| 359 | + |
| 360 | +* [Context](../context/README.md) explicitly passed by the caller or the current |
| 361 | + Context |
| 362 | +* [Instrumentation Scope](./data-model.md#field-instrumentationscope) associated |
| 363 | + with the `Logger` |
| 364 | +* [Severity Number](./data-model.md#field-severitynumber) passed by the caller |
| 365 | + |
| 366 | +**Returns:** `Boolean` |
| 367 | + |
| 368 | +An implementation should return `false` if a `LogRecord` (if ever created) |
| 369 | +is supposed to be filtered out for the given parameters. |
| 370 | +It should default to returning `true` for any indeterminate state, for example, |
| 371 | +when awaiting configuration. |
| 372 | + |
| 373 | +Any modifications to parameters inside `Enabled` MUST NOT be propagated to the |
| 374 | +caller. Parameters are immutable or passed by value. |
| 375 | + |
| 376 | +This operation is usually called synchronously, therefore it should not block |
| 377 | +or throw exceptions. |
| 378 | + |
| 379 | +`LogRecordProcessor` implementations responsible for filtering and supporting |
| 380 | +the `Enable` operation should ensure that [`OnEmit`](#onemit) handles filtering |
| 381 | +independently. API users cannot be expected to call [`Enabled`](api.md#enabled) |
| 382 | +before invoking [`Emit a LogRecord`](api.md#emit-a-logrecord). |
| 383 | +Moreover, the filtering logic in `OnEmit` and `Enabled` may differ. |
| 384 | + |
| 385 | +`LogRecordProcessor` implementations that wrap other `LogRecordProcessor` |
| 386 | +(which may perform filtering) can implement `Enabled` and delegate to |
| 387 | +the wrapped processor’s `Enabled`, if available. However, the `OnEmit` |
| 388 | +implementation of such processors should never call the wrapped processor’s |
| 389 | +`Enabled`, as `OnEmit` is responsible for handling filtering independently. |
| 390 | + |
348 | 391 | #### ShutDown |
349 | 392 |
|
350 | 393 | Shuts down the processor. Called when the SDK is shut down. This is an |
|
0 commit comments