Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[service] Make graph package public #8111

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .chloggen/mx-psi_graph.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: service

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Makes `graph` public to allow overrriding telemetry providers"

# One or more tracking issues or pull requests related to the change
issues: [4970]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
18 changes: 14 additions & 4 deletions service/internal/graph/graph.go → service/graph/graph.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package graph // import "go.opentelemetry.io/collector/service/internal/graph"
package graph // import "go.opentelemetry.io/collector/service/graph"

import (
"context"
Expand All @@ -25,20 +25,27 @@ import (
"go.opentelemetry.io/collector/service/pipelines"
)

// Settings holds configuration for building builtPipelines.
// Settings holds configuration for building a Graph.
type Settings struct {
// Telemetry specifies the telemetry settings.
Telemetry component.TelemetrySettings
// BuildInfo provides collector start information.
BuildInfo component.BuildInfo

ReceiverBuilder *receiver.Builder
// ReceiverBuilder is a helper struct that given a set of Configs and Factories helps with creating receivers.
ReceiverBuilder *receiver.Builder
// ProcessorBuilder is a helper struct that given a set of Configs and Factories helps with creating processors.
ProcessorBuilder *processor.Builder
ExporterBuilder *exporter.Builder
// ExporterBuilder is a helper struct that given a set of Configs and Factories helps with creating exporters.
ExporterBuilder *exporter.Builder
// ConnectorBuilder is a helper struct that given a set of Configs and Factories helps with creating connectors.
ConnectorBuilder *connector.Builder

// PipelineConfigs is a map of component.ID to PipelineConfig.
PipelineConfigs pipelines.Config
mx-psi marked this conversation as resolved.
Show resolved Hide resolved
}

// Graph of collector components.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "Graph" the right name? Just Pipelines maybe in the pipelines package?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a few places where we still call this Pipelines so I moved this to pipelines and renamed to Pipelines. @djaglowski what do you think?

type Graph struct {
// All component instances represented as nodes, with directed edges indicating data flow.
componentGraph *simple.DirectedGraph
Expand All @@ -47,6 +54,7 @@ type Graph struct {
pipelines map[component.ID]*pipelineNodes
}

// Build a collector graph.
func Build(ctx context.Context, set Settings) (*Graph, error) {
mx-psi marked this conversation as resolved.
Show resolved Hide resolved
pipelines := &Graph{
componentGraph: simple.NewDirectedGraph(),
Expand Down Expand Up @@ -316,6 +324,7 @@ type pipelineNodes struct {
exporters map[int64]graph.Node
}

// StartAll components in the graph in topological order.
func (g *Graph) StartAll(ctx context.Context, host component.Host) error {
nodes, err := topo.Sort(g.componentGraph)
if err != nil {
Expand All @@ -338,6 +347,7 @@ func (g *Graph) StartAll(ctx context.Context, host component.Host) error {
return nil
}

// ShutdownAll components in the graph in topological order.
func (g *Graph) ShutdownAll(ctx context.Context) error {
nodes, err := topo.Sort(g.componentGraph)
if err != nil {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion service/internal/graph/nodes.go → service/graph/nodes.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package graph // import "go.opentelemetry.io/collector/service/internal/graph"
package graph // import "go.opentelemetry.io/collector/service/graph"

import (
"context"
Expand Down
3 changes: 2 additions & 1 deletion service/internal/graph/zpages.go → service/graph/zpages.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package graph // import "go.opentelemetry.io/collector/service/internal/graph"
package graph // import "go.opentelemetry.io/collector/service/graph"

import (
"net/http"
Expand All @@ -18,6 +18,7 @@ const (
zComponentKind = "componentkindz"
)

// HandleZPages handles ZPages requests for the zpages extension.
func (g *Graph) HandleZPages(w http.ResponseWriter, r *http.Request) {
qValues := r.URL.Query()
pipelineName := qValues.Get(zPipelineName)
Expand Down
2 changes: 1 addition & 1 deletion service/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"go.opentelemetry.io/collector/processor"
"go.opentelemetry.io/collector/receiver"
"go.opentelemetry.io/collector/service/extensions"
"go.opentelemetry.io/collector/service/internal/graph"
"go.opentelemetry.io/collector/service/graph"
)

var _ component.Host = (*serviceHost)(nil)
Expand Down
2 changes: 1 addition & 1 deletion service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"go.opentelemetry.io/collector/receiver"
semconv "go.opentelemetry.io/collector/semconv/v1.18.0"
"go.opentelemetry.io/collector/service/extensions"
"go.opentelemetry.io/collector/service/internal/graph"
"go.opentelemetry.io/collector/service/graph"
"go.opentelemetry.io/collector/service/internal/proctelemetry"
"go.opentelemetry.io/collector/service/telemetry"
)
Expand Down
Loading