feat(otel): instrument LLM providers for latency and prompt visibility - #3798
feat(otel): instrument LLM providers for latency and prompt visibility#3798jaegeral wants to merge 20 commits into
Conversation
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request implements OpenTelemetry instrumentation for LLM providers, OpenSearch, and SQLAlchemy, while introducing a privacy-focused span processor for PII redaction and a logging filter for trace correlation. Feedback focused on ensuring that exceptions are properly recorded within the new LLM spans and addressing a potential KeyError in the logging filter when telemetry is disabled.
| except (KeyError, IndexError, requests.RequestException) as e: | ||
| raise ValueError( | ||
| f"Error JSON parsing text: {formatted_data}: {error}" | ||
| ) from error | ||
| f"Error generating text with Azure API: {e}" | ||
| ) from e |
There was a problem hiding this comment.
When an exception occurs during the LLM request, it is important to record the exception and set the span status to ERROR to ensure visibility in the trace waterfall. Currently, this exception block only raises a ValueError without updating the OpenTelemetry span.
| except (KeyError, IndexError, requests.RequestException) as e: | |
| raise ValueError( | |
| f"Error JSON parsing text: {formatted_data}: {error}" | |
| ) from error | |
| f"Error generating text with Azure API: {e}" | |
| ) from e | |
| except (KeyError, IndexError, requests.RequestException) as e: | |
| span.record_exception(e) | |
| span.set_status(telemetry.get_status_code("ERROR"), description=str(e)) | |
| raise ValueError( | |
| f"Error generating text with Azure API: {e}" | |
| ) from e |
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.