-
Notifications
You must be signed in to change notification settings - Fork 471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update ai statistics #1303
base: main
Are you sure you want to change the base?
Update ai statistics #1303
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1303 +/- ##
==========================================
+ Coverage 35.91% 44.23% +8.32%
==========================================
Files 69 76 +7
Lines 11576 9895 -1681
==========================================
+ Hits 4157 4377 +220
+ Misses 7104 5183 -1921
- Partials 315 335 +20 |
logAttributes[logAttribute.Key] = value | ||
} | ||
case "request_body": | ||
raw := gjson.GetBytes(body, logAttribute.Value).Raw |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为啥不用 .String()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Raw取的是序列化后的数据,用.String()的话,打印日志的时候会有格式问题
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
具体是什么格式问题呢,能举个例子吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{"ai_log":"{"consumer":"21321r9fncsb2dq","question":"用三行python实现求和函数","answer":"在Python中,你可以使用内置的sum()
函数来计算一个数字列表的总和。这是一个简单的实现:\n\npython\\ndef sum_function(numbers):\\n return sum(numbers)\\n\\n# 测试函数\\nnumbers = [1, 2, 3, 4, 5]\\nprint(sum_function(numbers)) # 输出:15\\n
\n\n如果你想要自己手动实现一个求和函数,可以使用以下代码:\n\npython\\ndef sum_function(numbers):\\n total = 0\\n for number in numbers:\\n total += number\\n return total\\n\\n# 测试函数\\nnumbers = [1, 2, 3, 4, 5]\\nprint(sum_function(numbers)) # 输出:15\\n
\n\n在这两个例子中,我们定义了一个名为sum_function
的函数,它接受一个数字列表作为参数,并返回该列表中所有数字的总和。","output_token":"188","llm_first_token_duration":"237","llm_service_duration":"4341","model":"qwen-turbo","input_token":"16"}"}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{"ai_log":"{\"consumer\":\"21321r9fncsb2dq\",\"question\":\"用三行python实现求和函数\",\"answer\":\"在Python中,你可以使用内置的`sum()`函数来计算一个数字列表的总和。这是一个简单的实现:\\n\\n```python\\ndef sum_function(numbers):\\n return sum(numbers)\\n\\n# 测试函数\\nnumbers = [1, 2, 3, 4, 5]\\nprint(sum_function(numbers)) # 输出:15\\n```\\n\\n如果你想要自己手动实现一个求和函数,可以使用以下代码:\\n\\n```python\\ndef sum_function(numbers):\\n total = 0\\n for number in numbers:\\n total += number\\n return total\\n\\n# 测试函数\\nnumbers = [1, 2, 3, 4, 5]\\nprint(sum_function(numbers)) # 输出:15\\n```\\n\\n在这两个例子中,我们定义了一个名为`sum_function`的函数,它接受一个数字列表作为参数,并返回该列表中所有数字的总和。\",\"output_token\":\"188\",\"llm_first_token_duration\":\"237\",\"llm_service_duration\":\"4341\",\"model\":\"qwen-turbo\",\"input_token\":\"16\"}"}
return data | ||
} | ||
setTraceAttributeValueBySource(config, "response_streaming_body", streamingBodyBuffer, log) | ||
setLogAttributeValueBySource(ctx, config, "response_streaming_body", streamingBodyBuffer, log) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么 endOfStream 的时候记录的 attribute 还是 “response_streaming_body” source 的?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
流式和非流式对响应的处理是有区别的
增加用户扩展 log & span attribute 机制