From c3d5b3b0de6c79658d597d48305e8462abde7c0c Mon Sep 17 00:00:00 2001 From: Daniel Jaglowski Date: Fri, 3 Feb 2023 12:25:21 -0500 Subject: [PATCH] Add graph-based GetExporters (#7108) --- service/graph.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/service/graph.go b/service/graph.go index 043d590f785..862381ca4e6 100644 --- a/service/graph.go +++ b/service/graph.go @@ -299,8 +299,20 @@ func (g *pipelinesGraph) ShutdownAll(ctx context.Context) error { } func (g *pipelinesGraph) GetExporters() map[component.DataType]map[component.ID]component.Component { - // TODO actual implementation - return make(map[component.DataType]map[component.ID]component.Component) + exportersMap := make(map[component.DataType]map[component.ID]component.Component) + exportersMap[component.DataTypeTraces] = make(map[component.ID]component.Component) + exportersMap[component.DataTypeMetrics] = make(map[component.ID]component.Component) + exportersMap[component.DataTypeLogs] = make(map[component.ID]component.Component) + + for _, pg := range g.pipelines { + for _, expNode := range pg.exporters { + // Skip connectors, otherwise individual components can introduce cycles + if expNode, ok := g.componentGraph.Node(expNode.ID()).(*exporterNode); ok { + exportersMap[expNode.pipelineType][expNode.componentID] = expNode.Component + } + } + } + return exportersMap } func (g *pipelinesGraph) HandleZPages(w http.ResponseWriter, r *http.Request) {