Skip to content

Commit 8f9447a

Browse files
wip
1 parent a30f51d commit 8f9447a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

backend_py/primary/primary/utils/azure_monitor_setup.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from fastapi import FastAPI
44
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
55
from opentelemetry.sdk._logs import LoggingHandler
6-
6+
from opentelemetry._logs import get_logger
77

88
# This is a custom logging handler that does formatting of log messages before passing them on to open telemetry.
99
# Note that the class we're inheriting from here *is* an OpenTelemetry derived Python logger.
@@ -18,8 +18,10 @@ def emit(self, record: logging.LogRecord) -> None:
1818
record.msg = formatted_msg
1919
record.args = None
2020

21+
logger = get_logger(record.name, logger_provider=self._logger_provider)
22+
2123
# Note that the logger that we're calling emit on here is an Open Telemetry Logger, not a Python logger.
22-
self._logger.emit(self._translate(record))
24+
logger.emit(self._translate(record))
2325

2426
# For inspecting and debugging the actual telemetry payload, uncomment the following lines.
2527
# log_record_as_json = self._translate(record).to_json()

0 commit comments

Comments
 (0)