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
{{ message }}
This repository was archived by the owner on Sep 17, 2025. It is now read-only.
This example shows how to send a span "hello" to Azure Monitor.
28
25
29
26
* Create an Azure Monitor resource and get the instrumentation key, more information can be found `here <https://docs.microsoft.com/azure/azure-monitor/app/create-new-resource>`_.
30
27
* Put the instrumentation key in ``APPINSIGHTS_INSTRUMENTATIONKEY`` environment variable.
31
28
32
-
33
29
.. code:: python
34
30
35
31
from opencensus.ext.azure.trace_exporter import AzureExporter
@@ -43,6 +39,10 @@ This example shows how to send a span "hello" to Azure Monitor.
43
39
44
40
You can also specify the instrumentation key explicitly in the code.
45
41
42
+
* Create an Azure Monitor resource and get the instrumentation key, more information can be found `here <https://docs.microsoft.com/azure/azure-monitor/app/create-new-resource>`_.
43
+
* Install the `requests integration package <../opencensus-ext-requests>`_ using ``pip install opencensus-ext-requests``.
44
+
* Put the instrumentation key in the following code.
45
+
46
46
.. code:: python
47
47
48
48
import requests
@@ -57,16 +57,69 @@ You can also specify the instrumentation key explicitly in the code.
57
57
exporter=AzureExporter(
58
58
#TODO: replace this with your own instrumentation key.
The **Azure Monitor Log Handler** allows you to export Python logs to `Azure Monitor`_.
70
+
71
+
This example shows how to send a warning level log to Azure Monitor.
72
+
73
+
* Create an Azure Monitor resource and get the instrumentation key, more information can be found `here <https://docs.microsoft.com/azure/azure-monitor/app/create-new-resource>`_.
74
+
* Put the instrumentation key in ``APPINSIGHTS_INSTRUMENTATIONKEY`` environment variable.
75
+
76
+
.. code:: python
77
+
78
+
import logging
79
+
80
+
from opencensus.ext.azure.log_exporter import AzureLogHandler
81
+
82
+
logger = logging.getLogger(__name__)
83
+
logger.addHandler(AzureLogHandler())
84
+
logger.warning('Hello, World!')
85
+
86
+
You can enrich the logs with trace IDs and span IDs by using the `logging integration <../opencensus-ext-logging>`_.
87
+
88
+
* Create an Azure Monitor resource and get the instrumentation key, more information can be found `here <https://docs.microsoft.com/azure/azure-monitor/app/create-new-resource>`_.
89
+
* Install the `logging integration package <../opencensus-ext-logging>`_ using ``pip install opencensus-ext-logging``.
90
+
* Put the instrumentation key in ``APPINSIGHTS_INSTRUMENTATIONKEY`` environment variable.
91
+
92
+
.. code:: python
93
+
94
+
import logging
95
+
96
+
from opencensus.ext.azure.log_exporter import AzureLogHandler
97
+
from opencensus.ext.azure.trace_exporter import AzureExporter
98
+
from opencensus.trace import config_integration
99
+
from opencensus.trace.samplers import ProbabilitySampler
0 commit comments