mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
add(OTel): Add OTel logging for MalformedJsonEvent (#6912)
Co-authored-by: Shnatu <snatu@google.com> Co-authored-by: cornmander <shikhman@google.com>
This commit is contained in:
@@ -20,6 +20,7 @@ import {
|
||||
SERVICE_NAME,
|
||||
EVENT_SLASH_COMMAND,
|
||||
EVENT_CHAT_COMPRESSION,
|
||||
EVENT_MALFORMED_JSON_RESPONSE,
|
||||
} from './constants.js';
|
||||
import {
|
||||
ApiErrorEvent,
|
||||
@@ -36,6 +37,7 @@ import {
|
||||
SlashCommandEvent,
|
||||
KittySequenceOverflowEvent,
|
||||
ChatCompressionEvent,
|
||||
MalformedJsonResponseEvent,
|
||||
} from './types.js';
|
||||
import {
|
||||
recordApiErrorMetrics,
|
||||
@@ -449,3 +451,24 @@ export function logKittySequenceOverflow(
|
||||
};
|
||||
logger.emit(logRecord);
|
||||
}
|
||||
|
||||
export function logMalformedJsonResponse(
|
||||
config: Config,
|
||||
event: MalformedJsonResponseEvent,
|
||||
): void {
|
||||
ClearcutLogger.getInstance(config)?.logMalformedJsonResponseEvent(event);
|
||||
if (!isTelemetrySdkInitialized()) return;
|
||||
|
||||
const attributes: LogAttributes = {
|
||||
...getCommonAttributes(config),
|
||||
...event,
|
||||
'event.name': EVENT_MALFORMED_JSON_RESPONSE,
|
||||
};
|
||||
|
||||
const logger = logs.getLogger(SERVICE_NAME);
|
||||
const logRecord: LogRecord = {
|
||||
body: `Malformed JSON response from ${event.model}.`,
|
||||
attributes,
|
||||
};
|
||||
logger.emit(logRecord);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user