MCPcopy Create free account
hub / github.com/docker/docker-agent / annotateFilesystemSpan

Function annotateFilesystemSpan

pkg/tools/builtin/filesystem/filesystem.go:37–49  ·  view source on GitHub ↗

annotateFilesystemSpan stamps the operation kind and target path onto the active runtime.tool.handler span. Paths ship unconditionally — they're the main signal of what the agent touched. Drop or hash `cagent.tool.filesystem.path` at the OTel collector if paths routinely reveal identifiers you don't

(ctx context.Context, op, path string)

Source from the content-addressed store, hash-verified

35// `cagent.tool.filesystem.path` at the OTel collector if paths
36// routinely reveal identifiers you don't want shipped.
37func annotateFilesystemSpan(ctx context.Context, op, path string) {
38 span := trace.SpanFromContext(ctx)
39 if !span.IsRecording() {
40 return
41 }
42 attrs := []attribute.KeyValue{
43 attribute.String("cagent.tool.filesystem.op", op),
44 }
45 if path != "" {
46 attrs = append(attrs, attribute.String("cagent.tool.filesystem.path", path))
47 }
48 span.SetAttributes(attrs...)
49}
50
51// maxFilesystemPathsAttr caps how many entries from args.Paths land on a
52// span attribute. Many backends drop attributes over a few KiB and per-

Callers 9

handleDirectoryTreeMethod · 0.85
handleEditFileMethod · 0.85
handleListDirectoryMethod · 0.85
handleReadFileMethod · 0.85
handleWriteFileMethod · 0.85
handleCreateDirectoryMethod · 0.85
handleRemoveDirectoryMethod · 0.85

Calls 3

IsRecordingMethod · 0.65
StringMethod · 0.45
SetAttributesMethod · 0.45

Tested by

no test coverage detected