Loging helper for Azure Monitor and Open Census
Project description
Provides addition properties for Azure Monitor under Azure Functions
This library is a sample of how to add additional properties that are queryable from Azure Monitor via traces.
Goal
The purpose is to provide a simple way to query on the message title with some set prefix, the using the returned records apply addition query logic.
This library is coupled to Azure Functions package in addition to OpenCensus.
OpenCensus
More details are explained at Set up Azure Monitor for your Python application
Usage
Installation
The package is published to Pypi.org and can be installed using normal pip
or other Python package management tools.
pip install azfunctionsmonitor
Very simply you just ensure that the APPLICATIONINSIGHTS_CONNECTION_STRING
environment variable is set for the application such as in WebApps or Azure Functions.
Again refer to OpenCensus above for more.
from azfunctionsmonitor import get_logger
logger = get_logger("my stuff") # LoggingHelper("zipper", logging.getLogger())
logger.info("hellow")
logger.debug("same same")
print("done")
If you don't have the OpenCensus APPLICATIONINSIGHTS_CONNECTION_STRING
variable or it is set incorrectly:
ERROR:root:failed to load opencensus AzureLogHandler: Instrumentation key cannot be none or empty.
Traceback (most recent call last):
File "/Users/cicorias/g/cse/py/az-mon-test/.venv/lib/python3.7/site-packages/azfunctionsmonitor/LoggingHelper.py", line 61, in get_logger
azure_handler = AzureLogHandler()
File "/Users/cicorias/g/cse/py/az-mon-test/.venv/lib/python3.7/site-packages/opencensus/ext/azure/log_exporter/__init__.py", line 45, in __init__
utils.validate_instrumentation_key(self.options.instrumentation_key)
File "/Users/cicorias/g/cse/py/az-mon-test/.venv/lib/python3.7/site-packages/opencensus/ext/azure/common/utils.py", line 76, in validate_instrumentation_key
raise ValueError("Instrumentation key cannot be none or empty.")
ValueError: Instrumentation key cannot be none or empty.
WARNING:root:[my stuff] logging set to WARNING
Environment settings
There are essentially only two key environment varaibles that the library is directly aware of
APPLICATIONINSIGHTS_CONNECTION_STRING
- which is what OpenCensus relies onLOGLEVEL
- this is equivalent to the Python log levels and can be set toDEBUG
,INFO
,WARNING
,ERROR
etc.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file azfunctionsmonitor-0.1.112.tar.gz
.
File metadata
- Download URL: azfunctionsmonitor-0.1.112.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.5 CPython/3.8.8 Linux/5.4.0-1040-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4593bbb43dab0eaa710f81c1140e55df75805985c5f3804fd4c1cb92013da49 |
|
MD5 | 8bcdc79a82510eb8ac330bf35ba4e97d |
|
BLAKE2b-256 | c4a9676fa335a760fad4baa8c0211c5ded6e04ced40669475b523879a82496f4 |
File details
Details for the file azfunctionsmonitor-0.1.112-py3-none-any.whl
.
File metadata
- Download URL: azfunctionsmonitor-0.1.112-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.5 CPython/3.8.8 Linux/5.4.0-1040-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e88fd7f927cbd3b9380aaa7fa5b288757241e028dfe2bd489720a9a027bf0392 |
|
MD5 | 82b46fb4c699b1796162a22c8b862d47 |
|
BLAKE2b-256 | 6bc85eb80928ab0c432a30211bfcdf2f0bcc93ef7a71b10c91fcff3938eddb99 |