Debian Codegraph @

service/internal/graph/zpages.go

raw symbols SCIP
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package graph // import "go.opentelemetry.io/collector/service/internal/graph"
5
6 import (
7 "net/http"
8 "sort"
9
10 "go.opentelemetry.io/collector/service/internal/zpages"
11 )
12
13 const (
14
15 // URL Params
16 zPipelineName = "pipelinenamez"
17 zComponentName = "componentnamez"
18 zComponentKind = "componentkindz"
19 )
20
21 func (g *Graph) HandleZPages(w http.ResponseWriter, r *http.Request) {
22 qValues := r.URL.Query()
23 pipelineName := qValues.Get(zPipelineName)
24 componentName := qValues.Get(zComponentName)
25 componentKind := qValues.Get(zComponentKind)
26
27 w.Header().Set("Content-Type", "text/html; charset=utf-8")
28 zpages.WriteHTMLPageHeader(w, zpages.HeaderData{Title: "builtPipelines"})
29
30 sumData := zpages.SummaryPipelinesTableData{}
31 sumData.Rows = make([]zpages.SummaryPipelinesTableRowData, 0, len(g.pipelines))
32 for c, p := range g.pipelines {
33 recvIDs := make([]string, 0, len(p.receivers))
34 for _, c := range p.receivers {
35 switch n := c.(type) {
36 case *receiverNode:
37 recvIDs = append(recvIDs, n.componentID.String())
38 case *connectorNode:
39 recvIDs = append(recvIDs, n.componentID.String()+" (connector)")
40 }
41 }
42 procIDs := make([]string, 0, len(p.processors))
43 for _, c := range p.processors {
44 procIDs = append(procIDs, c.(*processorNode).componentID.String())
45 }
46 exprIDs := make([]string, 0, len(p.exporters))
47 for _, c := range p.exporters {
48 switch n := c.(type) {
49 case *exporterNode:
50 exprIDs = append(exprIDs, n.componentID.String())
51 case *connectorNode:
52 exprIDs = append(exprIDs, n.componentID.String()+" (connector)")
53 }
54 }
55
56 sumData.Rows = append(sumData.Rows, zpages.SummaryPipelinesTableRowData{
57 FullName: c.String(),
58 InputType: c.Signal().String(),
59 MutatesData: p.capabilitiesNode.getConsumer().Capabilities().MutatesData,
60 Receivers: recvIDs,
61 Processors: procIDs,
62 Exporters: exprIDs,
63 })
64 }
65 sort.Slice(sumData.Rows, func(i, j int) bool {
66 return sumData.Rows[i].FullName < sumData.Rows[j].FullName
67 })
68 zpages.WriteHTMLPipelinesSummaryTable(w, sumData)
69
70 if pipelineName != "" && componentName != "" && componentKind != "" {
71 fullName := componentName
72 if componentKind == "processor" {
73 fullName = pipelineName + "/" + componentName
74 }
75 zpages.WriteHTMLComponentHeader(w, zpages.ComponentHeaderData{
76 Name: componentKind + ": " + fullName,
77 })
78 // TODO: Add config + status info.
79 }
80 zpages.WriteHTMLPageFooter(w)
81 }