Skip to content

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

support otel genai fields

Justin D'Souzafb08f5758ea4
diff --git a/cli/beacon-hooks/go.mod b/cli/beacon-hooks/go.mod
index 33a28603..a6c1a96d 100644
--- a/cli/beacon-hooks/go.mod
+++ b/cli/beacon-hooks/go.mod
@@ -3,11 +3,11 @@ module github.com/asymptote-labs/agent-beacon/cli/beacon-hooks
go 1.24
require (
- github.com/asymptote-labs/agent-beacon/pkg/asymptotetrace v0.0.0
+ github.com/asymptote-labs/agent-beacon/pkg/asymptoteobserve v0.0.0
github.com/spf13/cobra v1.8.1
)
-replace github.com/asymptote-labs/agent-beacon/pkg/asymptotetrace => ../../pkg/asymptotetrace
+replace github.com/asymptote-labs/agent-beacon/pkg/asymptoteobserve => ../../pkg/asymptoteobserve
require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
diff --git a/cli/beacon-hooks/internal/logging/logging.go b/cli/beacon-hooks/internal/logging/logging.go
index 12100f24..869b2e57 100644
--- a/cli/beacon-hooks/internal/logging/logging.go
+++ b/cli/beacon-hooks/internal/logging/logging.go
@@ -12,7 +12,7 @@ import (
"time"
"github.com/asymptote-labs/agent-beacon/cli/beacon-hooks/internal/config"
- "github.com/asymptote-labs/agent-beacon/pkg/asymptotetrace"
+ "github.com/asymptote-labs/agent-beacon/pkg/asymptoteobserve"
)
const (
@@ -139,7 +139,7 @@ func (l *Logger) baseEndpointEvent(action, category, severity, message string) m
"harness": map[string]interface{}{
"name": l.platform,
},
- "message": asymptotetrace.CleanString(message, asymptotetrace.DefaultStringLimit, true),
+ "message": asymptoteobserve.CleanString(message, asymptoteobserve.DefaultStringLimit, true),
}
if l.sessionID != "" {
event["session"] = map[string]interface{}{"id": l.sessionID}
@@ -182,25 +182,25 @@ func endpointLogPath() string {
}
func redactEndpointString(value string) string {
- return asymptotetrace.RedactString(value)
+ return asymptoteobserve.RedactString(value)
}
func sanitizeEndpointMap(input map[string]interface{}) map[string]interface{} {
- return asymptotetrace.SanitizeMap(input, asymptotetrace.PrivacyOptions{
+ return asymptoteobserve.SanitizeMap(input, asymptoteobserve.PrivacyOptions{
RedactSecrets: true,
- StringLimit: asymptotetrace.DefaultStringLimit,
+ StringLimit: asymptoteobserve.DefaultStringLimit,
})
}
func sanitizeEndpointSlice(input []interface{}) []interface{} {
- return asymptotetrace.SanitizeSlice(input, asymptotetrace.PrivacyOptions{
+ return asymptoteobserve.SanitizeSlice(input, asymptoteobserve.PrivacyOptions{
RedactSecrets: true,
- StringLimit: asymptotetrace.DefaultStringLimit,
+ StringLimit: asymptoteobserve.DefaultStringLimit,
})
}
func truncateEndpoint(value string, limit int) string {
- return asymptotetrace.TruncateString(value, limit)
+ return asymptoteobserve.TruncateString(value, limit)
}
// Keep this rotation contract mirrored with the endpoint CLI and beaconjson exporter.
diff --git a/cli/beacon/go.mod b/cli/beacon/go.mod
index d651d3d5..a548172f 100644
--- a/cli/beacon/go.mod
+++ b/cli/beacon/go.mod
@@ -3,13 +3,13 @@ module github.com/asymptote-labs/agent-beacon/cli/beacon
go 1.24
require (
- github.com/asymptote-labs/agent-beacon/pkg/asymptotetrace v0.0.0
+ github.com/asymptote-labs/agent-beacon/pkg/asymptoteobserve v0.0.0
github.com/pelletier/go-toml/v2 v2.3.1
github.com/spf13/cobra v1.8.1
gopkg.in/yaml.v3 v3.0.1
)
-replace github.com/asymptote-labs/agent-beacon/pkg/asymptotetrace => ../../pkg/asymptotetrace
+replace github.com/asymptote-labs/agent-beacon/pkg/asymptoteobserve => ../../pkg/asymptoteobserve
require (
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
diff --git a/cli/beacon/internal/endpoint/activity/activity.go b/cli/beacon/internal/endpoint/activity/activity.go
index c9bf6adf..661c9631 100644
--- a/cli/beacon/internal/endpoint/activity/activity.go
+++ b/cli/beacon/internal/endpoint/activity/activity.go
@@ -9,7 +9,6 @@ import (
"time"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/dashboard"
- "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/schema"
)
const DefaultLimit = 100
@@ -382,21 +381,15 @@ func summarizeRecord(record dashboard.EventRecord) EventSummary {
if event.Policy != nil {
summary.Policy = &PolicySummary{ID: event.Policy.ID, Name: event.Policy.Name, Decision: event.Policy.Decision, Enforcement: event.Policy.Enforcement, Reason: event.Policy.Reason}
}
- if event.Content != nil || event.Truncated {
- summary.Content = contentSummary(event.Content, event.Truncated)
+ if event.Truncated {
+ summary.Content = contentSummary(event.Truncated)
summary.Caveats = append(summary.Caveats, contentCaveats(summary.Content)...)
}
return summary
}
-func contentSummary(content *schema.ContentInfo, fieldTruncated bool) *ContentSummary {
+func contentSummary(fieldTruncated bool) *ContentSummary {
summary := &ContentSummary{FieldTruncated: fieldTruncated}
- if content != nil {
- summary.Retention = content.Retention
- summary.Included = content.Included
- summary.Redacted = content.Redacted
- summary.Truncated = content.Truncated
- }
return summary
}
diff --git a/cli/beacon/internal/endpoint/activity/activity_test.go b/cli/beacon/internal/endpoint/activity/activity_test.go
index 75c57434..f69230f0 100644
--- a/cli/beacon/internal/endpoint/activity/activity_test.go
+++ b/cli/beacon/internal/endpoint/activity/activity_test.go
@@ -9,11 +9,11 @@ import (
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/schema"
)
-func TestSearchReturnsHistoricalContentSummary(t *testing.T) {
+func TestSearchReturnsTruncationSummary(t *testing.T) {
path := filepath.Join(t.TempDir(), "runtime.jsonl")
event := testEvent("2026-05-13T01:00:00Z", "claude", "prompt.submitted", "prompt")
event.Prompt = &schema.PromptInfo{Text: "summarize local MCP use"}
- event.Content = &schema.ContentInfo{Retention: "metadata", Included: false}
+ event.Truncated = true
writeLog(t, path, event)
result, err := Search(Query{LogPath: path, Harness: "claude", Limit: 10})
@@ -27,11 +27,11 @@ func TestSearchReturnsHistoricalContentSummary(t *testing.T) {
if got.ID == "" || got.Action != "prompt.submitted" || got.Harness != "claude" {
t.Fatalf("unexpected event summary: %#v", got)
}
- if got.Content == nil || got.Content.Retention != "metadata" {
- t.Fatalf("content summary = %#v, want historical content metadata", got.Content)
+ if got.Content == nil || !got.Content.FieldTruncated {
+ t.Fatalf("content summary = %#v, want field truncation marker", got.Content)
}
- if len(got.Caveats) != 0 {
- t.Fatalf("unexpected retention caveat for historical content metadata: %#v", got.Caveats)
+ if len(got.Caveats) != 1 || got.Caveats[0] != "content was truncated" {
+ t.Fatalf("truncation caveat = %#v, want content was truncated", got.Caveats)
}
}
diff --git a/cli/beacon/internal/endpoint/config/config_test.go b/cli/beacon/internal/endpoint/config/config_test.go
index c23a80b3..462f0766 100644
--- a/cli/beacon/internal/endpoint/config/config_test.go
+++ b/cli/beacon/internal/endpoint/config/config_test.go
@@ -3,7 +3,6 @@ package config
import (
"os"
"path/filepath"
- "strings"
"testing"
)
@@ -68,13 +67,6 @@ func TestSaveLoadRoundTrip(t *testing.T) {
if len(loaded.EventCategories) != 2 || loaded.EventCategories[1] != "session" {
t.Fatalf("EventCategories did not round-trip: %#v", loaded.EventCategories)
}
- data, err := os.ReadFile(path)
- if err != nil {
- t.Fatalf("read saved config: %v", err)
- }
- if strings.Contains(string(data), "content_retention") {
- t.Fatalf("saved config unexpectedly contains legacy content_retention: %s", string(data))
- }
}
func TestSaveLoadSplunkHECRoundTripAndPrivatePermissions(t *testing.T) {
@@ -175,36 +167,6 @@ func TestSaveRejectsIncompleteFalconHEC(t *testing.T) {
}
}
-func TestLoadIgnoresLegacyContentRetention(t *testing.T) {
- home := t.TempDir()
- t.Setenv("HOME", home)
- path := filepath.Join(home, UserConfigPath)
- if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {
- t.Fatalf("mkdir config dir: %v", err)
- }
- if err := os.WriteFile(path, []byte(`{"user_mode":true,"content_retention":"metadata"}`), 0644); err != nil {
- t.Fatalf("write config: %v", err)
- }
-
- loaded, err := Load(true)
- if err != nil {
- t.Fatalf("Load returned error: %v", err)
- }
- if !loaded.UserMode {
- t.Fatal("UserMode = false, want true")
- }
- if _, err := Save(loaded); err != nil {
- t.Fatalf("Save returned error: %v", err)
- }
- data, err := os.ReadFile(path)
- if err != nil {
- t.Fatalf("read saved config: %v", err)
- }
- if strings.Contains(string(data), "content_retention") {
- t.Fatalf("saved config unexpectedly preserved legacy content_retention: %s", string(data))
- }
-}
-
func TestLoadRejectsCorruptJSON(t *testing.T) {
home := t.TempDir()
t.Setenv("HOME", home)
diff --git a/cli/beacon/internal/endpoint/dashboard/events.go b/cli/beacon/internal/endpoint/dashboard/events.go
index 5fed6fc2..84a7227f 100644
--- a/cli/beacon/internal/endpoint/dashboard/events.go
+++ b/cli/beacon/internal/endpoint/dashboard/events.go
@@ -464,18 +464,6 @@ func searchFields(record EventRecord) []string {
if event.Prompt != nil {
fields = append(fields, event.Prompt.Text)
}
- if event.Content != nil {
- fields = append(fields, event.Content.Retention)
- if event.Content.Included {
- fields = append(fields, "content included")
- }
- if event.Content.Redacted {
- fields = append(fields, "redacted")
- }
- if event.Content.Truncated {
- fields = append(fields, "truncated")
- }
- }
if event.Destination != nil {
fields = append(fields, event.Destination.Type, event.Destination.Mode, event.Destination.Status)
}
diff --git a/cli/beacon/internal/endpoint/dashboard/static/app.js b/cli/beacon/internal/endpoint/dashboard/static/app.js
index b1860a36..e5fae17d 100644
--- a/cli/beacon/internal/endpoint/dashboard/static/app.js
+++ b/cli/beacon/internal/endpoint/dashboard/static/app.js
@@ -453,9 +453,7 @@ function artifactCell(event) {
function retentionCell(record) {
const event = record.event || {};
const labels = [];
- if (event.content?.retention) labels.push(badge(event.content.retention, "badge-muted"));
- if (event.content?.truncated || event.field_truncated) labels.push(badge("truncated", "badge-warn"));
- if (event.content?.redacted) labels.push(badge("redacted", "badge-warn"));
+ if (event.field_truncated) labels.push(badge("truncated", "badge-warn"));
return labels.join(" ") || badge("default", "badge-muted");
}
@@ -475,7 +473,6 @@ function detailSummary(record) {
["Artifact", event.prompt?.text ? "" : primaryArtifact(event)],
["Approval", event.approval ? [event.approval.decision, event.approval.reason].filter(Boolean).join(": ") : ""],
["Policy", event.policy ? [event.policy.decision, event.policy.name, event.policy.reason].filter(Boolean).join(": ") : ""],
- ["Content", event.content ? `${event.content.retention}${event.content.redacted ? ", redacted" : ""}${event.content.truncated ? ", truncated" : ""}` : ""],
].filter(([, value]) => value);
return rows
.map(([label, value]) => {
diff --git a/cli/beacon/internal/endpoint/lifecycle/lifecycle_test.go b/cli/beacon/internal/endpoint/lifecycle/lifecycle_test.go
index d0abb03a..653075e8 100644
--- a/cli/beacon/internal/endpoint/lifecycle/lifecycle_test.go
+++ b/cli/beacon/internal/endpoint/lifecycle/lifecycle_test.go
@@ -530,7 +530,7 @@ func TestRepairPreservesExistingConfigWhenReinstallFails(t *testing.T) {
if err := os.MkdirAll(filepath.Dir(configPath), 0755); err != nil {
t.Fatalf("mkdir config dir: %v", err)
}
- const originalConfig = `{"user_mode":true,"log_path":"original","collector":{"config_path":"original","grpc_port":4317,"http_port":4318},"content_retention":"full"}`
+ const originalConfig = `{"user_mode":true,"log_path":"original","collector":{"config_path":"original","grpc_port":4317,"http_port":4318}}`
if err := os.WriteFile(configPath, []byte(originalConfig), 0600); err != nil {
t.Fatalf("write original config: %v", err)
}
diff --git a/cli/beacon/internal/endpoint/schema/event.go b/cli/beacon/internal/endpoint/schema/event.go
index b7a5cf7b..06a51572 100644
--- a/cli/beacon/internal/endpoint/schema/event.go
+++ b/cli/beacon/internal/endpoint/schema/event.go
@@ -1,68 +1,92 @@
package schema
-import (
- "github.com/asymptote-labs/agent-beacon/pkg/asymptotetrace"
-)
+import "github.com/asymptote-labs/agent-beacon/pkg/asymptoteobserve"
const (
- Vendor = asymptotetrace.Vendor
- Product = asymptotetrace.Product
- SchemaVersion = asymptotetrace.SchemaVersion
+ Vendor = asymptoteobserve.Vendor
+ Product = asymptoteobserve.Product
+ SchemaVersion = asymptoteobserve.SchemaVersion
)
-type Severity = asymptotetrace.Severity
+type Severity = asymptoteobserve.Severity
const (
- SeverityInfo = asymptotetrace.SeverityInfo
- SeverityLow = asymptotetrace.SeverityLow
- SeverityMedium = asymptotetrace.SeverityMedium
- SeverityHigh = asymptotetrace.SeverityHigh
- SeverityCritical = asymptotetrace.SeverityCritical
+ SeverityInfo = asymptoteobserve.SeverityInfo
+ SeverityLow = asymptoteobserve.SeverityLow
+ SeverityMedium = asymptoteobserve.SeverityMedium
+ SeverityHigh = asymptoteobserve.SeverityHigh
+ SeverityCritical = asymptoteobserve.SeverityCritical
)
-type Origin = asymptotetrace.Origin
+type Origin = asymptoteobserve.Origin
const (
- OriginLocal = asymptotetrace.OriginLocal
- OriginCloud = asymptotetrace.OriginCloud
- OriginCI = asymptotetrace.OriginCI
+ OriginLocal = asymptoteobserve.OriginLocal
+ OriginCloud = asymptoteobserve.OriginCloud
+ OriginCI = asymptoteobserve.OriginCI
)
const (
- AttributeOrigin = asymptotetrace.AttributeOrigin
- AttributeRunProvider = asymptotetrace.AttributeRunProvider
- AttributeRunID = asymptotetrace.AttributeRunID
- AttributeRunAttempt = asymptotetrace.AttributeRunAttempt
- AttributeRunWorkflow = asymptotetrace.AttributeRunWorkflow
- AttributeRunJob = asymptotetrace.AttributeRunJob
- AttributeRunEventName = asymptotetrace.AttributeRunEventName
- AttributeRunCommit = asymptotetrace.AttributeRunCommit
- AttributeRunRepository = asymptotetrace.AttributeRunRepository
- AttributeRunBranch = asymptotetrace.AttributeRunBranch
- AttributeRunPR = asymptotetrace.AttributeRunPR
- AttributeRunPRNumber = asymptotetrace.AttributeRunPRNumber
- AttributeRunActor = asymptotetrace.AttributeRunActor
- AttributeRunEphemeral = asymptotetrace.AttributeRunEphemeral
+ AttributeOrigin = asymptoteobserve.AttributeOrigin
+ AttributeRunProvider = asymptoteobserve.AttributeRunProvider
+ AttributeRunID = asymptoteobserve.AttributeRunID
+ AttributeRunAttempt = asymptoteobserve.AttributeRunAttempt
+ AttributeRunWorkflow = asymptoteobserve.AttributeRunWorkflow
+ AttributeRunJob = asymptoteobserve.AttributeRunJob
+ AttributeRunEventName = asymptoteobserve.AttributeRunEventName
+ AttributeRunCommit = asymptoteobserve.AttributeRunCommit
+ AttributeRunRepository = asymptoteobserve.AttributeRunRepository
+ AttributeRunBranch = asymptoteobserve.AttributeRunBranch
+ AttributeRunPR = asymptoteobserve.AttributeRunPR
+ AttributeRunPRNumber = asymptoteobserve.AttributeRunPRNumber
+ AttributeRunActor = asymptoteobserve.AttributeRunActor
+ AttributeRunEphemeral = asymptoteobserve.AttributeRunEphemeral
)
-type EventInfo = asymptotetrace.EventInfo
-type EndpointInfo = asymptotetrace.EndpointInfo
-type UserInfo = asymptotetrace.UserInfo
-type HarnessInfo = asymptotetrace.HarnessInfo
-type SessionInfo = asymptotetrace.SessionInfo
-type RunInfo = asymptotetrace.RunInfo
-type ToolInfo = asymptotetrace.ToolInfo
-type FileInfo = asymptotetrace.FileInfo
-type CommandInfo = asymptotetrace.CommandInfo
-type MCPInfo = asymptotetrace.MCPInfo
-type ApprovalInfo = asymptotetrace.ApprovalInfo
-type PolicyInfo = asymptotetrace.PolicyInfo
-type PromptInfo = asymptotetrace.PromptInfo
-type ContentInfo = asymptotetrace.ContentInfo
-type DestinationInfo = asymptotetrace.DestinationInfo
-type HealthInfo = asymptotetrace.HealthInfo
-type Event = asymptotetrace.Event
-type NewEventOptions = asymptotetrace.NewEventOptions
-type Envelope = asymptotetrace.Envelope
+type EventInfo = asymptoteobserve.EventInfo
+type EndpointInfo = asymptoteobserve.EndpointInfo
+type UserInfo = asymptoteobserve.UserInfo
+type HarnessInfo = asymptoteobserve.HarnessInfo
+type SessionInfo = asymptoteobserve.SessionInfo
+type RunInfo = asymptoteobserve.RunInfo
+type ToolInfo = asymptoteobserve.ToolInfo
+type FileInfo = asymptoteobserve.FileInfo
+type CommandInfo = asymptoteobserve.CommandInfo
+type MCPInfo = asymptoteobserve.MCPInfo
+type MCPMethodInfo = asymptoteobserve.MCPMethodInfo
+type MCPProtocolInfo = asymptoteobserve.MCPProtocolInfo
+type MCPResourceInfo = asymptoteobserve.MCPResourceInfo
+type MCPSessionInfo = asymptoteobserve.MCPSessionInfo
+type ApprovalInfo = asymptoteobserve.ApprovalInfo
+type PolicyInfo = asymptoteobserve.PolicyInfo
+type PromptInfo = asymptoteobserve.PromptInfo
+type DestinationInfo = asymptoteobserve.DestinationInfo
+type HealthInfo = asymptoteobserve.HealthInfo
+type GenAIInfo = asymptoteobserve.GenAIInfo
+type GenAIAgentInfo = asymptoteobserve.GenAIAgentInfo
+type GenAIConversationInfo = asymptoteobserve.GenAIConversationInfo
+type GenAIDataSourceInfo = asymptoteobserve.GenAIDataSourceInfo
+type GenAIEmbeddingsInfo = asymptoteobserve.GenAIEmbeddingsInfo
+type GenAIEvaluationInfo = asymptoteobserve.GenAIEvaluationInfo
+type GenAIEvaluationScoreInfo = asymptoteobserve.GenAIEvaluationScoreInfo
+type GenAIInputInfo = asymptoteobserve.GenAIInputInfo
+type GenAIOperationInfo = asymptoteobserve.GenAIOperationInfo
+type GenAIOutputInfo = asymptoteobserve.GenAIOutputInfo
+type GenAIPromptInfo = asymptoteobserve.GenAIPromptInfo
+type GenAIProviderInfo = asymptoteobserve.GenAIProviderInfo
+type GenAIRequestInfo = asymptoteobserve.GenAIRequestInfo
+type GenAIResponseInfo = asymptoteobserve.GenAIResponseInfo
+type GenAIRetrievalInfo = asymptoteobserve.GenAIRetrievalInfo
+type GenAITokenInfo = asymptoteobserve.GenAITokenInfo
+type GenAIToolInfo = asymptoteobserve.GenAIToolInfo
+type GenAIToolCallInfo = asymptoteobserve.GenAIToolCallInfo
+type GenAIUsageInfo = asymptoteobserve.GenAIUsageInfo
+type GenAIUsageCacheCreationInfo = asymptoteobserve.GenAIUsageCacheCreationInfo
+type GenAIUsageCacheReadInfo = asymptoteobserve.GenAIUsageCacheReadInfo
+type GenAIUsageReasoningInfo = asymptoteobserve.GenAIUsageReasoningInfo
+type GenAIWorkflowInfo = asymptoteobserve.GenAIWorkflowInfo
+type Event = asymptoteobserve.Event
+type NewEventOptions = asymptoteobserve.NewEventOptions
+type Envelope = asymptoteobserve.Envelope
-var NewEvent = asymptotetrace.NewEvent
+var NewEvent = asymptoteobserve.NewEvent
diff --git a/cli/beacon/internal/endpoint/schema/event_test.go b/cli/beacon/internal/endpoint/schema/event_test.go
index f2a7fab8..e12ef6ff 100644
--- a/cli/beacon/internal/endpoint/schema/event_test.go
+++ b/cli/beacon/internal/endpoint/schema/event_test.go
@@ -36,25 +36,14 @@ func TestNewEventSetsRequiredInvariants(t *testing.T) {
}
event.File = &FileInfo{Path: "main.go", Operation: "modify"}
event.Command = &CommandInfo{Command: "go test ./..."}
- event.MCP = &MCPInfo{Server: "github", Tool: "get_issue"}
+ event.MCP = &MCPInfo{Server: "github", Tool: "get_issue", Method: &MCPMethodInfo{Name: "tools/call"}}
event.Prompt = &PromptInfo{Text: "Summarize this file"}
+ event.GenAI = &GenAIInfo{Provider: &GenAIProviderInfo{Name: "openai"}, Request: &GenAIRequestInfo{Model: "gpt-4o"}}
if err := event.Validate(); err != nil {
t.Fatalf("Validate rejected optional telemetry fields: %v", err)
}
}
-func TestValidateToleratesHistoricalContentField(t *testing.T) {
- event := NewEvent(NewEventOptions{
- Action: "tool.invoked",
- Harness: HarnessInfo{Name: "cursor"},
- })
- event.Content = &ContentInfo{Retention: "metadata", Included: false}
-
- if err := event.Validate(); err != nil {
- t.Fatalf("Validate rejected historical content field: %v", err)
- }
-}
-
func TestValidateRejectsMissingOrInvalidRequiredFields(t *testing.T) {
valid := NewEvent(NewEventOptions{
Action: "tool.invoked",
diff --git a/cli/beacon/internal/endpoint/writer/writer.go b/cli/beacon/internal/endpoint/writer/writer.go
index 5c252b18..5312cb00 100644
--- a/cli/beacon/internal/endpoint/writer/writer.go
+++ b/cli/beacon/internal/endpoint/writer/writer.go
@@ -11,7 +11,7 @@ import (
"syscall"
"github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/schema"
- "github.com/asymptote-labs/agent-beacon/pkg/asymptotetrace"
+ "github.com/asymptote-labs/agent-beacon/pkg/asymptoteobserve"
)
const (
@@ -65,7 +65,7 @@ func AppendEvent(event schema.Event, opts Options) (string, error) {
}
if len(data) > opts.MaxBytes {
event.Raw = nil
- event.Message = asymptotetrace.TruncateString(event.Message, 1024)
+ event.Message = asymptoteobserve.TruncateString(event.Message, 1024)
event.Truncated = true
data, err = json.Marshal(event)
if err != nil {
@@ -100,7 +100,7 @@ func LastLine(path string) (string, error) {
}
func SanitizeEvent(event schema.Event, maxBytes int) schema.Event {
- return asymptotetrace.SanitizeEvent(event, maxBytes)
+ return asymptoteobserve.SanitizeEvent(event, maxBytes)
}
func appendJSONL(path string, line []byte, rotateBytes int64, rotateArchives int) error {
diff --git a/collector-builder/builder.yaml b/collector-builder/builder.yaml
index 0c794a6e..e2a5efee 100644
--- a/collector-builder/builder.yaml
+++ b/collector-builder/builder.yaml
@@ -22,7 +22,7 @@ extensions:
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension v0.121.0
replaces:
- - github.com/asymptote-labs/agent-beacon/pkg/asymptotetrace => ../../../pkg/asymptotetrace
+ - github.com/asymptote-labs/agent-beacon/pkg/asymptoteobserve => ../../../pkg/asymptoteobserve
- go.opentelemetry.io/otel/exporters/stdout/stdoutlog => go.opentelemetry.io/otel/exporters/stdout/stdoutlog v0.19.0
- go.opentelemetry.io/otel/log => go.opentelemetry.io/otel/log v0.19.0
- go.opentelemetry.io/otel/log/logtest => go.opentelemetry.io/otel/log/logtest v0.19.0
diff --git a/collector-builder/exporter/beaconjsonexporter/config.go b/collector-builder/exporter/beaconjsonexporter/config.go
index 5807160b..14e4eee0 100644
--- a/collector-builder/exporter/beaconjsonexporter/config.go
+++ b/collector-builder/exporter/beaconjsonexporter/config.go
@@ -10,13 +10,11 @@ const (
// Config controls local JSONL export for Beacon endpoint events.
type Config struct {
- Path string `mapstructure:"path"`
- MaxEventBytes int `mapstructure:"max_event_bytes"`
- RotateBytes int64 `mapstructure:"rotate_bytes"`
- RotateArchives int `mapstructure:"rotate_archives"`
- RedactSecrets bool `mapstructure:"redact_secrets"`
- // Deprecated no-op retained so older generated collector configs still load.
- ContentRetention string `mapstructure:"content_retention"`
+ Path string `mapstructure:"path"`
+ MaxEventBytes int `mapstructure:"max_event_bytes"`
+ RotateBytes int64 `mapstructure:"rotate_bytes"`
+ RotateArchives int `mapstructure:"rotate_archives"`
+ RedactSecrets bool `mapstructure:"redact_secrets"`
IncludeRuntimeMetrics bool `mapstructure:"include_runtime_metrics"`
IncludeCodexSpans bool `mapstructure:"include_codex_spans"`
}
diff --git a/collector-builder/exporter/beaconjsonexporter/event.go b/collector-builder/exporter/beaconjsonexporter/event.go
index 59260343..63bc295f 100644
--- a/collector-builder/exporter/beaconjsonexporter/event.go
+++ b/collector-builder/exporter/beaconjsonexporter/event.go
@@ -23,7 +23,6 @@ type commandInfo = beaconevent.CommandInfo
type mcpInfo = beaconevent.MCPInfo
type approvalInfo = beaconevent.ApprovalInfo
type promptInfo = beaconevent.PromptInfo
-type contentInfo = beaconevent.ContentInfo
type beaconEvent = beaconevent.Event
func newBeaconEvent(action, category, severity, harnessName string, ts time.Time) beaconEvent {
diff --git a/collector-builder/exporter/beaconjsonexporter/exporter_test.go b/collector-builder/exporter/beaconjsonexporter/exporter_test.go
index f4983e18..e61a5087 100644
--- a/collector-builder/exporter/beaconjsonexporter/exporter_test.go
+++ b/collector-builder/exporter/beaconjsonexporter/exporter_test.go
@@ -3,6 +3,7 @@ package beaconjsonexporter
import (
"context"
"encoding/json"
+ "fmt"
"os"
"path/filepath"
"strconv"
@@ -10,7 +11,7 @@ import (
"testing"
"time"
- "github.com/asymptote-labs/agent-beacon/pkg/asymptotetrace"
+ "github.com/asymptote-labs/agent-beacon/pkg/asymptoteobserve"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/pdata/plog"
"go.opentelemetry.io/collector/pdata/pmetric"
@@ -28,13 +29,6 @@ func TestConfigValidateRequiresPath(t *testing.T) {
}
}
-func TestDefaultConfigLeavesLegacyRetentionUnset(t *testing.T) {
- cfg := createDefaultConfig()
- if cfg.ContentRetention != "" {
- t.Fatalf("ContentRetention = %q, want empty legacy no-op", cfg.ContentRetention)
- }
-}
-
func TestDefaultConfigUsesBoundedRotation(t *testing.T) {
cfg := createDefaultConfig()
if cfg.RotateBytes != defaultRotateBytes {
@@ -45,22 +39,6 @@ func TestDefaultConfigUsesBoundedRotation(t *testing.T) {
}
}
-func TestNewExporterAcceptsEmptyLegacyRetention(t *testing.T) {
- cfg := &Config{
- Path: filepath.Join(t.TempDir(), "runtime.jsonl"),
- MaxEventBytes: defaultMaxEventBytes,
- RotateBytes: defaultRotateBytes,
- RedactSecrets: true,
- }
- exp, err := newExporter(cfg, exporter.Settings{})
- if err != nil {
- t.Fatalf("newExporter returned error: %v", err)
- }
- if exp.cfg.ContentRetention != "" {
- t.Fatalf("ContentRetention = %q, want empty legacy no-op", exp.cfg.ContentRetention)
- }
-}
-
func TestNewExporterNormalizesRotationDefaults(t *testing.T) {
cfg := &Config{
Path: filepath.Join(t.TempDir(), "runtime.jsonl"),
@@ -120,11 +98,10 @@ func TestJSONLWriterRotatesAndPrunesArchives(t *testing.T) {
func TestConsumeLogsWritesBeaconJSONL(t *testing.T) {
path := filepath.Join(t.TempDir(), "runtime.jsonl")
exp, err := newExporter(&Config{
- Path: path,
- MaxEventBytes: defaultMaxEventBytes,
- RotateBytes: defaultRotateBytes,
- RedactSecrets: true,
- ContentRetention: "redacted",
+ Path: path,
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
}, exporter.Settings{})
if err != nil {
t.Fatalf("newExporter returned error: %v", err)
@@ -172,11 +149,10 @@ func TestConsumeLogsWritesBeaconJSONL(t *testing.T) {
func TestConsumeLogsMapsCIRunResourceAttributes(t *testing.T) {
path := filepath.Join(t.TempDir(), "runtime.jsonl")
exp, err := newExporter(&Config{
- Path: path,
- MaxEventBytes: defaultMaxEventBytes,
- RotateBytes: defaultRotateBytes,
- RedactSecrets: true,
- ContentRetention: "metadata",
+ Path: path,
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
}, exporter.Settings{})
if err != nil {
t.Fatalf("newExporter returned error: %v", err)
@@ -188,20 +164,20 @@ func TestConsumeLogsMapsCIRunResourceAttributes(t *testing.T) {
resourceAttrs.PutStr("service.name", "claude-code")
resourceAttrs.PutStr("repository", "local/repo")
resourceAttrs.PutStr("branch", "local-branch")
- resourceAttrs.PutStr(asymptotetrace.AttributeOrigin, string(asymptotetrace.OriginCI))
- resourceAttrs.PutStr(asymptotetrace.AttributeRunProvider, "github_actions")
- resourceAttrs.PutStr(asymptotetrace.AttributeRunID, "123")
- resourceAttrs.PutStr(asymptotetrace.AttributeRunAttempt, "2")
- resourceAttrs.PutStr(asymptotetrace.AttributeRunWorkflow, "CI / build, smoke")
- resourceAttrs.PutStr(asymptotetrace.AttributeRunJob, "telemetry")
- resourceAttrs.PutStr(asymptotetrace.AttributeRunEventName, "pull_request")
- resourceAttrs.PutStr(asymptotetrace.AttributeRunCommit, "deadbeef")
- resourceAttrs.PutStr(asymptotetrace.AttributeRunRepository, "asymptote-labs/agent-beacon")
- resourceAttrs.PutStr(asymptotetrace.AttributeRunBranch, "feature/ci telemetry")
- resourceAttrs.PutStr(asymptotetrace.AttributeRunPR, "refs/pull/12/merge")
- resourceAttrs.PutStr(asymptotetrace.AttributeRunPRNumber, "12")
- resourceAttrs.PutStr(asymptotetrace.AttributeRunActor, "octocat")
- resourceAttrs.PutBool(asymptotetrace.AttributeRunEphemeral, true)
+ resourceAttrs.PutStr(asymptoteobserve.AttributeOrigin, string(asymptoteobserve.OriginCI))
+ resourceAttrs.PutStr(asymptoteobserve.AttributeRunProvider, "github_actions")
+ resourceAttrs.PutStr(asymptoteobserve.AttributeRunID, "123")
+ resourceAttrs.PutStr(asymptoteobserve.AttributeRunAttempt, "2")
+ resourceAttrs.PutStr(asymptoteobserve.AttributeRunWorkflow, "CI / build, smoke")
+ resourceAttrs.PutStr(asymptoteobserve.AttributeRunJob, "telemetry")
+ resourceAttrs.PutStr(asymptoteobserve.AttributeRunEventName, "pull_request")
+ resourceAttrs.PutStr(asymptoteobserve.AttributeRunCommit, "deadbeef")
+ resourceAttrs.PutStr(asymptoteobserve.AttributeRunRepository, "asymptote-labs/agent-beacon")
+ resourceAttrs.PutStr(asymptoteobserve.AttributeRunBranch, "feature/ci telemetry")
+ resourceAttrs.PutStr(asymptoteobserve.AttributeRunPR, "refs/pull/12/merge")
+ resourceAttrs.PutStr(asymptoteobserve.AttributeRunPRNumber, "12")
+ resourceAttrs.PutStr(asymptoteobserve.AttributeRunActor, "octocat")
+ resourceAttrs.PutBool(asymptoteobserve.AttributeRunEphemeral, true)
rec := rl.ScopeLogs().AppendEmpty().LogRecords().AppendEmpty()
rec.Body().SetStr("ci telemetry event")
rec.Attributes().PutStr("beacon.event.action", "tool.invoked")
@@ -217,7 +193,7 @@ func TestConsumeLogsMapsCIRunResourceAttributes(t *testing.T) {
if err := json.Unmarshal([]byte(strings.TrimSpace(string(data))), &event); err != nil {
t.Fatalf("unmarshal event: %v", err)
}
- if event.Origin != asymptotetrace.OriginCI {
+ if event.Origin != asymptoteobserve.OriginCI {
t.Fatalf("Origin = %q, want ci", event.Origin)
}
if event.Run == nil {
@@ -237,14 +213,13 @@ func TestConsumeLogsMapsCIRunResourceAttributes(t *testing.T) {
}
}
-func TestConsumeLogsMapsPromptForFullRetention(t *testing.T) {
+func TestConsumeLogsMapsPrompt(t *testing.T) {
path := filepath.Join(t.TempDir(), "runtime.jsonl")
exp, err := newExporter(&Config{
- Path: path,
- MaxEventBytes: defaultMaxEventBytes,
- RotateBytes: defaultRotateBytes,
- RedactSecrets: true,
- ContentRetention: "full",
+ Path: path,
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
}, exporter.Settings{})
if err != nil {
t.Fatalf("newExporter returned error: %v", err)
@@ -274,13 +249,12 @@ func TestConsumeLogsMapsPromptForFullRetention(t *testing.T) {
}
}
-func TestLegacyMetadataRetentionDoesNotOmitTypedPrompt(t *testing.T) {
+func TestEventFromLogKeepsTypedPrompt(t *testing.T) {
exp, err := newExporter(&Config{
- Path: filepath.Join(t.TempDir(), "runtime.jsonl"),
- MaxEventBytes: defaultMaxEventBytes,
- RotateBytes: defaultRotateBytes,
- RedactSecrets: true,
- ContentRetention: "metadata",
+ Path: filepath.Join(t.TempDir(), "runtime.jsonl"),
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
}, exporter.Settings{})
if err != nil {
t.Fatalf("newExporter returned error: %v", err)
@@ -299,8 +273,157 @@ func TestLegacyMetadataRetentionDoesNotOmitTypedPrompt(t *testing.T) {
if event.Prompt == nil || event.Prompt.Text != "summarize this file" {
t.Fatalf("legacy metadata retention should not omit prompt: %#v", event.Prompt)
}
- if event.Content != nil {
- t.Fatalf("legacy metadata retention should not emit content marker: %#v", event.Content)
+}
+
+func TestConsumeLogsMapsOTelGenAIAttributes(t *testing.T) {
+ path := filepath.Join(t.TempDir(), "runtime.jsonl")
+ exp, err := newExporter(&Config{
+ Path: path,
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
+ }, exporter.Settings{})
+ if err != nil {
+ t.Fatalf("newExporter returned error: %v", err)
+ }
+
+ logs := plog.NewLogs()
+ rec := logs.ResourceLogs().AppendEmpty().ScopeLogs().AppendEmpty().LogRecords().AppendEmpty()
+ rec.Attributes().PutStr("service.name", "otel")
+ rec.Attributes().PutStr("gen_ai.operation.name", "chat")
+ rec.Attributes().PutStr("gen_ai.provider.name", "openai")
+ rec.Attributes().PutStr("gen_ai.conversation.id", "conv-1")
+ rec.Attributes().PutStr("gen_ai.request.model", "gpt-4o")
+ rec.Attributes().PutInt("gen_ai.request.max_tokens", 100)
+ rec.Attributes().PutDouble("gen_ai.request.temperature", 0.2)
+ rec.Attributes().PutStr("gen_ai.response.id", "chatcmpl-1")
+ rec.Attributes().PutStr("gen_ai.response.model", "gpt-4o-2026")
+ rec.Attributes().PutInt("gen_ai.usage.input_tokens", 12)
+ rec.Attributes().PutInt("gen_ai.usage.output_tokens", 34)
+ rec.Attributes().PutStr("gen_ai.input.messages", `[{"role":"user","parts":[{"type":"text","content":"summarize token=genai-secret"}]}]`)
+ reasons := rec.Attributes().PutEmptySlice("gen_ai.response.finish_reasons")
+ reasons.AppendEmpty().SetStr("stop")
+
+ if err := exp.consumeLogs(context.Background(), logs); err != nil {
+ t.Fatalf("consumeLogs returned error: %v", err)
+ }
+ data, err := os.ReadFile(path)
+ if err != nil {
+ t.Fatalf("read runtime log: %v", err)
+ }
+ if strings.Contains(string(data), "genai-secret") {
+ t.Fatalf("GenAI content was not redacted: %s", string(data))
+ }
+ var event beaconEvent
+ if err := json.Unmarshal([]byte(strings.TrimSpace(string(data))), &event); err != nil {
+ t.Fatalf("unmarshal event: %v", err)
+ }
+ if event.GenAI == nil || event.GenAI.Provider == nil || event.GenAI.Provider.Name != "openai" {
+ t.Fatalf("provider missing from GenAI: %#v", event.GenAI)
+ }
+ if event.GenAI.Request == nil || event.GenAI.Request.Model != "gpt-4o" || event.GenAI.Request.MaxTokens == nil || *event.GenAI.Request.MaxTokens != 100 {
+ t.Fatalf("request missing from GenAI: %#v", event.GenAI.Request)
+ }
+ if event.GenAI.Response == nil || event.GenAI.Response.ID != "chatcmpl-1" || len(event.GenAI.Response.FinishReasons) != 1 || event.GenAI.Response.FinishReasons[0] != "stop" {
+ t.Fatalf("response missing from GenAI: %#v", event.GenAI.Response)
+ }
+ if event.GenAI.Usage == nil || event.GenAI.Usage.InputTokens == nil || *event.GenAI.Usage.InputTokens != 12 || event.GenAI.Usage.OutputTokens == nil || *event.GenAI.Usage.OutputTokens != 34 {
+ t.Fatalf("usage missing from GenAI: %#v", event.GenAI.Usage)
+ }
+ if event.Session == nil || event.Session.ID != "conv-1" {
+ t.Fatalf("conversation not promoted to session: %#v", event.Session)
+ }
+ if event.Model != "gpt-4o" {
+ t.Fatalf("model = %q, want request model", event.Model)
+ }
+ if event.Prompt == nil || !strings.Contains(event.Prompt.Text, "[REDACTED]") {
+ t.Fatalf("prompt was not populated and redacted: %#v", event.Prompt)
+ }
+}
+
+func TestEventFromLogMapsLegacyOpenLLMetryMessages(t *testing.T) {
+ exp, err := newExporter(&Config{
+ Path: filepath.Join(t.TempDir(), "runtime.jsonl"),
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
+ }, exporter.Settings{})
+ if err != nil {
+ t.Fatalf("newExporter returned error: %v", err)
+ }
+ rec := plog.NewLogs().ResourceLogs().AppendEmpty().ScopeLogs().AppendEmpty().LogRecords().AppendEmpty()
+ rec.Attributes().PutStr("gen_ai.operation.name", "chat")
+ rec.Attributes().PutStr("gen_ai.prompt.0.content", "hello")
+ rec.Attributes().PutStr("gen_ai.completion.0.content", "hi there")
+ rec.Attributes().PutStr("llm.usage.prompt_tokens", "3")
+ rec.Attributes().PutStr("llm.usage.completion_tokens", "4")
+
+ event := exp.eventFromLog(nil, rec)
+ if event.GenAI == nil || event.GenAI.Input == nil || event.GenAI.Output == nil {
+ t.Fatalf("legacy messages not mapped: %#v", event.GenAI)
+ }
+ if text := testFirstTextFromAny(event.GenAI.Input.Messages); text != "hello" {
+ t.Fatalf("input message text = %q, want hello", text)
+ }
+ if text := testFirstTextFromAny(event.GenAI.Output.Messages); text != "hi there" {
+ t.Fatalf("output message text = %q, want hi there", text)
+ }
+ if event.GenAI.Usage == nil || event.GenAI.Usage.InputTokens == nil || *event.GenAI.Usage.InputTokens != 3 || event.GenAI.Usage.OutputTokens == nil || *event.GenAI.Usage.OutputTokens != 4 {
+ t.Fatalf("legacy token usage not mapped: %#v", event.GenAI.Usage)
+ }
+}
+
+func testFirstTextFromAny(value interface{}) string {
+ switch typed := value.(type) {
+ case string:
+ return typed
+ case []interface{}:
+ for _, item := range typed {
+ if text := testFirstTextFromAny(item); text != "" {
+ return text
+ }
+ }
+ case map[string]interface{}:
+ if content, ok := typed["content"]; ok {
+ return strings.TrimSpace(fmt.Sprint(content))
+ }
+ if parts, ok := typed["parts"]; ok {
+ return testFirstTextFromAny(parts)
+ }
+ }
+ return ""
+}
+
+func TestEventFromLogMapsOTelMCPAttributes(t *testing.T) {
+ exp, err := newExporter(&Config{
+ Path: filepath.Join(t.TempDir(), "runtime.jsonl"),
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
+ }, exporter.Settings{})
+ if err != nil {
+ t.Fatalf("newExporter returned error: %v", err)
+ }
+ rec := plog.NewLogs().ResourceLogs().AppendEmpty().ScopeLogs().AppendEmpty().LogRecords().AppendEmpty()
+ rec.Attributes().PutStr("mcp.method.name", "resources/read")
+ rec.Attributes().PutStr("mcp.protocol.version", "2025-06-18")
+ rec.Attributes().PutStr("mcp.resource.uri", "file:///tmp/report.md")
+ rec.Attributes().PutStr("mcp.session.id", "mcp-session-1")
+ rec.Attributes().PutStr("mcp.server.name", "filesystem")
+ rec.Attributes().PutStr("mcp.tool.name", "read_file")
+
+ event := exp.eventFromLog(nil, rec)
+ if event.Event.Action != "file.read" || event.Event.Category != "file" {
+ t.Fatalf("MCP resource action/category = %#v, want file.read/file", event.Event)
+ }
+ if event.MCP == nil || event.MCP.Method == nil || event.MCP.Method.Name != "resources/read" || event.MCP.Protocol == nil || event.MCP.Protocol.Version != "2025-06-18" {
+ t.Fatalf("MCP method/protocol missing: %#v", event.MCP)
+ }
+ if event.MCP.Resource == nil || event.MCP.Resource.URI != "file:///tmp/report.md" || event.MCP.Session == nil || event.MCP.Session.ID != "mcp-session-1" {
+ t.Fatalf("MCP resource/session missing: %#v", event.MCP)
+ }
+ if event.MCP.Server != "filesystem" || event.MCP.Tool != "read_file" {
+ t.Fatalf("Beacon MCP server/tool missing: %#v", event.MCP)
}
}
@@ -327,11 +450,10 @@ func TestEventCategoryInfersFromAction(t *testing.T) {
func TestEventFromMetricDefaultsToObservedAction(t *testing.T) {
exp, err := newExporter(&Config{
- Path: filepath.Join(t.TempDir(), "runtime.jsonl"),
- MaxEventBytes: defaultMaxEventBytes,
- RotateBytes: defaultRotateBytes,
- RedactSecrets: true,
- ContentRetention: "metadata",
+ Path: filepath.Join(t.TempDir(), "runtime.jsonl"),
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
}, exporter.Settings{})
if err != nil {
t.Fatalf("newExporter returned error: %v", err)
@@ -359,11 +481,10 @@ func TestEventFromMetricDefaultsToObservedAction(t *testing.T) {
func TestConsumeMetricsDropsRuntimeMetricsByDefault(t *testing.T) {
path := filepath.Join(t.TempDir(), "runtime.jsonl")
exp, err := newExporter(&Config{
- Path: path,
- MaxEventBytes: defaultMaxEventBytes,
- RotateBytes: defaultRotateBytes,
- RedactSecrets: true,
- ContentRetention: "full",
+ Path: path,
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
}, exporter.Settings{})
if err != nil {
t.Fatalf("newExporter returned error: %v", err)
@@ -400,7 +521,6 @@ func TestConsumeMetricsIncludesRuntimeMetricsWhenConfigured(t *testing.T) {
MaxEventBytes: defaultMaxEventBytes,
RotateBytes: defaultRotateBytes,
RedactSecrets: true,
- ContentRetention: "full",
IncludeRuntimeMetrics: true,
}, exporter.Settings{})
if err != nil {
@@ -426,11 +546,10 @@ func TestConsumeMetricsIncludesRuntimeMetricsWhenConfigured(t *testing.T) {
func TestConsumeMetricsDropsOpenClawMetricsByDefault(t *testing.T) {
path := filepath.Join(t.TempDir(), "runtime.jsonl")
exp, err := newExporter(&Config{
- Path: path,
- MaxEventBytes: defaultMaxEventBytes,
- RotateBytes: defaultRotateBytes,
- RedactSecrets: true,
- ContentRetention: "metadata",
+ Path: path,
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
}, exporter.Settings{})
if err != nil {
t.Fatalf("newExporter returned error: %v", err)
@@ -499,7 +618,6 @@ func TestConsumeMetricsIncludesOpenClawMetricsWhenConfigured(t *testing.T) {
MaxEventBytes: defaultMaxEventBytes,
RotateBytes: defaultRotateBytes,
RedactSecrets: true,
- ContentRetention: "metadata",
IncludeRuntimeMetrics: true,
}, exporter.Settings{})
if err != nil {
@@ -538,11 +656,10 @@ func TestConsumeMetricsIncludesOpenClawMetricsWhenConfigured(t *testing.T) {
func TestConsumeMetricsDropsCodexMetricsByDefault(t *testing.T) {
path := filepath.Join(t.TempDir(), "runtime.jsonl")
exp, err := newExporter(&Config{
- Path: path,
- MaxEventBytes: defaultMaxEventBytes,
- RotateBytes: defaultRotateBytes,
- RedactSecrets: true,
- ContentRetention: "metadata",
+ Path: path,
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
}, exporter.Settings{})
if err != nil {
t.Fatalf("newExporter returned error: %v", err)
@@ -575,11 +692,10 @@ func TestConsumeMetricsDropsCodexMetricsByDefault(t *testing.T) {
func TestConsumeMetricsDropsCopilotMetricsByDefault(t *testing.T) {
path := filepath.Join(t.TempDir(), "runtime.jsonl")
exp, err := newExporter(&Config{
- Path: path,
- MaxEventBytes: defaultMaxEventBytes,
- RotateBytes: defaultRotateBytes,
- RedactSecrets: true,
- ContentRetention: "metadata",
+ Path: path,
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
}, exporter.Settings{})
if err != nil {
t.Fatalf("newExporter returned error: %v", err)
@@ -642,7 +758,6 @@ func TestConsumeMetricsIncludesCopilotOperationalMetricsWhenConfigured(t *testin
MaxEventBytes: defaultMaxEventBytes,
RotateBytes: defaultRotateBytes,
RedactSecrets: true,
- ContentRetention: "metadata",
IncludeRuntimeMetrics: true,
}, exporter.Settings{})
if err != nil {
@@ -696,11 +811,10 @@ func TestInferActionMapsCodexOpAttributeToPrompt(t *testing.T) {
func TestConsumeTracesDropsCodexUserInputSpan(t *testing.T) {
path := filepath.Join(t.TempDir(), "runtime.jsonl")
exp, err := newExporter(&Config{
- Path: path,
- MaxEventBytes: defaultMaxEventBytes,
- RotateBytes: defaultRotateBytes,
- RedactSecrets: true,
- ContentRetention: "full",
+ Path: path,
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
}, exporter.Settings{})
if err != nil {
t.Fatalf("newExporter returned error: %v", err)
@@ -731,7 +845,6 @@ func TestConsumeTracesIncludesCodexSpansWhenConfigured(t *testing.T) {
MaxEventBytes: defaultMaxEventBytes,
RotateBytes: defaultRotateBytes,
RedactSecrets: true,
- ContentRetention: "full",
IncludeCodexSpans: true,
}, exporter.Settings{})
if err != nil {
@@ -768,11 +881,10 @@ func TestConsumeTracesIncludesCodexSpansWhenConfigured(t *testing.T) {
func TestConsumeLogsMapsCodexSemanticEventsAndDropsTransportNoise(t *testing.T) {
path := filepath.Join(t.TempDir(), "runtime.jsonl")
exp, err := newExporter(&Config{
- Path: path,
- MaxEventBytes: defaultMaxEventBytes,
- RotateBytes: defaultRotateBytes,
- RedactSecrets: true,
- ContentRetention: "full",
+ Path: path,
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
}, exporter.Settings{})
if err != nil {
t.Fatalf("newExporter returned error: %v", err)
@@ -869,13 +981,12 @@ func TestCodexToolResultExtractsShellCommand(t *testing.T) {
}
}
-func TestLegacyMetadataRetentionDoesNotOmitCodexPromptMessage(t *testing.T) {
+func TestCodexPromptMessageKeepsTypedPrompt(t *testing.T) {
exp, err := newExporter(&Config{
- Path: filepath.Join(t.TempDir(), "runtime.jsonl"),
- MaxEventBytes: defaultMaxEventBytes,
- RotateBytes: defaultRotateBytes,
- RedactSecrets: true,
- ContentRetention: "metadata",
+ Path: filepath.Join(t.TempDir(), "runtime.jsonl"),
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
}, exporter.Settings{})
if err != nil {
t.Fatalf("newExporter returned error: %v", err)
@@ -893,19 +1004,15 @@ func TestLegacyMetadataRetentionDoesNotOmitCodexPromptMessage(t *testing.T) {
if strings.Contains(event.Message, "codex-secret") {
t.Fatalf("message leaked unredacted prompt secret: %q", event.Message)
}
- if event.Content != nil {
- t.Fatalf("legacy metadata retention should not emit content marker: %#v", event.Content)
- }
}
func TestConsumeLogsMapsGeminiPrompt(t *testing.T) {
path := filepath.Join(t.TempDir(), "runtime.jsonl")
exp, err := newExporter(&Config{
- Path: path,
- MaxEventBytes: defaultMaxEventBytes,
- RotateBytes: defaultRotateBytes,
- RedactSecrets: true,
- ContentRetention: "full",
+ Path: path,
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
}, exporter.Settings{})
if err != nil {
t.Fatalf("newExporter returned error: %v", err)
@@ -948,11 +1055,10 @@ func TestConsumeLogsMapsGeminiPrompt(t *testing.T) {
func TestConsumeLogsMapsGeminiMCPTool(t *testing.T) {
path := filepath.Join(t.TempDir(), "runtime.jsonl")
exp, err := newExporter(&Config{
- Path: path,
- MaxEventBytes: defaultMaxEventBytes,
- RotateBytes: defaultRotateBytes,
- RedactSecrets: true,
- ContentRetention: "metadata",
+ Path: path,
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
}, exporter.Settings{})
if err != nil {
t.Fatalf("newExporter returned error: %v", err)
@@ -997,11 +1103,10 @@ func TestConsumeLogsMapsGeminiMCPTool(t *testing.T) {
func TestConsumeLogsMapsGeminiFileOperation(t *testing.T) {
exp, err := newExporter(&Config{
- Path: filepath.Join(t.TempDir(), "runtime.jsonl"),
- MaxEventBytes: defaultMaxEventBytes,
- RotateBytes: defaultRotateBytes,
- RedactSecrets: true,
- ContentRetention: "metadata",
+ Path: filepath.Join(t.TempDir(), "runtime.jsonl"),
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
}, exporter.Settings{})
if err != nil {
t.Fatalf("newExporter returned error: %v", err)
@@ -1033,11 +1138,10 @@ func TestInferActionMapsGeminiApprovalEvents(t *testing.T) {
func TestLegacyMetadataRetentionKeepsRawAttributes(t *testing.T) {
exp, err := newExporter(&Config{
- Path: filepath.Join(t.TempDir(), "runtime.jsonl"),
- MaxEventBytes: defaultMaxEventBytes,
- RotateBytes: defaultRotateBytes,
- RedactSecrets: true,
- ContentRetention: "metadata",
+ Path: filepath.Join(t.TempDir(), "runtime.jsonl"),
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
}, exporter.Settings{})
if err != nil {
t.Fatalf("newExporter returned error: %v", err)
@@ -1074,11 +1178,10 @@ func TestCodexInternalSpanFilter(t *testing.T) {
func TestConsumeTracesDropsCodexInternalSpans(t *testing.T) {
path := filepath.Join(t.TempDir(), "runtime.jsonl")
exp, err := newExporter(&Config{
- Path: path,
- MaxEventBytes: defaultMaxEventBytes,
- RotateBytes: defaultRotateBytes,
- RedactSecrets: true,
- ContentRetention: "metadata",
+ Path: path,
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
}, exporter.Settings{})
if err != nil {
t.Fatalf("newExporter returned error: %v", err)
@@ -1219,11 +1322,10 @@ func TestCopilotSpanActions(t *testing.T) {
func TestVSCodeCopilotDropsNoisySpansByDefault(t *testing.T) {
path := filepath.Join(t.TempDir(), "runtime.jsonl")
exp, err := newExporter(&Config{
- Path: path,
- MaxEventBytes: defaultMaxEventBytes,
- RotateBytes: defaultRotateBytes,
- RedactSecrets: true,
- ContentRetention: "metadata",
+ Path: path,
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
}, exporter.Settings{})
if err != nil {
t.Fatalf("newExporter returned error: %v", err)
@@ -1260,11 +1362,10 @@ func TestVSCodeCopilotDropsNoisySpansByDefault(t *testing.T) {
func TestVSCodeCopilotDropsNoisyMetricsByDefault(t *testing.T) {
path := filepath.Join(t.TempDir(), "runtime.jsonl")
exp, err := newExporter(&Config{
- Path: path,
- MaxEventBytes: defaultMaxEventBytes,
- RotateBytes: defaultRotateBytes,
- RedactSecrets: true,
- ContentRetention: "metadata",
+ Path: path,
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
}, exporter.Settings{})
if err != nil {
t.Fatalf("newExporter returned error: %v", err)
@@ -1291,11 +1392,10 @@ func TestVSCodeCopilotDropsNoisyMetricsByDefault(t *testing.T) {
func TestVSCodeCopilotKeepsActivityLogs(t *testing.T) {
path := filepath.Join(t.TempDir(), "runtime.jsonl")
exp, err := newExporter(&Config{
- Path: path,
- MaxEventBytes: defaultMaxEventBytes,
- RotateBytes: defaultRotateBytes,
- RedactSecrets: true,
- ContentRetention: "metadata",
+ Path: path,
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
}, exporter.Settings{})
if err != nil {
t.Fatalf("newExporter returned error: %v", err)
@@ -1325,11 +1425,10 @@ func TestVSCodeCopilotKeepsActivityLogs(t *testing.T) {
func TestVSCodeCopilotDropsRepeatedSessionStartLogs(t *testing.T) {
path := filepath.Join(t.TempDir(), "runtime.jsonl")
exp, err := newExporter(&Config{
- Path: path,
- MaxEventBytes: defaultMaxEventBytes,
- RotateBytes: defaultRotateBytes,
- RedactSecrets: true,
- ContentRetention: "metadata",
+ Path: path,
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
}, exporter.Settings{})
if err != nil {
t.Fatalf("newExporter returned error: %v", err)
@@ -1359,11 +1458,10 @@ func TestVSCodeCopilotDropsRepeatedSessionStartLogs(t *testing.T) {
func TestVSCodeCopilotInvokeAgentUserRequestBecomesPrompt(t *testing.T) {
path := filepath.Join(t.TempDir(), "runtime.jsonl")
exp, err := newExporter(&Config{
- Path: path,
- MaxEventBytes: defaultMaxEventBytes,
- RotateBytes: defaultRotateBytes,
- RedactSecrets: true,
- ContentRetention: "full",
+ Path: path,
+ MaxEventBytes: defaultMaxEventBytes,
+ RotateBytes: defaultRotateBytes,
+ RedactSecrets: true,
}, exporter.Settings{})
if err != nil {
t.Fatalf("newExporter returned error: %v", err)
diff --git a/collector-builder/exporter/beaconjsonexporter/falconhecexporter/config.go b/collector-builder/exporter/beaconjsonexporter/falconhecexporter/config.go
index a0786ca4..1f9b73be 100644
--- a/collector-builder/exporter/beaconjsonexporter/falconhecexporter/config.go
+++ b/collector-builder/exporter/beaconjsonexporter/falconhecexporter/config.go
@@ -12,20 +12,18 @@ import (
const defaultTimeout = 10 * time.Second
type Config struct {
- Endpoint string `mapstructure:"endpoint"`
- Token string `mapstructure:"token"`
- Source string `mapstructure:"source"`
- Sourcetype string `mapstructure:"sourcetype"`
- Index string `mapstructure:"index"`
- InsecureSkipVerify bool `mapstructure:"insecure_skip_verify"`
- CAFile string `mapstructure:"ca_file"`
- Timeout time.Duration `mapstructure:"timeout"`
- QueueSettings exporterhelper.QueueConfig `mapstructure:"sending_queue"`
- RetrySettings configretry.BackOffConfig `mapstructure:"retry_on_failure"`
- // Deprecated no-op retained so older generated collector configs still load.
- ContentRetention string `mapstructure:"content_retention"`
- IncludeRuntimeMetrics bool `mapstructure:"include_runtime_metrics"`
- IncludeCodexSpans bool `mapstructure:"include_codex_spans"`
+ Endpoint string `mapstructure:"endpoint"`
+ Token string `mapstructure:"token"`
+ Source string `mapstructure:"source"`
+ Sourcetype string `mapstructure:"sourcetype"`
+ Index string `mapstructure:"index"`
+ InsecureSkipVerify bool `mapstructure:"insecure_skip_verify"`
+ CAFile string `mapstructure:"ca_file"`
+ Timeout time.Duration `mapstructure:"timeout"`
+ QueueSettings exporterhelper.QueueConfig `mapstructure:"sending_queue"`
+ RetrySettings configretry.BackOffConfig `mapstructure:"retry_on_failure"`
+ IncludeRuntimeMetrics bool `mapstructure:"include_runtime_metrics"`
+ IncludeCodexSpans bool `mapstructure:"include_codex_spans"`
}
func createDefaultConfig() *Config {
diff --git a/collector-builder/exporter/beaconjsonexporter/falconhecexporter/exporter_test.go b/collector-builder/exporter/beaconjsonexporter/falconhecexporter/exporter_test.go
index 04219b81..fbdc0a51 100644
--- a/collector-builder/exporter/beaconjsonexporter/falconhecexporter/exporter_test.go
+++ b/collector-builder/exporter/beaconjsonexporter/falconhecexporter/exporter_test.go
@@ -48,15 +48,14 @@ func TestConsumeLogsSendsBearerHECPayload(t *testing.T) {
defer server.Close()
exp, err := newExporter(&Config{
- Endpoint: server.URL,
- Token: "ingest-token",
- Source: "beacon-endpoint-agent",
- Sourcetype: "json",
- Index: "beacon-repo",
- Timeout: time.Second,
- QueueSettings: createDefaultConfig().QueueSettings,
- RetrySettings: createDefaultConfig().RetrySettings,
- ContentRetention: "full",
+ Endpoint: server.URL,
+ Token: "ingest-token",
+ Source: "beacon-endpoint-agent",
+ Sourcetype: "json",
+ Index: "beacon-repo",
+ Timeout: time.Second,
+ QueueSettings: createDefaultConfig().QueueSettings,
+ RetrySettings: createDefaultConfig().RetrySettings,
}, exporter.Settings{})
if err != nil {
t.Fatalf("newExporter returned error: %v", err)
@@ -124,12 +123,11 @@ func TestConsumeLogsReturnsErrorForNonSuccess(t *testing.T) {
}))
defer server.Close()
exp, err := newExporter(&Config{
- Endpoint: server.URL,
- Token: "bad-token",
- Timeout: time.Second,
- QueueSettings: createDefaultConfig().QueueSettings,
- RetrySettings: configNoRetry(),
- ContentRetention: "metadata",
+ Endpoint: server.URL,
+ Token: "bad-token",
+ Timeout: time.Second,
+ QueueSettings: createDefaultConfig().QueueSettings,
+ RetrySettings: configNoRetry(),
}, exporter.Settings{})
if err != nil {
t.Fatalf("newExporter returned error: %v", err)
diff --git a/collector-builder/exporter/beaconjsonexporter/go.mod b/collector-builder/exporter/beaconjsonexporter/go.mod
index d489de2c..a9e4fe5e 100644
--- a/collector-builder/exporter/beaconjsonexporter/go.mod
+++ b/collector-builder/exporter/beaconjsonexporter/go.mod
@@ -3,7 +3,7 @@ module github.com/asymptote-labs/agent-beacon/collector-builder/exporter/beaconj
go 1.24.0
require (
- github.com/asymptote-labs/agent-beacon/pkg/asymptotetrace v0.0.0
+ github.com/asymptote-labs/agent-beacon/pkg/asymptoteobserve v0.0.0
go.opentelemetry.io/collector/component v1.27.0
go.opentelemetry.io/collector/consumer v1.27.0
go.opentelemetry.io/collector/exporter v0.121.0
@@ -11,7 +11,7 @@ require (
go.uber.org/zap v1.27.0
)
-replace github.com/asymptote-labs/agent-beacon/pkg/asymptotetrace => ../../../pkg/asymptotetrace
+replace github.com/asymptote-labs/agent-beacon/pkg/asymptoteobserve => ../../../pkg/asymptoteobserve
require (
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
diff --git a/collector-builder/exporter/beaconjsonexporter/internal/beaconevent/converter.go b/collector-builder/exporter/beaconjsonexporter/internal/beaconevent/converter.go
index e6f9c07e..86761268 100644
--- a/collector-builder/exporter/beaconjsonexporter/internal/beaconevent/converter.go
+++ b/collector-builder/exporter/beaconjsonexporter/internal/beaconevent/converter.go
@@ -3,11 +3,13 @@ package beaconevent
import (
"encoding/json"
"fmt"
+ "net/url"
+ "sort"
"strconv"
"strings"
"time"
- "github.com/asymptote-labs/agent-beacon/pkg/asymptotetrace"
+ "github.com/asymptote-labs/agent-beacon/pkg/asymptoteobserve"
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/plog"
"go.opentelemetry.io/collector/pdata/pmetric"
@@ -393,6 +395,7 @@ func (c Converter) EventFromMetric(resourceAttrs map[string]interface{}, metric
func (c Converter) PopulateCommon(event *Event, attrs map[string]interface{}) {
populateRunContext(event, attrs)
+ event.GenAI = GenAIFromAttrs(attrs)
event.Model = FirstString(attrs, "gen_ai.request.model", "gen_ai.response.model", "model", "ai.model")
event.Repository = FirstString(attrs, "vcs.repository.url", "repository", "repo.path", "workspace.repository")
event.Branch = FirstString(attrs, "vcs.branch.name", "git.branch", "branch")
@@ -402,10 +405,10 @@ func (c Converter) PopulateCommon(event *Event, attrs map[string]interface{}) {
WorkingDirectory: FirstString(attrs, "cwd", "working_directory", "process.command_args.cwd", "workspace"),
}
}
- if name := FirstString(attrs, "tool.name", "gen_ai.tool.name", "mcp.tool.name", "function_name", "tool_name"); name != "" || FirstString(attrs, "tool.command", "command", "function_args") != "" {
+ if name := FirstString(attrs, "tool.name", "gen_ai.tool.name", "mcp.tool.name", "function_name", "tool_name"); name != "" || FirstString(attrs, "tool.command", "command", "function_args", "gen_ai.tool.call.arguments") != "" {
event.Tool = &ToolInfo{
Name: name,
- Command: FirstString(attrs, "tool.command", "command", "process.command_line", "function_args"),
+ Command: FirstString(attrs, "tool.command", "command", "process.command_line", "function_args", "gen_ai.tool.call.arguments"),
Path: FirstString(attrs, "tool.path", "file.path", "file_path"),
}
}
@@ -425,11 +428,8 @@ func (c Converter) PopulateCommon(event *Event, attrs map[string]interface{}) {
event.Command.DurationMS = duration
}
}
- if server := FirstString(attrs, "mcp.server.name", "mcp.server", "gen_ai.mcp.server", "mcp_server_name"); server != "" || FirstString(attrs, "mcp.tool.name") != "" || FirstString(attrs, "tool_type") == "mcp" {
- event.MCP = &MCPInfo{
- Server: server,
- Tool: FirstString(attrs, "mcp.tool.name", "tool.name", "function_name"),
- }
+ if mcp := MCPFromAttrs(attrs); mcp != nil {
+ event.MCP = mcp
}
if decision := FirstString(attrs, "approval.decision", "policy.decision", "decision"); decision != "" {
event.Approval = &ApprovalInfo{
@@ -439,31 +439,248 @@ func (c Converter) PopulateCommon(event *Event, attrs map[string]interface{}) {
}
}
if event.Event.Category == "prompt" {
- if text := FirstString(attrs, "gen_ai.prompt", "prompt", "user_prompt", "input.prompt", "copilot_chat.user_request"); text != "" {
+ if text := FirstNonEmpty(FirstString(attrs, "gen_ai.prompt", "prompt", "user_prompt", "input.prompt", "copilot_chat.user_request"), FirstMessageText(event.GenAI)); text != "" {
event.Prompt = &PromptInfo{Text: text}
}
}
}
+func GenAIFromAttrs(attrs map[string]interface{}) *GenAIInfo {
+ genai := &GenAIInfo{}
+ if description := FirstString(attrs, "gen_ai.agent.description"); description != "" || FirstString(attrs, "gen_ai.agent.id", "gen_ai.agent.name", "gen_ai.agent.version") != "" {
+ genai.Agent = &GenAIAgentInfo{
+ Description: description,
+ ID: FirstString(attrs, "gen_ai.agent.id"),
+ Name: FirstString(attrs, "gen_ai.agent.name"),
+ Version: FirstString(attrs, "gen_ai.agent.version"),
+ }
+ }
+ if id := FirstString(attrs, "gen_ai.conversation.id"); id != "" {
+ genai.Conversation = &GenAIConversationInfo{ID: id}
+ }
+ if id := FirstString(attrs, "gen_ai.data_source.id"); id != "" {
+ genai.DataSource = &GenAIDataSourceInfo{ID: id}
+ }
+ if count, ok := IntAttr(attrs, "gen_ai.embeddings.dimension.count"); ok {
+ genai.Embeddings = &GenAIEmbeddingsInfo{DimensionCount: &count}
+ }
+ if explanation := FirstString(attrs, "gen_ai.evaluation.explanation"); explanation != "" || FirstString(attrs, "gen_ai.evaluation.name", "gen_ai.evaluation.score.label") != "" || HasAttr(attrs, "gen_ai.evaluation.score.value") {
+ genai.Evaluation = &GenAIEvaluationInfo{
+ Explanation: explanation,
+ Name: FirstString(attrs, "gen_ai.evaluation.name"),
+ }
+ if label := FirstString(attrs, "gen_ai.evaluation.score.label"); label != "" || HasAttr(attrs, "gen_ai.evaluation.score.value") {
+ genai.Evaluation.Score = &GenAIEvaluationScoreInfo{Label: label}
+ if value, ok := FloatAttr(attrs, "gen_ai.evaluation.score.value"); ok {
+ genai.Evaluation.Score.Value = &value
+ }
+ }
+ }
+ if messages, ok := AnyAttr(attrs, "gen_ai.input.messages"); ok {
+ genai.Input = &GenAIInputInfo{Messages: messages}
+ } else if messages := LegacyMessages(attrs, "gen_ai.prompt.", "user"); len(messages) > 0 {
+ genai.Input = &GenAIInputInfo{Messages: messages}
+ } else if messages, ok := AnyAttr(attrs, "llm.prompts", "gen_ai.prompts"); ok {
+ genai.Input = &GenAIInputInfo{Messages: messages}
+ }
+ if name := FirstString(attrs, "gen_ai.operation.name"); name != "" {
+ genai.Operation = &GenAIOperationInfo{Name: name}
+ }
+ if messages, ok := AnyAttr(attrs, "gen_ai.output.messages"); ok {
+ genai.Output = &GenAIOutputInfo{Messages: messages, Type: FirstString(attrs, "gen_ai.output.type")}
+ } else if messages := LegacyMessages(attrs, "gen_ai.completion.", "assistant"); len(messages) > 0 {
+ genai.Output = &GenAIOutputInfo{Messages: messages, Type: FirstString(attrs, "gen_ai.output.type")}
+ } else if messages, ok := AnyAttr(attrs, "llm.completions", "gen_ai.completions"); ok {
+ genai.Output = &GenAIOutputInfo{Messages: messages, Type: FirstString(attrs, "gen_ai.output.type")}
+ } else if outputType := FirstString(attrs, "gen_ai.output.type"); outputType != "" {
+ genai.Output = &GenAIOutputInfo{Type: outputType}
+ }
+ if name := FirstString(attrs, "gen_ai.prompt.name"); name != "" {
+ genai.Prompt = &GenAIPromptInfo{Name: name}
+ }
+ if name := FirstString(attrs, "gen_ai.provider.name", "gen_ai.system"); name != "" {
+ genai.Provider = &GenAIProviderInfo{Name: name}
+ }
+ if request := GenAIRequestFromAttrs(attrs); request != nil {
+ genai.Request = request
+ }
+ if response := GenAIResponseFromAttrs(attrs); response != nil {
+ genai.Response = response
+ }
+ if documents, ok := AnyAttr(attrs, "gen_ai.retrieval.documents"); ok {
+ genai.Retrieval = &GenAIRetrievalInfo{Documents: documents, QueryText: FirstString(attrs, "gen_ai.retrieval.query.text")}
+ } else if query := FirstString(attrs, "gen_ai.retrieval.query.text"); query != "" {
+ genai.Retrieval = &GenAIRetrievalInfo{QueryText: query}
+ }
+ if instructions, ok := AnyAttr(attrs, "gen_ai.system_instructions"); ok {
+ genai.SystemInstructions = instructions
+ }
+ if tokenType := FirstString(attrs, "gen_ai.token.type"); tokenType != "" {
+ genai.Token = &GenAITokenInfo{Type: tokenType}
+ }
+ if tool := GenAIToolFromAttrs(attrs); tool != nil {
+ genai.Tool = tool
+ }
+ if usage := GenAIUsageFromAttrs(attrs); usage != nil {
+ genai.Usage = usage
+ }
+ if name := FirstString(attrs, "gen_ai.workflow.name"); name != "" {
+ genai.Workflow = &GenAIWorkflowInfo{Name: name}
+ }
+ if IsZeroJSON(genai) {
+ return nil
+ }
+ return genai
+}
+
+func GenAIRequestFromAttrs(attrs map[string]interface{}) *GenAIRequestInfo {
+ request := &GenAIRequestInfo{
+ Model: FirstString(attrs, "gen_ai.request.model", "llm.request.model"),
+ EncodingFormats: StringSliceAttr(attrs, "gen_ai.request.encoding_formats"),
+ StopSequences: StringSliceAttr(attrs, "gen_ai.request.stop_sequences"),
+ }
+ if value, ok := IntAttr(attrs, "gen_ai.request.choice.count"); ok {
+ request.ChoiceCount = &value
+ }
+ if value, ok := FloatAttr(attrs, "gen_ai.request.frequency_penalty"); ok {
+ request.FrequencyPenalty = &value
+ }
+ if value, ok := IntAttr(attrs, "gen_ai.request.max_tokens", "llm.request.max_tokens"); ok {
+ request.MaxTokens = &value
+ }
+ if value, ok := FloatAttr(attrs, "gen_ai.request.presence_penalty"); ok {
+ request.PresencePenalty = &value
+ }
+ if value, ok := IntAttr(attrs, "gen_ai.request.seed"); ok {
+ request.Seed = &value
+ }
+ if value, ok := BoolAttr(attrs, "gen_ai.request.stream"); ok {
+ request.Stream = &value
+ }
+ if value, ok := FloatAttr(attrs, "gen_ai.request.temperature", "llm.request.temperature"); ok {
+ request.Temperature = &value
+ }
+ if value, ok := FloatAttr(attrs, "gen_ai.request.top_k"); ok {
+ request.TopK = &value
+ }
+ if value, ok := FloatAttr(attrs, "gen_ai.request.top_p"); ok {
+ request.TopP = &value
+ }
+ if IsZeroJSON(request) {
+ return nil
+ }
+ return request
+}
+
+func GenAIResponseFromAttrs(attrs map[string]interface{}) *GenAIResponseInfo {
+ response := &GenAIResponseInfo{
+ FinishReasons: StringSliceAttr(attrs, "gen_ai.response.finish_reasons"),
+ ID: FirstString(attrs, "gen_ai.response.id"),
+ Model: FirstString(attrs, "gen_ai.response.model", "llm.response.model"),
+ }
+ if value, ok := FloatAttr(attrs, "gen_ai.response.time_to_first_chunk"); ok {
+ response.TimeToFirstChunk = &value
+ }
+ if IsZeroJSON(response) {
+ return nil
+ }
+ return response
+}
+
+func GenAIToolFromAttrs(attrs map[string]interface{}) *GenAIToolInfo {
+ tool := &GenAIToolInfo{
+ Description: FirstString(attrs, "gen_ai.tool.description"),
+ Name: FirstString(attrs, "gen_ai.tool.name", "tool.name"),
+ Type: FirstString(attrs, "gen_ai.tool.type"),
+ }
+ if definitions, ok := AnyAttr(attrs, "gen_ai.tool.definitions"); ok {
+ tool.Definitions = definitions
+ }
+ if args, ok := AnyAttr(attrs, "gen_ai.tool.call.arguments", "function_args", "arguments"); ok {
+ tool.Call = &GenAIToolCallInfo{Arguments: args, ID: FirstString(attrs, "gen_ai.tool.call.id")}
+ } else if id := FirstString(attrs, "gen_ai.tool.call.id"); id != "" {
+ tool.Call = &GenAIToolCallInfo{ID: id}
+ }
+ if result, ok := AnyAttr(attrs, "gen_ai.tool.call.result"); ok {
+ if tool.Call == nil {
+ tool.Call = &GenAIToolCallInfo{}
+ }
+ tool.Call.Result = result
+ }
+ if IsZeroJSON(tool) {
+ return nil
+ }
+ return tool
+}
+
+func GenAIUsageFromAttrs(attrs map[string]interface{}) *GenAIUsageInfo {
+ usage := &GenAIUsageInfo{}
+ if value, ok := IntAttr(attrs, "gen_ai.usage.cache_creation.input_tokens"); ok {
+ usage.CacheCreation = &GenAIUsageCacheCreationInfo{InputTokens: &value}
+ }
+ if value, ok := IntAttr(attrs, "gen_ai.usage.cache_read.input_tokens"); ok {
+ usage.CacheRead = &GenAIUsageCacheReadInfo{InputTokens: &value}
+ }
+ if value, ok := IntAttr(attrs, "gen_ai.usage.input_tokens", "llm.usage.prompt_tokens", "gen_ai.usage.prompt_tokens"); ok {
+ usage.InputTokens = &value
+ }
+ if value, ok := IntAttr(attrs, "gen_ai.usage.output_tokens", "llm.usage.completion_tokens", "gen_ai.usage.completion_tokens"); ok {
+ usage.OutputTokens = &value
+ }
+ if value, ok := IntAttr(attrs, "gen_ai.usage.reasoning.output_tokens"); ok {
+ usage.Reasoning = &GenAIUsageReasoningInfo{OutputTokens: &value}
+ }
+ if IsZeroJSON(usage) {
+ return nil
+ }
+ return usage
+}
+
+func MCPFromAttrs(attrs map[string]interface{}) *MCPInfo {
+ server := FirstString(attrs, "mcp.server.name", "mcp.server", "gen_ai.mcp.server", "mcp_server_name")
+ tool := FirstString(attrs, "mcp.tool.name", "tool.name", "function_name")
+ method := FirstString(attrs, "mcp.method.name")
+ protocol := FirstString(attrs, "mcp.protocol.version")
+ resource := FirstString(attrs, "mcp.resource.uri")
+ session := FirstString(attrs, "mcp.session.id")
+ if server == "" && tool == "" && method == "" && protocol == "" && resource == "" && session == "" && FirstString(attrs, "tool_type") != "mcp" {
+ return nil
+ }
+ out := &MCPInfo{Server: server, Tool: tool}
+ if method != "" {
+ out.Method = &MCPMethodInfo{Name: method}
+ }
+ if protocol != "" {
+ out.Protocol = &MCPProtocolInfo{Version: protocol}
+ }
+ if resource != "" {
+ out.Resource = &MCPResourceInfo{URI: resource}
+ }
+ if session != "" {
+ out.Session = &MCPSessionInfo{ID: session}
+ }
+ return out
+}
+
func populateRunContext(event *Event, attrs map[string]interface{}) {
- if FirstString(attrs, asymptotetrace.AttributeOrigin) == string(asymptotetrace.OriginCI) {
- event.Origin = asymptotetrace.OriginCI
+ if FirstString(attrs, asymptoteobserve.AttributeOrigin) == string(asymptoteobserve.OriginCI) {
+ event.Origin = asymptoteobserve.OriginCI
}
run := RunInfo{
- Provider: FirstString(attrs, asymptotetrace.AttributeRunProvider),
- RunID: FirstString(attrs, asymptotetrace.AttributeRunID),
- RunAttempt: FirstString(attrs, asymptotetrace.AttributeRunAttempt),
- Workflow: FirstString(attrs, asymptotetrace.AttributeRunWorkflow),
- Job: FirstString(attrs, asymptotetrace.AttributeRunJob),
- EventName: FirstString(attrs, asymptotetrace.AttributeRunEventName),
- Commit: FirstString(attrs, asymptotetrace.AttributeRunCommit),
- Repository: FirstString(attrs, asymptotetrace.AttributeRunRepository),
- Branch: FirstString(attrs, asymptotetrace.AttributeRunBranch),
- PR: FirstString(attrs, asymptotetrace.AttributeRunPR),
- PRNumber: FirstString(attrs, asymptotetrace.AttributeRunPRNumber),
- Actor: FirstString(attrs, asymptotetrace.AttributeRunActor),
- }
- if ephemeral, ok := BoolAttr(attrs, asymptotetrace.AttributeRunEphemeral); ok {
+ Provider: FirstString(attrs, asymptoteobserve.AttributeRunProvider),
+ RunID: FirstString(attrs, asymptoteobserve.AttributeRunID),
+ RunAttempt: FirstString(attrs, asymptoteobserve.AttributeRunAttempt),
+ Workflow: FirstString(attrs, asymptoteobserve.AttributeRunWorkflow),
+ Job: FirstString(attrs, asymptoteobserve.AttributeRunJob),
+ EventName: FirstString(attrs, asymptoteobserve.AttributeRunEventName),
+ Commit: FirstString(attrs, asymptoteobserve.AttributeRunCommit),
+ Repository: FirstString(attrs, asymptoteobserve.AttributeRunRepository),
+ Branch: FirstString(attrs, asymptoteobserve.AttributeRunBranch),
+ PR: FirstString(attrs, asymptoteobserve.AttributeRunPR),
+ PRNumber: FirstString(attrs, asymptoteobserve.AttributeRunPRNumber),
+ Actor: FirstString(attrs, asymptoteobserve.AttributeRunActor),
+ }
+ if ephemeral, ok := BoolAttr(attrs, asymptoteobserve.AttributeRunEphemeral); ok {
run.Ephemeral = ephemeral
}
if run.Provider == "" && run.RunID == "" && run.RunAttempt == "" && run.Workflow == "" && run.Job == "" && run.EventName == "" && run.Commit == "" && run.Repository == "" && run.Branch == "" && run.PR == "" && run.PRNumber == "" && run.Actor == "" && !run.Ephemeral {
@@ -512,6 +729,11 @@ func FirstString(attrs map[string]interface{}, keys ...string) string {
return ""
}
+func HasAttr(attrs map[string]interface{}, key string) bool {
+ _, ok := attrs[key]
+ return ok
+}
+
func FirstNonEmpty(values ...string) string {
for _, value := range values {
if strings.TrimSpace(value) != "" {
@@ -535,6 +757,32 @@ func Int64Attr(attrs map[string]interface{}, keys ...string) (int64, bool) {
return typed, true
case float64:
return int64(typed), true
+ case string:
+ value, err := strconv.ParseInt(strings.TrimSpace(typed), 10, 64)
+ if err == nil {
+ return value, true
+ }
+ }
+ }
+ return 0, false
+}
+
+func FloatAttr(attrs map[string]interface{}, keys ...string) (float64, bool) {
+ for _, key := range keys {
+ switch typed := attrs[key].(type) {
+ case float32:
+ return float64(typed), true
+ case float64:
+ return typed, true
+ case int:
+ return float64(typed), true
+ case int64:
+ return float64(typed), true
+ case string:
+ value, err := strconv.ParseFloat(strings.TrimSpace(typed), 64)
+ if err == nil {
+ return value, true
+ }
}
}
return 0, false
@@ -555,6 +803,161 @@ func BoolAttr(attrs map[string]interface{}, keys ...string) (bool, bool) {
return false, false
}
+func StringSliceAttr(attrs map[string]interface{}, keys ...string) []string {
+ for _, key := range keys {
+ value, ok := attrs[key]
+ if !ok {
+ continue
+ }
+ switch typed := value.(type) {
+ case []string:
+ return typed
+ case []interface{}:
+ out := make([]string, 0, len(typed))
+ for _, item := range typed {
+ if str := strings.TrimSpace(fmt.Sprint(item)); str != "" && str != "<nil>" {
+ out = append(out, str)
+ }
+ }
+ if len(out) > 0 {
+ return out
+ }
+ case string:
+ trimmed := strings.TrimSpace(typed)
+ if trimmed == "" {
+ continue
+ }
+ var parsed []string
+ if err := json.Unmarshal([]byte(trimmed), &parsed); err == nil {
+ return parsed
+ }
+ if strings.Contains(trimmed, ",") {
+ parts := strings.Split(trimmed, ",")
+ out := make([]string, 0, len(parts))
+ for _, part := range parts {
+ if part = strings.TrimSpace(part); part != "" {
+ out = append(out, part)
+ }
+ }
+ if len(out) > 0 {
+ return out
+ }
+ }
+ return []string{trimmed}
+ }
+ }
+ return nil
+}
+
+func AnyAttr(attrs map[string]interface{}, keys ...string) (interface{}, bool) {
+ for _, key := range keys {
+ value, ok := attrs[key]
+ if !ok || value == nil {
+ continue
+ }
+ if str, ok := value.(string); ok {
+ trimmed := strings.TrimSpace(str)
+ if trimmed == "" {
+ continue
+ }
+ if decoded, ok := DecodeJSONValue(trimmed); ok {
+ return decoded, true
+ }
+ return trimmed, true
+ }
+ return value, true
+ }
+ return nil, false
+}
+
+func DecodeJSONValue(value string) (interface{}, bool) {
+ if value == "" {
+ return nil, false
+ }
+ first := value[0]
+ if first != '{' && first != '[' && first != '"' {
+ return nil, false
+ }
+ var decoded interface{}
+ if err := json.Unmarshal([]byte(value), &decoded); err != nil {
+ return nil, false
+ }
+ return decoded, true
+}
+
+func LegacyMessages(attrs map[string]interface{}, prefix, role string) []interface{} {
+ type messagePart struct {
+ index int
+ text string
+ }
+ var parts []messagePart
+ for key, value := range attrs {
+ if !strings.HasPrefix(key, prefix) || !strings.HasSuffix(key, ".content") {
+ continue
+ }
+ indexText := strings.TrimSuffix(strings.TrimPrefix(key, prefix), ".content")
+ index, err := strconv.Atoi(indexText)
+ if err != nil {
+ continue
+ }
+ text := strings.TrimSpace(fmt.Sprint(value))
+ if text == "" || text == "<nil>" {
+ continue
+ }
+ parts = append(parts, messagePart{index: index, text: text})
+ }
+ sort.Slice(parts, func(i, j int) bool { return parts[i].index < parts[j].index })
+ out := make([]interface{}, 0, len(parts))
+ for _, part := range parts {
+ out = append(out, map[string]interface{}{
+ "role": role,
+ "parts": []interface{}{
+ map[string]interface{}{"type": "text", "content": part.text},
+ },
+ })
+ }
+ return out
+}
+
+func FirstMessageText(genai *GenAIInfo) string {
+ if genai == nil || genai.Input == nil || genai.Input.Messages == nil {
+ return ""
+ }
+ return firstTextFromAny(genai.Input.Messages)
+}
+
+func firstTextFromAny(value interface{}) string {
+ switch typed := value.(type) {
+ case string:
+ return typed
+ case []interface{}:
+ for _, item := range typed {
+ if text := firstTextFromAny(item); text != "" {
+ return text
+ }
+ }
+ case map[string]interface{}:
+ if content, ok := typed["content"]; ok {
+ return strings.TrimSpace(fmt.Sprint(content))
+ }
+ if parts, ok := typed["parts"]; ok {
+ return firstTextFromAny(parts)
+ }
+ if messages, ok := typed["messages"]; ok {
+ return firstTextFromAny(messages)
+ }
+ }
+ return ""
+}
+
+func IsZeroJSON(value interface{}) bool {
+ data, err := json.Marshal(value)
+ if err != nil {
+ return false
+ }
+ return string(data) == "{}"
+}
+
func Timestamp(ts time.Time) time.Time {
if ts.IsZero() || ts.UnixNano() == 0 {
return time.Now().UTC()
@@ -633,16 +1036,26 @@ func NormalizeHarnessName(name string) string {
func InferAction(attrs map[string]interface{}, fallback string) string {
tool := strings.ToLower(FirstString(attrs, "tool.name", "gen_ai.tool.name", "mcp.tool.name", "function_name", "tool_name"))
operation := strings.ToLower(FirstString(attrs, "gen_ai.operation.name"))
+ mcpMethod := strings.ToLower(FirstString(attrs, "mcp.method.name"))
harness := HarnessName(attrs, fallback)
text := strings.ToLower(strings.Join([]string{
fallback,
tool,
operation,
+ mcpMethod,
FirstString(attrs, "event.name", "codex.op", "rpc.method"),
}, " "))
switch {
case harness == "copilot_cli" || harness == "vscode_copilot":
return CopilotAction(attrs, operation, text)
+ case mcpMethod == "tools/call":
+ return "mcp.tool_invoked"
+ case mcpMethod == "resources/read" && IsFileURI(FirstString(attrs, "mcp.resource.uri")):
+ return "file.read"
+ case operation == "execute_tool" || FirstString(attrs, "gen_ai.tool.call.id", "gen_ai.tool.call.arguments") != "":
+ return "tool.invoked"
+ case (operation == "chat" || operation == "generate_content" || operation == "text_completion") && HasPromptLikeContent(attrs):
+ return "prompt.submitted"
case strings.Contains(text, "gemini_cli.user_prompt"):
return "prompt.submitted"
case strings.Contains(text, "gemini_cli.tool_call"):
@@ -666,6 +1079,21 @@ func InferAction(attrs map[string]interface{}, fallback string) string {
}
}
+func IsFileURI(value string) bool {
+ parsed, err := url.Parse(value)
+ return err == nil && parsed.Scheme == "file"
+}
+
+func HasPromptLikeContent(attrs map[string]interface{}) bool {
+ if FirstString(attrs, "gen_ai.prompt", "prompt", "user_prompt", "input.prompt", "copilot_chat.user_request") != "" {
+ return true
+ }
+ if _, ok := AnyAttr(attrs, "gen_ai.input.messages"); ok {
+ return true
+ }
+ return len(LegacyMessages(attrs, "gen_ai.prompt.", "user")) > 0
+}
+
func CopilotAction(attrs map[string]interface{}, operation, text string) string {
if eventName := FirstString(attrs, "event.name", "name"); eventName != "" {
switch eventName {
diff --git a/collector-builder/exporter/beaconjsonexporter/internal/beaconevent/event.go b/collector-builder/exporter/beaconjsonexporter/internal/beaconevent/event.go
index 47d3f1cf..34dd30b5 100644
--- a/collector-builder/exporter/beaconjsonexporter/internal/beaconevent/event.go
+++ b/collector-builder/exporter/beaconjsonexporter/internal/beaconevent/event.go
@@ -3,60 +3,86 @@ package beaconevent
import (
"time"
- "github.com/asymptote-labs/agent-beacon/pkg/asymptotetrace"
+ "github.com/asymptote-labs/agent-beacon/pkg/asymptoteobserve"
)
const (
- Vendor = asymptotetrace.Vendor
- Product = asymptotetrace.Product
- SchemaVersion = asymptotetrace.SchemaVersion
+ Vendor = asymptoteobserve.Vendor
+ Product = asymptoteobserve.Product
+ SchemaVersion = asymptoteobserve.SchemaVersion
)
-type EventInfo = asymptotetrace.EventInfo
-type EndpointInfo = asymptotetrace.EndpointInfo
-type UserInfo = asymptotetrace.UserInfo
-type HarnessInfo = asymptotetrace.HarnessInfo
-type SessionInfo = asymptotetrace.SessionInfo
-type RunInfo = asymptotetrace.RunInfo
-type ToolInfo = asymptotetrace.ToolInfo
-type FileInfo = asymptotetrace.FileInfo
-type CommandInfo = asymptotetrace.CommandInfo
-type MCPInfo = asymptotetrace.MCPInfo
-type ApprovalInfo = asymptotetrace.ApprovalInfo
-type PolicyInfo = asymptotetrace.PolicyInfo
-type PromptInfo = asymptotetrace.PromptInfo
-type ContentInfo = asymptotetrace.ContentInfo
+type EventInfo = asymptoteobserve.EventInfo
+type EndpointInfo = asymptoteobserve.EndpointInfo
+type UserInfo = asymptoteobserve.UserInfo
+type HarnessInfo = asymptoteobserve.HarnessInfo
+type SessionInfo = asymptoteobserve.SessionInfo
+type RunInfo = asymptoteobserve.RunInfo
+type ToolInfo = asymptoteobserve.ToolInfo
+type FileInfo = asymptoteobserve.FileInfo
+type CommandInfo = asymptoteobserve.CommandInfo
+type MCPInfo = asymptoteobserve.MCPInfo
+type MCPMethodInfo = asymptoteobserve.MCPMethodInfo
+type MCPProtocolInfo = asymptoteobserve.MCPProtocolInfo
+type MCPResourceInfo = asymptoteobserve.MCPResourceInfo
+type MCPSessionInfo = asymptoteobserve.MCPSessionInfo
+type ApprovalInfo = asymptoteobserve.ApprovalInfo
+type PolicyInfo = asymptoteobserve.PolicyInfo
+type PromptInfo = asymptoteobserve.PromptInfo
+type GenAIInfo = asymptoteobserve.GenAIInfo
+type GenAIAgentInfo = asymptoteobserve.GenAIAgentInfo
+type GenAIConversationInfo = asymptoteobserve.GenAIConversationInfo
+type GenAIDataSourceInfo = asymptoteobserve.GenAIDataSourceInfo
+type GenAIEmbeddingsInfo = asymptoteobserve.GenAIEmbeddingsInfo
+type GenAIEvaluationInfo = asymptoteobserve.GenAIEvaluationInfo
+type GenAIEvaluationScoreInfo = asymptoteobserve.GenAIEvaluationScoreInfo
+type GenAIInputInfo = asymptoteobserve.GenAIInputInfo
+type GenAIOperationInfo = asymptoteobserve.GenAIOperationInfo
+type GenAIOutputInfo = asymptoteobserve.GenAIOutputInfo
+type GenAIPromptInfo = asymptoteobserve.GenAIPromptInfo
+type GenAIProviderInfo = asymptoteobserve.GenAIProviderInfo
+type GenAIRequestInfo = asymptoteobserve.GenAIRequestInfo
+type GenAIResponseInfo = asymptoteobserve.GenAIResponseInfo
+type GenAIRetrievalInfo = asymptoteobserve.GenAIRetrievalInfo
+type GenAITokenInfo = asymptoteobserve.GenAITokenInfo
+type GenAIToolInfo = asymptoteobserve.GenAIToolInfo
+type GenAIToolCallInfo = asymptoteobserve.GenAIToolCallInfo
+type GenAIUsageInfo = asymptoteobserve.GenAIUsageInfo
+type GenAIUsageCacheCreationInfo = asymptoteobserve.GenAIUsageCacheCreationInfo
+type GenAIUsageCacheReadInfo = asymptoteobserve.GenAIUsageCacheReadInfo
+type GenAIUsageReasoningInfo = asymptoteobserve.GenAIUsageReasoningInfo
+type GenAIWorkflowInfo = asymptoteobserve.GenAIWorkflowInfo
type Event struct {
- ObservedAt time.Time `json:"-"`
- Timestamp string `json:"timestamp"`
- Vendor string `json:"vendor"`
- Product string `json:"product"`
- SchemaVersion string `json:"schema_version"`
- Event EventInfo `json:"event"`
- Severity string `json:"severity"`
- Endpoint EndpointInfo `json:"endpoint"`
- User UserInfo `json:"user,omitempty"`
- Harness HarnessInfo `json:"harness"`
- Origin asymptotetrace.Origin `json:"origin,omitempty"`
- Run *RunInfo `json:"run,omitempty"`
- Session *SessionInfo `json:"session,omitempty"`
- Tool *ToolInfo `json:"tool,omitempty"`
- File *FileInfo `json:"file,omitempty"`
- Command *CommandInfo `json:"command,omitempty"`
- MCP *MCPInfo `json:"mcp,omitempty"`
- Approval *ApprovalInfo `json:"approval,omitempty"`
- Policy *PolicyInfo `json:"policy,omitempty"`
- Prompt *PromptInfo `json:"prompt,omitempty"`
- Content *ContentInfo `json:"content,omitempty"`
- Destination *asymptotetrace.DestinationInfo `json:"destination,omitempty"`
- Health *asymptotetrace.HealthInfo `json:"health,omitempty"`
- Model string `json:"model,omitempty"`
- Repository string `json:"repository,omitempty"`
- Branch string `json:"branch,omitempty"`
- Message string `json:"message,omitempty"`
- Raw map[string]interface{} `json:"raw,omitempty"`
- Truncated bool `json:"field_truncated,omitempty"`
+ ObservedAt time.Time `json:"-"`
+ Timestamp string `json:"timestamp"`
+ Vendor string `json:"vendor"`
+ Product string `json:"product"`
+ SchemaVersion string `json:"schema_version"`
+ Event EventInfo `json:"event"`
+ Severity string `json:"severity"`
+ Endpoint EndpointInfo `json:"endpoint"`
+ User UserInfo `json:"user,omitempty"`
+ Harness HarnessInfo `json:"harness"`
+ Origin asymptoteobserve.Origin `json:"origin,omitempty"`
+ Run *RunInfo `json:"run,omitempty"`
+ Session *SessionInfo `json:"session,omitempty"`
+ Tool *ToolInfo `json:"tool,omitempty"`
+ File *FileInfo `json:"file,omitempty"`
+ Command *CommandInfo `json:"command,omitempty"`
+ MCP *MCPInfo `json:"mcp,omitempty"`
+ Approval *ApprovalInfo `json:"approval,omitempty"`
+ Policy *PolicyInfo `json:"policy,omitempty"`
+ Prompt *PromptInfo `json:"prompt,omitempty"`
+ Destination *asymptoteobserve.DestinationInfo `json:"destination,omitempty"`
+ Health *asymptoteobserve.HealthInfo `json:"health,omitempty"`
+ GenAI *GenAIInfo `json:"gen_ai,omitempty"`
+ Model string `json:"model,omitempty"`
+ Repository string `json:"repository,omitempty"`
+ Branch string `json:"branch,omitempty"`
+ Message string `json:"message,omitempty"`
+ Raw map[string]interface{} `json:"raw,omitempty"`
+ Truncated bool `json:"field_truncated,omitempty"`
}
func NewEvent(action, category, severity, harnessName string, ts time.Time) Event {
@@ -69,10 +95,10 @@ func NewEvent(action, category, severity, harnessName string, ts time.Time) Even
if harnessName == "" {
harnessName = "unknown"
}
- base := asymptotetrace.NewEvent(asymptotetrace.NewEventOptions{
+ base := asymptoteobserve.NewEvent(asymptoteobserve.NewEventOptions{
Action: action,
Category: category,
- Severity: asymptotetrace.Severity(severity),
+ Severity: asymptoteobserve.Severity(severity),
Harness: HarnessInfo{Name: harnessName},
})
return Event{
diff --git a/collector-builder/exporter/beaconjsonexporter/writer.go b/collector-builder/exporter/beaconjsonexporter/writer.go
index c130fdc0..accecd6f 100644
--- a/collector-builder/exporter/beaconjsonexporter/writer.go
+++ b/collector-builder/exporter/beaconjsonexporter/writer.go
@@ -9,7 +9,7 @@ import (
"strings"
"syscall"
- "github.com/asymptote-labs/agent-beacon/pkg/asymptotetrace"
+ "github.com/asymptote-labs/agent-beacon/pkg/asymptoteobserve"
)
type jsonlWriter struct {
@@ -28,7 +28,7 @@ func (w jsonlWriter) append(event beaconEvent) error {
}
if len(data) > w.maxEventBytes {
event.Raw = nil
- event.Message = asymptotetrace.TruncateString(event.Message, 1024)
+ event.Message = asymptoteobserve.TruncateString(event.Message, 1024)
event.Truncated = true
data, err = json.Marshal(event)
if err != nil {
@@ -45,22 +45,28 @@ func (w jsonlWriter) append(event beaconEvent) error {
}
func (w jsonlWriter) sanitize(event beaconEvent) beaconEvent {
- event.Message = w.cleanString(event.Message, asymptotetrace.DefaultStringLimit)
+ event.Message = w.cleanString(event.Message, asymptoteobserve.DefaultStringLimit)
if event.Tool != nil {
- event.Tool.Command = w.cleanString(event.Tool.Command, asymptotetrace.DefaultStringLimit)
- event.Tool.Path = asymptotetrace.TruncateString(event.Tool.Path, asymptotetrace.DefaultRawStringLimit)
+ event.Tool.Command = w.cleanString(event.Tool.Command, asymptoteobserve.DefaultStringLimit)
+ event.Tool.Path = asymptoteobserve.TruncateString(event.Tool.Path, asymptoteobserve.DefaultRawStringLimit)
}
if event.Command != nil {
- event.Command.Command = w.cleanString(event.Command.Command, asymptotetrace.DefaultStringLimit)
+ event.Command.Command = w.cleanString(event.Command.Command, asymptoteobserve.DefaultStringLimit)
}
if event.Approval != nil {
- event.Approval.Reason = w.cleanString(event.Approval.Reason, asymptotetrace.DefaultStringLimit)
+ event.Approval.Reason = w.cleanString(event.Approval.Reason, asymptoteobserve.DefaultStringLimit)
}
if event.Policy != nil {
- event.Policy.Reason = w.cleanString(event.Policy.Reason, asymptotetrace.DefaultStringLimit)
+ event.Policy.Reason = w.cleanString(event.Policy.Reason, asymptoteobserve.DefaultStringLimit)
}
if event.Prompt != nil {
- event.Prompt.Text = w.cleanString(event.Prompt.Text, asymptotetrace.DefaultStringLimit)
+ event.Prompt.Text = w.cleanString(event.Prompt.Text, asymptoteobserve.DefaultStringLimit)
+ }
+ if event.MCP != nil {
+ event.MCP = sanitizeTyped(event.MCP, w.sanitizeMap)
+ }
+ if event.GenAI != nil {
+ event.GenAI = sanitizeTyped(event.GenAI, w.sanitizeMap)
}
if event.Raw != nil {
event.Raw = w.sanitizeMap(event.Raw)
@@ -72,21 +78,49 @@ func (w jsonlWriter) sanitize(event beaconEvent) beaconEvent {
}
func (w jsonlWriter) sanitizeMap(input map[string]interface{}) map[string]interface{} {
- return asymptotetrace.SanitizeMap(input, asymptotetrace.PrivacyOptions{
+ return asymptoteobserve.SanitizeMap(input, asymptoteobserve.PrivacyOptions{
RedactSecrets: w.redactSecrets,
- StringLimit: asymptotetrace.DefaultRawStringLimit,
+ StringLimit: asymptoteobserve.DefaultRawStringLimit,
})
}
func (w jsonlWriter) sanitizeSlice(input []interface{}) []interface{} {
- return asymptotetrace.SanitizeSlice(input, asymptotetrace.PrivacyOptions{
+ return asymptoteobserve.SanitizeSlice(input, asymptoteobserve.PrivacyOptions{
RedactSecrets: w.redactSecrets,
- StringLimit: asymptotetrace.DefaultRawStringLimit,
+ StringLimit: asymptoteobserve.DefaultRawStringLimit,
})
}
func (w jsonlWriter) cleanString(value string, limit int) string {
- return asymptotetrace.CleanString(value, limit, w.redactSecrets)
+ return asymptoteobserve.CleanString(value, limit, w.redactSecrets)
+}
+
+func sanitizeTyped[T any](input *T, sanitize func(map[string]interface{}) map[string]interface{}) *T {
+ if input == nil {
+ return nil
+ }
+ data, err := json.Marshal(input)
+ if err != nil {
+ out := *input
+ return &out
+ }
+ var raw map[string]interface{}
+ if err := json.Unmarshal(data, &raw); err != nil {
+ out := *input
+ return &out
+ }
+ raw = sanitize(raw)
+ data, err = json.Marshal(raw)
+ if err != nil {
+ out := *input
+ return &out
+ }
+ var out T
+ if err := json.Unmarshal(data, &out); err != nil {
+ fallback := *input
+ return &fallback
+ }
+ return &out
}
// Keep this rotation contract mirrored with the endpoint CLI and hook writer.
diff --git a/pkg/asymptotetrace/envelope.go b/pkg/asymptoteobserve/envelope.go
similarity index 98%
rename from pkg/asymptotetrace/envelope.go
rename to pkg/asymptoteobserve/envelope.go
index 3ac75a12..fbcfdbac 100644
--- a/pkg/asymptotetrace/envelope.go
+++ b/pkg/asymptoteobserve/envelope.go
@@ -1,4 +1,4 @@
-package asymptotetrace
+package asymptoteobserve
import "errors"
diff --git a/pkg/asymptotetrace/envelope_test.go b/pkg/asymptoteobserve/envelope_test.go
similarity index 98%
rename from pkg/asymptotetrace/envelope_test.go
rename to pkg/asymptoteobserve/envelope_test.go
index 3cb24ef8..f98ee2c2 100644
--- a/pkg/asymptotetrace/envelope_test.go
+++ b/pkg/asymptoteobserve/envelope_test.go
@@ -1,4 +1,4 @@
-package asymptotetrace
+package asymptoteobserve
import (
"strings"
diff --git a/pkg/asymptotetrace/event.go b/pkg/asymptoteobserve/event.go
similarity index 57%
rename from pkg/asymptotetrace/event.go
rename to pkg/asymptoteobserve/event.go
index b63dd2f6..43c4e37e 100644
--- a/pkg/asymptotetrace/event.go
+++ b/pkg/asymptoteobserve/event.go
@@ -1,4 +1,4 @@
-package asymptotetrace
+package asymptoteobserve
import (
"errors"
@@ -116,9 +116,29 @@ type CommandInfo struct {
DurationMS int64 `json:"duration_ms,omitempty"`
}
+type MCPMethodInfo struct {
+ Name string `json:"name,omitempty"`
+}
+
+type MCPProtocolInfo struct {
+ Version string `json:"version,omitempty"`
+}
+
+type MCPResourceInfo struct {
+ URI string `json:"uri,omitempty"`
+}
+
+type MCPSessionInfo struct {
+ ID string `json:"id,omitempty"`
+}
+
type MCPInfo struct {
- Server string `json:"server,omitempty"`
- Tool string `json:"tool,omitempty"`
+ Server string `json:"server,omitempty"`
+ Tool string `json:"tool,omitempty"`
+ Method *MCPMethodInfo `json:"method,omitempty"`
+ Protocol *MCPProtocolInfo `json:"protocol,omitempty"`
+ Resource *MCPResourceInfo `json:"resource,omitempty"`
+ Session *MCPSessionInfo `json:"session,omitempty"`
}
type ApprovalInfo struct {
@@ -139,11 +159,145 @@ type PromptInfo struct {
Text string `json:"text,omitempty"`
}
-type ContentInfo struct {
- Retention string `json:"retention"`
- Included bool `json:"included"`
- Redacted bool `json:"redacted,omitempty"`
- Truncated bool `json:"truncated,omitempty"`
+type GenAIAgentInfo struct {
+ Description string `json:"description,omitempty"`
+ ID string `json:"id,omitempty"`
+ Name string `json:"name,omitempty"`
+ Version string `json:"version,omitempty"`
+}
+
+type GenAIConversationInfo struct {
+ ID string `json:"id,omitempty"`
+}
+
+type GenAIDataSourceInfo struct {
+ ID string `json:"id,omitempty"`
+}
+
+type GenAIEmbeddingsInfo struct {
+ DimensionCount *int `json:"dimension_count,omitempty"`
+}
+
+type GenAIEvaluationScoreInfo struct {
+ Label string `json:"label,omitempty"`
+ Value *float64 `json:"value,omitempty"`
+}
+
+type GenAIEvaluationInfo struct {
+ Explanation string `json:"explanation,omitempty"`
+ Name string `json:"name,omitempty"`
+ Score *GenAIEvaluationScoreInfo `json:"score,omitempty"`
+}
+
+type GenAIInputInfo struct {
+ Messages interface{} `json:"messages,omitempty"`
+}
+
+type GenAIOperationInfo struct {
+ Name string `json:"name,omitempty"`
+}
+
+type GenAIOutputInfo struct {
+ Messages interface{} `json:"messages,omitempty"`
+ Type string `json:"type,omitempty"`
+}
+
+type GenAIPromptInfo struct {
+ Name string `json:"name,omitempty"`
+}
+
+type GenAIProviderInfo struct {
+ Name string `json:"name,omitempty"`
+}
+
+type GenAIRequestInfo struct {
+ ChoiceCount *int `json:"choice_count,omitempty"`
+ EncodingFormats []string `json:"encoding_formats,omitempty"`
+ FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"`
+ MaxTokens *int `json:"max_tokens,omitempty"`
+ Model string `json:"model,omitempty"`
+ PresencePenalty *float64 `json:"presence_penalty,omitempty"`
+ Seed *int `json:"seed,omitempty"`
+ StopSequences []string `json:"stop_sequences,omitempty"`
+ Stream *bool `json:"stream,omitempty"`
+ Temperature *float64 `json:"temperature,omitempty"`
+ TopK *float64 `json:"top_k,omitempty"`
+ TopP *float64 `json:"top_p,omitempty"`
+}
+
+type GenAIResponseInfo struct {
+ FinishReasons []string `json:"finish_reasons,omitempty"`
+ ID string `json:"id,omitempty"`
+ Model string `json:"model,omitempty"`
+ TimeToFirstChunk *float64 `json:"time_to_first_chunk,omitempty"`
+}
+
+type GenAIRetrievalInfo struct {
+ Documents interface{} `json:"documents,omitempty"`
+ QueryText string `json:"query_text,omitempty"`
+}
+
+type GenAITokenInfo struct {
+ Type string `json:"type,omitempty"`
+}
+
+type GenAIToolCallInfo struct {
+ Arguments interface{} `json:"arguments,omitempty"`
+ ID string `json:"id,omitempty"`
+ Result interface{} `json:"result,omitempty"`
+}
+
+type GenAIToolInfo struct {
+ Call *GenAIToolCallInfo `json:"call,omitempty"`
+ Definitions interface{} `json:"definitions,omitempty"`
+ Description string `json:"description,omitempty"`
+ Name string `json:"name,omitempty"`
+ Type string `json:"type,omitempty"`
+}
+
+type GenAIUsageCacheCreationInfo struct {
+ InputTokens *int `json:"input_tokens,omitempty"`
+}
+
+type GenAIUsageCacheReadInfo struct {
+ InputTokens *int `json:"input_tokens,omitempty"`
+}
+
+type GenAIUsageReasoningInfo struct {
+ OutputTokens *int `json:"output_tokens,omitempty"`
+}
+
+type GenAIUsageInfo struct {
+ CacheCreation *GenAIUsageCacheCreationInfo `json:"cache_creation,omitempty"`
+ CacheRead *GenAIUsageCacheReadInfo `json:"cache_read,omitempty"`
+ InputTokens *int `json:"input_tokens,omitempty"`
+ OutputTokens *int `json:"output_tokens,omitempty"`
+ Reasoning *GenAIUsageReasoningInfo `json:"reasoning,omitempty"`
+}
+
+type GenAIWorkflowInfo struct {
+ Name string `json:"name,omitempty"`
+}
+
+type GenAIInfo struct {
+ Agent *GenAIAgentInfo `json:"agent,omitempty"`
+ Conversation *GenAIConversationInfo `json:"conversation,omitempty"`
+ DataSource *GenAIDataSourceInfo `json:"data_source,omitempty"`
+ Embeddings *GenAIEmbeddingsInfo `json:"embeddings,omitempty"`
+ Evaluation *GenAIEvaluationInfo `json:"evaluation,omitempty"`
+ Input *GenAIInputInfo `json:"input,omitempty"`
+ Operation *GenAIOperationInfo `json:"operation,omitempty"`
+ Output *GenAIOutputInfo `json:"output,omitempty"`
+ Prompt *GenAIPromptInfo `json:"prompt,omitempty"`
+ Provider *GenAIProviderInfo `json:"provider,omitempty"`
+ Request *GenAIRequestInfo `json:"request,omitempty"`
+ Response *GenAIResponseInfo `json:"response,omitempty"`
+ Retrieval *GenAIRetrievalInfo `json:"retrieval,omitempty"`
+ SystemInstructions interface{} `json:"system_instructions,omitempty"`
+ Token *GenAITokenInfo `json:"token,omitempty"`
+ Tool *GenAIToolInfo `json:"tool,omitempty"`
+ Usage *GenAIUsageInfo `json:"usage,omitempty"`
+ Workflow *GenAIWorkflowInfo `json:"workflow,omitempty"`
}
type DestinationInfo struct {
@@ -178,9 +332,9 @@ type Event struct {
Approval *ApprovalInfo `json:"approval,omitempty"`
Policy *PolicyInfo `json:"policy,omitempty"`
Prompt *PromptInfo `json:"prompt,omitempty"`
- Content *ContentInfo `json:"content,omitempty"`
Destination *DestinationInfo `json:"destination,omitempty"`
Health *HealthInfo `json:"health,omitempty"`
+ GenAI *GenAIInfo `json:"gen_ai,omitempty"`
Model string `json:"model,omitempty"`
Repository string `json:"repository,omitempty"`
Branch string `json:"branch,omitempty"`
diff --git a/pkg/asymptotetrace/event_sink.go b/pkg/asymptoteobserve/event_sink.go
similarity index 94%
rename from pkg/asymptotetrace/event_sink.go
rename to pkg/asymptoteobserve/event_sink.go
index 697abb45..c9064a2a 100644
--- a/pkg/asymptotetrace/event_sink.go
+++ b/pkg/asymptoteobserve/event_sink.go
@@ -1,4 +1,4 @@
-package asymptotetrace
+package asymptoteobserve
import "context"
diff --git a/pkg/asymptotetrace/event_test.go b/pkg/asymptoteobserve/event_test.go
similarity index 91%
rename from pkg/asymptotetrace/event_test.go
rename to pkg/asymptoteobserve/event_test.go
index 6074b089..6dcd3abe 100644
--- a/pkg/asymptotetrace/event_test.go
+++ b/pkg/asymptoteobserve/event_test.go
@@ -1,4 +1,4 @@
-package asymptotetrace
+package asymptoteobserve
import (
"encoding/json"
@@ -37,22 +37,15 @@ func TestNewEventSetsRequiredInvariants(t *testing.T) {
}
event.File = &FileInfo{Path: "main.go", Operation: "modify"}
event.Command = &CommandInfo{Command: "go test ./..."}
- event.MCP = &MCPInfo{Server: "github", Tool: "get_issue"}
+ event.MCP = &MCPInfo{Server: "github", Tool: "get_issue", Method: &MCPMethodInfo{Name: "tools/call"}}
event.Prompt = &PromptInfo{Text: "Summarize this file"}
- if err := event.Validate(); err != nil {
- t.Fatalf("Validate rejected optional telemetry fields: %v", err)
+ event.GenAI = &GenAIInfo{
+ Provider: &GenAIProviderInfo{Name: "openai"},
+ Request: &GenAIRequestInfo{Model: "gpt-4o"},
+ Usage: &GenAIUsageInfo{InputTokens: intPtr(10), OutputTokens: intPtr(20)},
}
-}
-
-func TestValidateToleratesHistoricalContentField(t *testing.T) {
- event := NewEvent(NewEventOptions{
- Action: "tool.invoked",
- Harness: HarnessInfo{Name: "cursor"},
- })
- event.Content = &ContentInfo{Retention: "metadata", Included: false}
-
if err := event.Validate(); err != nil {
- t.Fatalf("Validate rejected historical content field: %v", err)
+ t.Fatalf("Validate rejected optional telemetry fields: %v", err)
}
}
@@ -76,6 +69,10 @@ func TestValidateOriginValues(t *testing.T) {
}
}
+func intPtr(value int) *int {
+ return &value
+}
+
func TestRunAndOriginAreOmittedWhenUnset(t *testing.T) {
event := NewEvent(NewEventOptions{Action: "tool.invoked", Harness: HarnessInfo{Name: "cursor"}})
data, err := json.Marshal(event)
diff --git a/pkg/asymptoteobserve/go.mod b/pkg/asymptoteobserve/go.mod
new file mode 100644
index 00000000..acb484b8
--- /dev/null
+++ b/pkg/asymptoteobserve/go.mod
@@ -0,0 +1,3 @@
+module github.com/asymptote-labs/agent-beacon/pkg/asymptoteobserve
+
+go 1.24
diff --git a/pkg/asymptotetrace/jsonl_sink.go b/pkg/asymptoteobserve/jsonl_sink.go
similarity index 98%
rename from pkg/asymptotetrace/jsonl_sink.go
rename to pkg/asymptoteobserve/jsonl_sink.go
index 6f9792a2..4103c81e 100644
--- a/pkg/asymptotetrace/jsonl_sink.go
+++ b/pkg/asymptoteobserve/jsonl_sink.go
@@ -1,4 +1,4 @@
-package asymptotetrace
+package asymptoteobserve
import (
"context"
diff --git a/pkg/asymptotetrace/jsonl_sink_test.go b/pkg/asymptoteobserve/jsonl_sink_test.go
similarity index 99%
rename from pkg/asymptotetrace/jsonl_sink_test.go
rename to pkg/asymptoteobserve/jsonl_sink_test.go
index 97b75706..6a8abf38 100644
--- a/pkg/asymptotetrace/jsonl_sink_test.go
+++ b/pkg/asymptoteobserve/jsonl_sink_test.go
@@ -1,4 +1,4 @@
-package asymptotetrace
+package asymptoteobserve
import (
"bufio"
diff --git a/pkg/asymptotetrace/normalizer.go b/pkg/asymptoteobserve/normalizer.go
similarity index 98%
rename from pkg/asymptotetrace/normalizer.go
rename to pkg/asymptoteobserve/normalizer.go
index 32e2381b..a6919243 100644
--- a/pkg/asymptotetrace/normalizer.go
+++ b/pkg/asymptoteobserve/normalizer.go
@@ -1,4 +1,4 @@
-package asymptotetrace
+package asymptoteobserve
import "context"
diff --git a/pkg/asymptotetrace/pipeline.go b/pkg/asymptoteobserve/pipeline.go
similarity index 92%
rename from pkg/asymptotetrace/pipeline.go
rename to pkg/asymptoteobserve/pipeline.go
index 07360447..e076711f 100644
--- a/pkg/asymptotetrace/pipeline.go
+++ b/pkg/asymptoteobserve/pipeline.go
@@ -1,7 +1,8 @@
-package asymptotetrace
+package asymptoteobserve
import (
"context"
+ "encoding/json"
"errors"
)
@@ -169,10 +170,6 @@ func copyEvent(event Event) Event {
prompt := *event.Prompt
out.Prompt = &prompt
}
- if event.Content != nil {
- content := *event.Content
- out.Content = &content
- }
if event.Destination != nil {
destination := *event.Destination
out.Destination = &destination
@@ -181,8 +178,28 @@ func copyEvent(event Event) Event {
health := *event.Health
out.Health = &health
}
+ if event.GenAI != nil {
+ out.GenAI = cloneTyped(event.GenAI)
+ }
if event.Raw != nil {
out.Raw = copyMap(event.Raw)
}
return out
}
+
+func cloneTyped[T any](input *T) *T {
+ if input == nil {
+ return nil
+ }
+ data, err := json.Marshal(input)
+ if err != nil {
+ out := *input
+ return &out
+ }
+ var out T
+ if err := json.Unmarshal(data, &out); err != nil {
+ fallback := *input
+ return &fallback
+ }
+ return &out
+}
diff --git a/pkg/asymptotetrace/pipeline_test.go b/pkg/asymptoteobserve/pipeline_test.go
similarity index 96%
rename from pkg/asymptotetrace/pipeline_test.go
rename to pkg/asymptoteobserve/pipeline_test.go
index f036f72e..5676ecb4 100644
--- a/pkg/asymptotetrace/pipeline_test.go
+++ b/pkg/asymptoteobserve/pipeline_test.go
@@ -1,4 +1,4 @@
-package asymptotetrace
+package asymptoteobserve
import (
"context"
@@ -195,9 +195,6 @@ func TestPipelineWithoutPrivacyPassesEventsThrough(t *testing.T) {
if rawText := stringify(events[0].Raw); !strings.Contains(rawText, "visible-without-privacy") {
t.Fatalf("event was unexpectedly sanitized without privacy: %s", rawText)
}
- if events[0].Content != nil {
- t.Fatalf("content metadata was unexpectedly set without privacy: %#v", events[0].Content)
- }
}
func TestPipelinePrivacyRunsBeforeAdditionalProcessors(t *testing.T) {
@@ -223,7 +220,7 @@ func TestPipelinePrivacyRunsBeforeAdditionalProcessors(t *testing.T) {
}
}
-func TestPipelinePrivacyDoesNotSetContentMetadata(t *testing.T) {
+func TestPipelinePrivacyKeepsRawTelemetry(t *testing.T) {
sink := &captureEventSink{}
pipeline := NewPipeline(PipelineOptions{
Source: staticSource{NewEnvelopeRecord(testEnvelope())},
@@ -238,9 +235,6 @@ func TestPipelinePrivacyDoesNotSetContentMetadata(t *testing.T) {
if len(events) != 1 {
t.Fatalf("events = %d, want 1", len(events))
}
- if events[0].Content != nil {
- t.Fatalf("privacy unexpectedly set content metadata: %#v", events[0].Content)
- }
if events[0].Raw["prompt"] != "summarize" {
t.Fatalf("privacy unexpectedly removed raw: %#v", events[0].Raw)
}
diff --git a/pkg/asymptotetrace/privacy.go b/pkg/asymptoteobserve/privacy.go
similarity index 80%
rename from pkg/asymptotetrace/privacy.go
rename to pkg/asymptoteobserve/privacy.go
index 0cda1909..0d8b33b6 100644
--- a/pkg/asymptotetrace/privacy.go
+++ b/pkg/asymptoteobserve/privacy.go
@@ -1,4 +1,4 @@
-package asymptotetrace
+package asymptoteobserve
import (
"encoding/json"
@@ -116,6 +116,12 @@ func SanitizeEvent(event Event, maxBytes int) Event {
if event.Prompt != nil {
event.Prompt.Text = CleanString(event.Prompt.Text, DefaultStringLimit, true)
}
+ if event.MCP != nil {
+ event.MCP = sanitizeTyped(event.MCP, PrivacyOptions{RedactSecrets: true, StringLimit: DefaultRawStringLimit})
+ }
+ if event.GenAI != nil {
+ event.GenAI = sanitizeTyped(event.GenAI, PrivacyOptions{RedactSecrets: true, StringLimit: DefaultRawStringLimit})
+ }
if event.Raw != nil {
event.Raw = SanitizeMap(event.Raw, PrivacyOptions{RedactSecrets: true, StringLimit: DefaultRawStringLimit})
}
@@ -124,3 +130,31 @@ func SanitizeEvent(event Event, maxBytes int) Event {
}
return event
}
+
+func sanitizeTyped[T any](input *T, opts PrivacyOptions) *T {
+ if input == nil {
+ return nil
+ }
+ data, err := json.Marshal(input)
+ if err != nil {
+ out := *input
+ return &out
+ }
+ var raw map[string]interface{}
+ if err := json.Unmarshal(data, &raw); err != nil {
+ out := *input
+ return &out
+ }
+ raw = SanitizeMap(raw, opts)
+ data, err = json.Marshal(raw)
+ if err != nil {
+ out := *input
+ return &out
+ }
+ var out T
+ if err := json.Unmarshal(data, &out); err != nil {
+ fallback := *input
+ return &fallback
+ }
+ return &out
+}
diff --git a/pkg/asymptotetrace/privacy_test.go b/pkg/asymptoteobserve/privacy_test.go
similarity index 98%
rename from pkg/asymptotetrace/privacy_test.go
rename to pkg/asymptoteobserve/privacy_test.go
index d0013eb5..b54cd335 100644
--- a/pkg/asymptotetrace/privacy_test.go
+++ b/pkg/asymptoteobserve/privacy_test.go
@@ -1,4 +1,4 @@
-package asymptotetrace
+package asymptoteobserve
import (
"encoding/json"
diff --git a/pkg/asymptotetrace/processor.go b/pkg/asymptoteobserve/processor.go
similarity index 97%
rename from pkg/asymptotetrace/processor.go
rename to pkg/asymptoteobserve/processor.go
index b7f26e07..3d95c775 100644
--- a/pkg/asymptotetrace/processor.go
+++ b/pkg/asymptoteobserve/processor.go
@@ -1,4 +1,4 @@
-package asymptotetrace
+package asymptoteobserve
import "context"
diff --git a/pkg/asymptotetrace/source.go b/pkg/asymptoteobserve/source.go
similarity index 97%
rename from pkg/asymptotetrace/source.go
rename to pkg/asymptoteobserve/source.go
index 54f397dd..24a5cebf 100644
--- a/pkg/asymptotetrace/source.go
+++ b/pkg/asymptoteobserve/source.go
@@ -1,4 +1,4 @@
-package asymptotetrace
+package asymptoteobserve
import "context"
diff --git a/pkg/asymptotetrace/go.mod b/pkg/asymptotetrace/go.mod
deleted file mode 100644
index 99142f88..00000000
--- a/pkg/asymptotetrace/go.mod
+++ /dev/null
@@ -1,3 +0,0 @@
-module github.com/asymptote-labs/agent-beacon/pkg/asymptotetrace
-
-go 1.24