Skip to content

Commit cc37ee3

Browse files
authored
Merge pull request #55456 from dmwgroup/master
Fixed Python syntax highlighting not displaying correctly
2 parents fceaff8 + b976fc4 commit cc37ee3

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

articles/azure-monitor/app/opencensus-python.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -251,13 +251,13 @@ For details on how to modify tracked telemetry before it is sent to Azure Monito
251251

252252
By default, the metrics exporter will send a set of standard metrics to Azure Monitor. You can disable this by setting the `enable_standard_metrics` flag to `False` in the constructor of the metrics exporter.
253253

254-
```python
255-
...
256-
exporter = metrics_exporter.new_metrics_exporter(
257-
enable_standard_metrics=False,
258-
connection_string='InstrumentationKey=<your-instrumentation-key-here>')
259-
...
260-
```
254+
```python
255+
...
256+
exporter = metrics_exporter.new_metrics_exporter(
257+
enable_standard_metrics=False,
258+
connection_string='InstrumentationKey=<your-instrumentation-key-here>')
259+
...
260+
```
261261
Below is a list of standard metrics that are currently sent:
262262

263263
- Available Memory (bytes)
@@ -335,8 +335,8 @@ For details on how to modify tracked telemetry before it is sent to Azure Monito
335335

336336
4. The exporter will send log data to Azure Monitor. You can find the data under `traces`.
337337

338-
> [!NOTE]
339-
> `traces` in this context is not the same as `Tracing`. `traces` refers to the type of telemetry that you will see in Azure Monitor when utilizing the `AzureLogHandler`. `Tracing` refers to a concept in OpenCensus and relates to [distributed tracing](https://docs.microsoft.com/azure/azure-monitor/app/distributed-tracing).
338+
> [!NOTE]
339+
> `traces` in this context is not the same as `Tracing`. `traces` refers to the type of telemetry that you will see in Azure Monitor when utilizing the `AzureLogHandler`. `Tracing` refers to a concept in OpenCensus and relates to [distributed tracing](https://docs.microsoft.com/azure/azure-monitor/app/distributed-tracing).
340340

341341
5. To format your log messages, you can use `formatters` in the built-in Python [logging API](https://docs.python.org/3/library/logging.html#formatter-objects).
342342

@@ -368,8 +368,8 @@ For details on how to modify tracked telemetry before it is sent to Azure Monito
368368
```
369369

370370
6. You can also add custom properties to your log messages in the *extra* keyword argument using the custom_dimensions field. These will appear as key-value pairs in `customDimensions` in Azure Monitor.
371-
> [!NOTE]
372-
> For this feature to work, you need to pass a dictionary to the custom_dimensions field. If you pass arguments of any other type, the logger will ignore them.
371+
> [!NOTE]
372+
> For this feature to work, you need to pass a dictionary to the custom_dimensions field. If you pass arguments of any other type, the logger will ignore them.
373373

374374
```python
375375
import logging
@@ -392,25 +392,25 @@ For details on how to modify tracked telemetry before it is sent to Azure Monito
392392

393393
OpenCensus Python does not automatically track and send `exception` telemetry. They are sent through the `AzureLogHandler` by using exceptions through the Python logging library. You can add custom properties just like with normal logging.
394394

395-
```python
396-
import logging
397-
398-
from opencensus.ext.azure.log_exporter import AzureLogHandler
399-
400-
logger = logging.getLogger(__name__)
401-
# TODO: replace the all-zero GUID with your instrumentation key.
402-
logger.addHandler(AzureLogHandler(
403-
connection_string='InstrumentationKey=00000000-0000-0000-0000-000000000000')
404-
)
395+
```python
396+
import logging
405397

406-
properties = {'custom_dimensions': {'key_1': 'value_1', 'key_2': 'value_2'}}
398+
from opencensus.ext.azure.log_exporter import AzureLogHandler
407399

408-
# Use properties in exception logs
409-
try:
410-
result = 1 / 0 # generate a ZeroDivisionError
411-
except Exception:
412-
logger.exception('Captured an exception.', extra=properties)
413-
```
400+
logger = logging.getLogger(__name__)
401+
# TODO: replace the all-zero GUID with your instrumentation key.
402+
logger.addHandler(AzureLogHandler(
403+
connection_string='InstrumentationKey=00000000-0000-0000-0000-000000000000')
404+
)
405+
406+
properties = {'custom_dimensions': {'key_1': 'value_1', 'key_2': 'value_2'}}
407+
408+
# Use properties in exception logs
409+
try:
410+
result = 1 / 0 # generate a ZeroDivisionError
411+
except Exception:
412+
logger.exception('Captured an exception.', extra=properties)
413+
```
414414
Since you must log exceptions explicitly, it is up to the user in how they want to log unhandled exceptions. OpenCensus does not place restrictions in how a user wants to do this, as long as they explicitly log an exception telemetry.
415415

416416
#### Sampling

0 commit comments

Comments
 (0)