You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-monitor/app/api-filtering-sampling.md
+101Lines changed: 101 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -376,6 +376,107 @@ For a summary of the non-custom properties available on the telemetryItem, see [
376
376
377
377
You can add as many initializers as you like, and they are called in the order they are added.
378
378
379
+
### OpenCensus Python telemetry processors
380
+
381
+
Telemetry processors in OpenCensus Python are simply callback functions called to process telemetry before they are exported. The callback function must accept an [envelope](https://github.com/census-instrumentation/opencensus-python/blob/master/contrib/opencensus-ext-azure/opencensus/ext/azure/common/protocol.py#L86) data type as its parameter. To filter out telemetry from being exported,make sure the callback function returns `False`. You can see the schema for Azure Monitor data types in the envelopes [here](https://github.com/census-instrumentation/opencensus-python/blob/master/contrib/opencensus-ext-azure/opencensus/ext/azure/common/protocol.py).
382
+
383
+
```python
384
+
# Example for log exporter
385
+
import logging
386
+
387
+
from opencensus.ext.azure.log_exporter import AzureLogHandler
388
+
389
+
logger = logging.getLogger(__name__)
390
+
391
+
# Callback function to append '_hello' to each log message telemetry
# Your application should run for at least this amount
469
+
# of time so the exporter will meet this interval
470
+
# Sleep can fulfill this
471
+
time.sleep(60)
472
+
473
+
print("Done recording metrics")
474
+
475
+
if__name__=="__main__":
476
+
main()
477
+
```
478
+
You can add as many processors as you like, and they are called in the order they are added. If one processor should throw an exception, it does not impact the following processors.
0 commit comments