Skip to content

Commit fda0863

Browse files
committed
Record whether a query is remote query
1 parent 4de2a0c commit fda0863

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

shell/AIShell.Kernel/Shell.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@ internal async Task RunREPLAsync()
595595
while (!Exit)
596596
{
597597
string input = null;
598+
bool isRemoteQuery = false;
598599
LLMAgent agent = _activeAgent;
599600

600601
try
@@ -614,6 +615,7 @@ internal async Task RunREPLAsync()
614615
// Write out the remote query, in the same style as user typing.
615616
Host.Markup($"\n>> Remote Query Received:\n");
616617
Host.MarkupLine($"[teal]{input.EscapeMarkup()}[/]");
618+
isRemoteQuery = true;
617619
}
618620
else
619621
{
@@ -681,7 +683,7 @@ internal async Task RunREPLAsync()
681683
.MarkupWarningLine($"[[{Utils.AppName}]]: Run {Formatter.Command($"/agent config {agent.Impl.Name}")} to edit the settings for the agent.");
682684
}
683685

684-
Telemetry.TrackQuery(agent.Impl.Name);
686+
Telemetry.TrackQuery(agent.Impl.Name, isRemoteQuery);
685687
}
686688
catch (Exception ex)
687689
{
@@ -746,7 +748,7 @@ internal async Task RunOnceAsync(string prompt)
746748
await _activeAgent.Impl.RefreshChatAsync(this, force: false);
747749
await _activeAgent.Impl.ChatAsync(prompt, this);
748750

749-
Telemetry.TrackQuery(_activeAgent.Impl.Name);
751+
Telemetry.TrackQuery(_activeAgent.Impl.Name, isRemote: false);
750752
}
751753
catch (OperationCanceledException)
752754
{

shell/AIShell.Kernel/Utility/Telemetry.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static Telemetry()
3939
: OperatingSystem.IsMacOS() ? "macOS" : "Linux";
4040

4141
s_sessionCount = new MetricIdentifier(MetricNamespace, "SessionCount", "uuid", "os", "standalone");
42-
s_queryCount = new MetricIdentifier(MetricNamespace, "QueryCount", "uuid", "agent");
42+
s_queryCount = new MetricIdentifier(MetricNamespace, "QueryCount", "uuid", "agent", "remote");
4343
s_knownAgents = ["openai-gpt", "azure", "interpreter", "ollama", "PhiSilica"];
4444
}
4545
}
@@ -248,11 +248,11 @@ internal static void TrackSession(bool standalone)
248248
}
249249
}
250250

251-
internal static void TrackQuery(string agentName)
251+
internal static void TrackQuery(string agentName, bool isRemote)
252252
{
253253
if (s_enabled && s_knownAgents.Contains(agentName))
254254
{
255-
s_client.GetMetric(s_queryCount).TrackValue(1.0, s_uniqueId, agentName);
255+
s_client.GetMetric(s_queryCount).TrackValue(1.0, s_uniqueId, agentName, isRemote ? "true" : "false");
256256
}
257257
}
258258
}

0 commit comments

Comments
 (0)