Skip to content

Commit

Permalink
Consolidate zpages constants (#7275)
Browse files Browse the repository at this point in the history
  • Loading branch information
djaglowski authored Mar 3, 2023
1 parent 900f699 commit a0b905b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
6 changes: 0 additions & 6 deletions service/pipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ import (
"go.opentelemetry.io/collector/service/internal/fanoutconsumer"
)

const (
zPipelineName = "zpipelinename"
zComponentName = "zcomponentname"
zComponentKind = "zcomponentkind"
)

// baseConsumer redeclared here since not public in consumer package. May consider to make that public.
type baseConsumer interface {
Capabilities() consumer.Capabilities
Expand Down
28 changes: 17 additions & 11 deletions service/zpages.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,23 @@ import (
)

const (
servicezPath = "servicez"
pipelinezPath = "pipelinez"
extensionzPath = "extensionz"
featurezPath = "featurez"
// Paths
zServicePath = "servicez"
zPipelinePath = "pipelinez"
zExtensionPath = "extensionz"
zFeaturePath = "featurez"

// URL Params
zPipelineName = "pipelinenamez"
zComponentName = "componentnamez"
zComponentKind = "componentkindz"
)

func (host *serviceHost) RegisterZPages(mux *http.ServeMux, pathPrefix string) {
mux.HandleFunc(path.Join(pathPrefix, servicezPath), host.zPagesRequest)
mux.HandleFunc(path.Join(pathPrefix, pipelinezPath), host.pipelines.HandleZPages)
mux.HandleFunc(path.Join(pathPrefix, extensionzPath), host.serviceExtensions.HandleZPages)
mux.HandleFunc(path.Join(pathPrefix, featurezPath), handleFeaturezRequest)
mux.HandleFunc(path.Join(pathPrefix, zServicePath), host.zPagesRequest)
mux.HandleFunc(path.Join(pathPrefix, zPipelinePath), host.pipelines.HandleZPages)
mux.HandleFunc(path.Join(pathPrefix, zExtensionPath), host.serviceExtensions.HandleZPages)
mux.HandleFunc(path.Join(pathPrefix, zFeaturePath), handleFeaturezRequest)
}

func (host *serviceHost) zPagesRequest(w http.ResponseWriter, r *http.Request) {
Expand All @@ -46,17 +52,17 @@ func (host *serviceHost) zPagesRequest(w http.ResponseWriter, r *http.Request) {
zpages.WriteHTMLPropertiesTable(w, zpages.PropertiesTableData{Name: "Runtime Info", Properties: runtimeinfo.Info()})
zpages.WriteHTMLComponentHeader(w, zpages.ComponentHeaderData{
Name: "Pipelines",
ComponentEndpoint: pipelinezPath,
ComponentEndpoint: zPipelinePath,
Link: true,
})
zpages.WriteHTMLComponentHeader(w, zpages.ComponentHeaderData{
Name: "Extensions",
ComponentEndpoint: extensionzPath,
ComponentEndpoint: zExtensionPath,
Link: true,
})
zpages.WriteHTMLComponentHeader(w, zpages.ComponentHeaderData{
Name: "Features",
ComponentEndpoint: featurezPath,
ComponentEndpoint: zFeaturePath,
Link: true,
})
zpages.WriteHTMLPageFooter(w)
Expand Down

0 comments on commit a0b905b

Please sign in to comment.