Merge pull request #908 from iceljc/master
Refine global stats lock key
This commit is contained in:
commit
ab725dd4f0
|
|
@ -60,12 +60,14 @@ public class TokenStatistics : ITokenStatistics
|
|||
stat.SetState("llm_total_cost", total_cost, isNeedVersion: false, source: StateSource.Application);
|
||||
|
||||
// Save stats
|
||||
var metric = StatsMetric.AgentLlmCost;
|
||||
var dim = "agent";
|
||||
var agentId = message.CurrentAgentId ?? string.Empty;
|
||||
var globalStats = _services.GetRequiredService<IBotSharpStatsService>();
|
||||
var body = new BotSharpStatsInput
|
||||
{
|
||||
Metric = StatsMetric.AgentLlmCost,
|
||||
Dimension = "agent",
|
||||
Metric = metric,
|
||||
Dimension = dim,
|
||||
DimRefVal = agentId,
|
||||
RecordTime = DateTime.UtcNow,
|
||||
IntervalType = StatsInterval.Day,
|
||||
|
|
@ -76,7 +78,7 @@ public class TokenStatistics : ITokenStatistics
|
|||
new StatsKeyValuePair("completion_cost_total", deltaCompletionCost)
|
||||
]
|
||||
};
|
||||
globalStats.UpdateStats($"global-llm-cost-{agentId}", body);
|
||||
globalStats.UpdateStats($"global-{metric}-{dim}-{agentId}", body);
|
||||
}
|
||||
|
||||
public void PrintStatistics()
|
||||
|
|
|
|||
|
|
@ -25,11 +25,13 @@ public class GlobalStatsConversationHook : IContentGeneratingHook
|
|||
// record agent call
|
||||
var globalStats = _services.GetRequiredService<IBotSharpStatsService>();
|
||||
|
||||
var metric = StatsMetric.AgentCall;
|
||||
var dim = "agent";
|
||||
var agentId = message.CurrentAgentId ?? string.Empty;
|
||||
var body = new BotSharpStatsInput
|
||||
{
|
||||
Metric = StatsMetric.AgentCall,
|
||||
Dimension = "agent",
|
||||
Metric = metric,
|
||||
Dimension = dim,
|
||||
DimRefVal = agentId,
|
||||
RecordTime = DateTime.UtcNow,
|
||||
IntervalType = StatsInterval.Day,
|
||||
|
|
@ -37,6 +39,6 @@ public class GlobalStatsConversationHook : IContentGeneratingHook
|
|||
new StatsKeyValuePair("agent_call_count", 1)
|
||||
]
|
||||
};
|
||||
globalStats.UpdateStats($"global-agent-call-{agentId}", body);
|
||||
globalStats.UpdateStats($"global-{metric}-{dim}-{agentId}", body);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue