MCPcopy Create free account
hub / github.com/compozy/agh / observabilitySources

Method observabilitySources

internal/memory/observability.go:31–76  ·  view source on GitHub ↗
(ctx context.Context, workspaces []string)

Source from the content-addressed store, hash-verified

29}
30
31func (s *Store) observabilitySources(ctx context.Context, workspaces []string) ([]observabilitySource, error) {
32 sources := make([]observabilitySource, 0, len(workspaces)+1)
33 seenPaths := make(map[string]struct{})
34 globalSource := -1
35 seenGlobalWorkspaceIDs := make(map[string]struct{})
36 if s.catalog != nil {
37 path := filepath.Clean(s.catalog.path)
38 globalSource = len(sources)
39 sources = append(sources, observabilitySource{
40 id: observabilityGlobalKey,
41 path: path,
42 store: s,
43 catalog: s.catalog,
44 filters: []catalogFilter{{scope: memcontract.ScopeGlobal}},
45 })
46 seenPaths[path] = struct{}{}
47 }
48 for _, workspace := range workspaces {
49 if globalSource >= 0 {
50 filter, ok, err := workspaceObservabilityFilter(ctx, workspace)
51 if err != nil {
52 return nil, err
53 }
54 if ok {
55 workspaceID := strings.TrimSpace(filter.workspaceID)
56 if _, exists := seenGlobalWorkspaceIDs[workspaceID]; !exists {
57 seenGlobalWorkspaceIDs[workspaceID] = struct{}{}
58 sources[globalSource].filters = append(sources[globalSource].filters, filter)
59 }
60 }
61 }
62 source, ok, err := s.workspaceObservabilitySource(ctx, workspace)
63 if err != nil {
64 return nil, err
65 }
66 if !ok {
67 continue
68 }
69 if _, exists := seenPaths[source.path]; exists {
70 continue
71 }
72 seenPaths[source.path] = struct{}{}
73 sources = append(sources, source)
74 }
75 return sources, nil
76}
77
78func workspaceObservabilityFilter(ctx context.Context, workspace string) (catalogFilter, bool, error) {
79 workspaceRoot := canonicalWorkspaceRoot(workspace)

Callers 2

healthSourcesMethod · 0.95

Calls 3

appendFunction · 0.85

Tested by

no test coverage detected