Slackbot
10/27/2022, 6:38 PMAbhinav Ramana
10/27/2022, 6:41 PMPrashant Shahi
10/28/2022, 5:48 AMk8s-infra
chart.Prashant Shahi
10/28/2022, 5:49 AMPrashant Shahi
10/28/2022, 5:50 AMPrashant Shahi
10/28/2022, 5:51 AMnitya-signoz
10/28/2022, 6:03 AMSrikanth Chekuri
10/28/2022, 2:07 PMOTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true
but make sure you understand the potential issue with it from the linked issue.Abhinav Ramana
10/28/2022, 7:47 PMlogging.basicConfig(level=<http://logging.INFO|logging.INFO>, force=True) # Should happen before any logging
app = FastAPI(**opts)
app.add_middleware(LoggingMiddleware)
class LoggingMiddleware(BaseHTTPMiddleware):
async def dispatch(self, request: Request, call_next):
# Record the actual processing time for the request
start_time = time.time()
try:
response = await call_next(request)
response_status_code = response.status_code
stats_json = get_stats_json(start_time, request, response_status_code)
except ClientDisconnect:
# We don't want to handle this and logs get cluttered
stats_json = get_stats_json(start_time, request, status.HTTP_418_IM_A_TEAPOT)
stats_json["error_reason"] = "ClientDisconnect"
<http://logger.info|logger.info>(stats_json)
response = JSONResponse(stats_json, status.HTTP_418_IM_A_TEAPOT)
except Exception as ex:
# Since this was unexpected exception
stats_json = get_stats_json(start_time, request, status.HTTP_500_INTERNAL_SERVER_ERROR)
json_response_body = {"detail": repr(ex)}
response = JSONResponse(json_response_body, status.HTTP_500_INTERNAL_SERVER_ERROR)
logger.error(json_response_body, exc_info=True)
if request.url.path != "/":
<http://logger.info|logger.info>(stats_json)
return response
And udpated the environment variable as you said but I still don't see the logs beta getting populatedSrikanth Chekuri
10/28/2022, 8:01 PMlogging.basicConfig(level=<http://logging.INFO|logging.INFO>, force=True)
Abhinav Ramana
10/28/2022, 8:02 PMAbhinav Ramana
10/28/2022, 8:53 PMAbhinav Ramana
10/28/2022, 8:53 PMSrikanth Chekuri
10/28/2022, 8:59 PMforce=True
it removes handler what’s automatically configure by opentelemetry-instrument
. And any calls after that with logging.basicConfig
will not be affective. That’s problem we are talking about here https://github.com/open-telemetry/opentelemetry-python/issues/2594#issuecomment-1099620061.Abhinav Ramana
10/28/2022, 10:24 PMAbhinav Ramana
10/31/2022, 3:06 PMAbhinav Ramana
10/31/2022, 3:09 PMSrikanth Chekuri
10/31/2022, 3:30 PMOTLPHandler + OTLPLogExporter
or something else?Abhinav Ramana
10/31/2022, 3:31 PMAbhinav Ramana
10/31/2022, 3:31 PMAbhinav Ramana
10/31/2022, 3:31 PMSrikanth Chekuri
10/31/2022, 3:31 PM