Open se02035 opened 3 years ago
You can modify this field via telemetry processors
Yeah, I know but wouldn't it be nicer/cleaner to have a env var here? I mean I see a couple of benefits:
OpenCensusExtension._exporter.add_telemetry_processor(..)
plus use the same for other AzureLogHandler (if available). @se02035
Those are excellent points and I agree with it. Feel free to open a PR and I will review it :)
@lzchen , created a PR for allowing devs to set the cloud role name via an envvar. pls see https://github.com/census-instrumentation/opencensus-python/pull/1061
It is unclear how to set the cloud role value for a log record. According to https://github.com/census-instrumentation/opencensus-python/blob/5ad2a7cc62fc9663d186e15636a7b0306c9a8d7a/contrib/opencensus-ext-azure/opencensus/ext/azure/common/utils.py#L27 the cloud is always
'ai.cloud.role': os.path.basename(sys.argv[0]) or 'Python Application'
This is a problem when multiple applications send traces to a single AppInsights instance (and have the same entry point e.g. main.py)A correct cloud role name is essential for Azure Application Insights Application Map. In order to use another role name (which is likely true for most of the cases) a custom callback has be used to update the role name. It would be better to have an parameter on "Options" https://github.com/census-instrumentation/opencensus-python/blob/1ca601584cbbd3b6019bddb9c7120c069ff4f819/contrib/opencensus-ext-azure/opencensus/ext/azure/common/__init__.py#L104 to set the cloud role (and instance) and pass use that value when creating the log/trace records - similar to the instrumentation key/connection string.