File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
backend_py/primary/primary/utils Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change 3
3
from fastapi import FastAPI
4
4
from opentelemetry .instrumentation .fastapi import FastAPIInstrumentor
5
5
from opentelemetry .sdk ._logs import LoggingHandler
6
-
6
+ from opentelemetry . _logs import get_logger
7
7
8
8
# This is a custom logging handler that does formatting of log messages before passing them on to open telemetry.
9
9
# 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:
18
18
record .msg = formatted_msg
19
19
record .args = None
20
20
21
+ logger = get_logger (record .name , logger_provider = self ._logger_provider )
22
+
21
23
# 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 ))
23
25
24
26
# For inspecting and debugging the actual telemetry payload, uncomment the following lines.
25
27
# log_record_as_json = self._translate(record).to_json()
You can’t perform that action at this time.
0 commit comments