OpenAI服务添加吞吐量监控功能 - #100
Merged
HeiSir2014 merged 1 commit intoSep 23, 2025
Merged
Conversation
📊 Performance Impact Analysis
Analysis
|
HeiSir2014
deleted the
heisir/feat-openai-throughput-monitoring-af94ee
branch
September 23, 2025 14:45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更内容
在
src/services/openai-service.ts中新增ThroughputStats接口,用于定义 API 性能分析的吞吐量统计信息在
OpenAiService类中添加吞吐量统计相关属性:lastThroughputStats:缓存最新的吞吐量统计数据throughputHistory:存储最近10次请求的吞吐量历史记录在 API 请求处理流程中添加性能统计逻辑:
logThroughputStats私有方法,用于计算和记录吞吐量指标新增公共方法用于访问统计信息:
getLastThroughputStats():获取最新一次请求的吞吐量统计getThroughputHistory():获取历史统计记录(最多10条)getAggregatedThroughputStats():获取聚合统计信息,包括平均响应时间、吞吐量趋势等clearThroughputStats():清空统计缓存和历史记录在
src/test/openai-sdk-test.ts中增强测试脚本:变更原因
测试方法
OPENAI_KEY和可选的OPENAI_BASE_URLnode src/test/openai-sdk-test.tsOpenAiService的新增公共方法是否能正确返回统计信息