Reputation: 479
We have running on Azure a Python Web App (flask). It processes requests and also logs some results in the end via a custom event to Application Insights.
However inside Application Insights our end-to-end transaction Operation ID for our Custom Events is 0.
Other event types such as Requests, do have the operation id. How can we get the same operation id in here as the Request event?
import logging
from opencensus.ext.azure.log_exporter import AzureEventHandler, AzureLogHandler
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
logger.addHandler(AzureEventHandler(
connection_string='InstrumentationKey=00000000-0000-0000-0000-000000000000'))
def track_result(result):
properties = {'result': result}
logger.info('Result log', extra={'custom_dimensions': properties})
return None
Upvotes: 1
Views: 1224
Reputation: 2069
openCensus
and AzureEventHandler
the operation ID was populated in application insights using the following code :import logging
from opencensus.trace import config_integration
from opencensus.ext.azure.log_exporter import AzureEventHandler
config_integration.trace_integrations(['logging'])
logger = logging.getLogger(__name__)
handler = AzureEventHandler(connection_string='Connection String from portal')
logger.addHandler(handler)
# Now we can log like this
logger.warning('Before the span')
Upvotes: 1