Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

add copilot runtime metric filtering

Justin D'Souzac1a528fa6f66
diff --git a/cli/beacon/cmd/endpoint.go b/cli/beacon/cmd/endpoint.go
index 1c0a3e82..53d73767 100644
--- a/cli/beacon/cmd/endpoint.go
+++ b/cli/beacon/cmd/endpoint.go
@@ -537,7 +537,7 @@ func init() {
endpointInstallCmd.Flags().IntVar(&endpointOpts.grpcPort, "otlp-grpc-port", endpointconfig.DefaultGRPCPort, "Local OTLP gRPC port")
endpointInstallCmd.Flags().IntVar(&endpointOpts.httpPort, "otlp-http-port", endpointconfig.DefaultHTTPPort, "Local OTLP HTTP port")
endpointInstallCmd.Flags().StringVar(&endpointOpts.collectorPath, "collector", "", "Path to a beacon-otelcol binary")
- endpointInstallCmd.Flags().BoolVar(&endpointOpts.includeRuntimeMetrics, "include-runtime-metrics", false, "Include generic process/runtime OTLP metrics and OpenClaw operational metrics in the runtime JSONL log")
+ endpointInstallCmd.Flags().BoolVar(&endpointOpts.includeRuntimeMetrics, "include-runtime-metrics", false, "Include generic process/runtime OTLP metrics and harness operational metrics (OpenClaw, Copilot CLI) in the runtime JSONL log")
endpointInstallCmd.Flags().BoolVar(&endpointOpts.includeCodexSpans, "include-codex-spans", false, "Include high-volume Codex OTLP spans for troubleshooting")
endpointInstallCmd.Flags().BoolVar(&endpointOpts.noStart, "no-start", false, "Write files without starting the launchd service")
endpointInstallCmd.Flags().BoolVar(&endpointOpts.dryRun, "dry-run", false, "Print planned actions without changing endpoint files or services")
@@ -547,7 +547,7 @@ func init() {
endpointRepairCmd.Flags().IntVar(&endpointOpts.grpcPort, "otlp-grpc-port", endpointconfig.DefaultGRPCPort, "Local OTLP gRPC port")
endpointRepairCmd.Flags().IntVar(&endpointOpts.httpPort, "otlp-http-port", endpointconfig.DefaultHTTPPort, "Local OTLP HTTP port")
endpointRepairCmd.Flags().StringVar(&endpointOpts.collectorPath, "collector", "", "Path to a beacon-otelcol binary")
- endpointRepairCmd.Flags().BoolVar(&endpointOpts.includeRuntimeMetrics, "include-runtime-metrics", false, "Include generic process/runtime OTLP metrics and OpenClaw operational metrics in the runtime JSONL log")
+ endpointRepairCmd.Flags().BoolVar(&endpointOpts.includeRuntimeMetrics, "include-runtime-metrics", false, "Include generic process/runtime OTLP metrics and harness operational metrics (OpenClaw, Copilot CLI) in the runtime JSONL log")
endpointRepairCmd.Flags().BoolVar(&endpointOpts.includeCodexSpans, "include-codex-spans", false, "Include high-volume Codex OTLP spans for troubleshooting")
endpointRepairCmd.Flags().BoolVar(&endpointOpts.noStart, "no-start", false, "Write files without starting the launchd service")
endpointRepairCmd.Flags().BoolVar(&endpointOpts.dryRun, "dry-run", false, "Print planned actions without changing endpoint files or services")
diff --git a/collector-builder/exporter/beaconjsonexporter/README.md b/collector-builder/exporter/beaconjsonexporter/README.md
index 258a8b67..7eb7733a 100644
--- a/collector-builder/exporter/beaconjsonexporter/README.md
+++ b/collector-builder/exporter/beaconjsonexporter/README.md
@@ -29,6 +29,11 @@ Noise controls:
troubleshooting Codex OTLP internals.
- Codex metrics and transport/startup/debug logs remain suppressed by default so
one prompt does not flood the endpoint runtime log.
+- Copilot CLI operational metrics (`github.copilot.*`, legacy
+ `copilot_chat.*`) are suppressed by default; only
+ `gen_ai.client.token.usage` and `gen_ai.client.operation.duration` are kept.
+ Activity comes from OTLP spans. Set `include_runtime_metrics: true` for
+ troubleshooting.
The production implementation should live here and be included by
`collector-builder/builder.yaml`.
diff --git a/collector-builder/exporter/beaconjsonexporter/exporter.go b/collector-builder/exporter/beaconjsonexporter/exporter.go
index aa1cb7fe..d0dc4914 100644
--- a/collector-builder/exporter/beaconjsonexporter/exporter.go
+++ b/collector-builder/exporter/beaconjsonexporter/exporter.go
@@ -247,10 +247,10 @@ func shouldDropCopilotMetric(resourceAttrs map[string]interface{}, name string,
return false
}
normalized := strings.ToLower(strings.TrimSpace(name))
- if slices.Contains(copilotKeptMetricNames, normalized) {
+ if normalized == "" {
return false
}
- return strings.HasPrefix(normalized, "copilot_chat.")
+ return !slices.Contains(copilotKeptMetricNames, normalized)
}
var copilotKeptMetricNames = []string{
diff --git a/collector-builder/exporter/beaconjsonexporter/exporter_test.go b/collector-builder/exporter/beaconjsonexporter/exporter_test.go
index 5e844bb5..f1dc98d8 100644
--- a/collector-builder/exporter/beaconjsonexporter/exporter_test.go
+++ b/collector-builder/exporter/beaconjsonexporter/exporter_test.go
@@ -505,6 +505,11 @@ func TestConsumeMetricsDropsCopilotOperationalMetricsByDefault(t *testing.T) {
for _, name := range []string{
"gen_ai.client.operation.duration",
"gen_ai.client.token.usage",
+ "github.copilot.mcp.server.connection.count",
+ "github.copilot.agent.turn.count",
+ "github.copilot.tool.call.duration",
+ "github.copilot.tool.call.count",
+ "github.copilot.new.internal.metric",
"copilot_chat.tool.call.count",
"copilot_chat.agent.invocation.duration",
} {
@@ -519,7 +524,15 @@ func TestConsumeMetricsDropsCopilotOperationalMetricsByDefault(t *testing.T) {
t.Fatalf("read runtime log: %v", err)
}
text := strings.TrimSpace(string(data))
- for _, dropped := range []string{"copilot_chat.tool.call.count", "copilot_chat.agent.invocation.duration"} {
+ for _, dropped := range []string{
+ "github.copilot.mcp.server.connection.count",
+ "github.copilot.agent.turn.count",
+ "github.copilot.tool.call.duration",
+ "github.copilot.tool.call.count",
+ "github.copilot.new.internal.metric",
+ "copilot_chat.tool.call.count",
+ "copilot_chat.agent.invocation.duration",
+ } {
if strings.Contains(text, dropped) {
t.Fatalf("Copilot operational metric %q should have been dropped, wrote: %s", dropped, text)
}
@@ -548,8 +561,13 @@ func TestConsumeMetricsIncludesCopilotOperationalMetricsWhenConfigured(t *testin
metrics := pmetric.NewMetrics()
rm := metrics.ResourceMetrics().AppendEmpty()
rm.Resource().Attributes().PutStr("service.name", "github-copilot")
- metric := rm.ScopeMetrics().AppendEmpty().Metrics().AppendEmpty()
- metric.SetName("copilot_chat.tool.call.count")
+ sm := rm.ScopeMetrics().AppendEmpty()
+ for _, name := range []string{
+ "github.copilot.tool.call.count",
+ "copilot_chat.tool.call.count",
+ } {
+ sm.Metrics().AppendEmpty().SetName(name)
+ }
if err := exp.consumeMetrics(context.Background(), metrics); err != nil {
t.Fatalf("consumeMetrics returned error: %v", err)
@@ -558,8 +576,10 @@ func TestConsumeMetricsIncludesCopilotOperationalMetricsWhenConfigured(t *testin
if err != nil {
t.Fatalf("read runtime log: %v", err)
}
- if !strings.Contains(string(data), "copilot_chat.tool.call.count") {
- t.Fatalf("Copilot operational metric should have been kept: %s", string(data))
+ for _, kept := range []string{"github.copilot.tool.call.count", "copilot_chat.tool.call.count"} {
+ if !strings.Contains(string(data), kept) {
+ t.Fatalf("Copilot operational metric %q should have been kept: %s", kept, string(data))
+ }
}
}