Skip to content

Commit

Permalink
internal: rename references of flow mode to Alloy (#83)
Browse files Browse the repository at this point in the history
This renames all references of "flow mode" to Alloy or Grafana Alloy.
  • Loading branch information
rfratto authored Mar 26, 2024
1 parent 01e4c95 commit 4574031
Show file tree
Hide file tree
Showing 173 changed files with 540 additions and 578 deletions.
4 changes: 2 additions & 2 deletions internal/alloy/internal/testcomponents/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func NewModuleComponent(o component.Options) (*ModuleComponent, error) {
return c, err
}

// LoadAlloySource loads the flow controller with the current component source.
// LoadAlloySource loads the controller with the current component source.
// It will set the component health in addition to return the error so that the consumer can rely on either or both.
// If the content is the same as the last time it was successfully loaded, it will not be reloaded.
func (c *ModuleComponent) LoadAlloySource(args map[string]any, contentValue string) error {
Expand Down Expand Up @@ -70,7 +70,7 @@ func (c *ModuleComponent) LoadAlloySource(args map[string]any, contentValue stri
return nil
}

// RunAlloyController runs the flow controller that all module components start.
// RunAlloyController runs the controller that all module components start.
func (c *ModuleComponent) RunAlloyController(ctx context.Context) {
err := c.mod.Run(ctx)
if err != nil {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Package findcomponents exposes an Analyzer which ensures that created Flow
// Package findcomponents exposes an Analyzer which ensures that created
// components are imported by a registry package.
package findcomponents

Expand All @@ -13,7 +13,7 @@ import (

var Analyzer = &analysis.Analyzer{
Name: "findcomponents",
Doc: "ensure Flow components are imported",
Doc: "ensure components are imported",
Run: run,
}

Expand Down Expand Up @@ -67,8 +67,8 @@ func run(p *analysis.Pass) (interface{}, error) {
}

// findComponentPackages returns a map of discovered packages which declare
// Flow components. The pattern argument controls the full list of patterns
// which are searched (e.g., "./..." or "./component/...").
// components. The pattern argument controls the full list of patterns which
// are searched (e.g., "./..." or "./component/...").
func findComponentPackages(pattern string) (map[string]struct{}, error) {
pkgs, err := packages.Load(&packages.Config{
Mode: packages.NeedName | packages.NeedTypes | packages.NeedSyntax | packages.NeedTypesInfo,
Expand Down
2 changes: 1 addition & 1 deletion internal/component/common/config/selectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type LabelSelector struct {
MatchExpressions []MatchExpression `alloy:"match_expression,block,optional"`
}

// BuildSelector builds a [labels.Selector] from a Flow LabelSelector.
// BuildSelector builds a [labels.Selector] from an Alloy LabelSelector.
func (ls *LabelSelector) BuildSelector() (labels.Selector, error) {
if ls == nil {
return metav1.LabelSelectorAsSelector(nil)
Expand Down
12 changes: 7 additions & 5 deletions internal/component/common/loki/client/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,14 @@ func (p watcherClientPair) Stop(drain bool) {
p.client.Stop()
}

// Manager manages remote write client instantiation, and connects the related components to orchestrate the flow of loki.Entry
// from the scrape targets, to the remote write clients themselves.
// Manager manages remote write client instantiation, and connects the related
// components to orchestrate the flow of loki.Entry from the scrape targets, to
// the remote write clients themselves.
//
// Right now it just supports instantiating the WAL writer side of the future-to-be WAL enabled client. In follow-up
// work, tracked in https://github.com/grafana/loki/issues/8197, this Manager will be responsible for instantiating all client
// types: Logger, Multi and WAL.
// Right now it just supports instantiating the WAL writer side of the
// future-to-be WAL enabled client. In follow-up work, tracked in
// https://github.com/grafana/loki/issues/8197, this Manager will be
// responsible for instantiating all client types: Logger, Multi and WAL.
type Manager struct {
name string

Expand Down
14 changes: 8 additions & 6 deletions internal/component/common/net/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import (
"github.com/prometheus/common/model"
)

// TargetServer is wrapper around dskit.Server that handles some common configuration used in all flow components
// that expose a network server. It just handles configuration and initialization, the handlers implementation are left
// to the consumer.
// TargetServer is wrapper around dskit.Server that handles some common
// configuration used in all components that expose a network server. It just
// handles configuration and initialization, the handlers implementation are
// left to the consumer.
type TargetServer struct {
logger log.Logger
config *dskit.Config
Expand Down Expand Up @@ -48,9 +49,10 @@ func NewTargetServer(logger log.Logger, metricsNamespace string, reg prometheus.
ts.config = &serverCfg
// To prevent metric collisions because all metrics are going to be registered in the global Prometheus registry.
ts.config.MetricsNamespace = ts.metricsNamespace
// We don't want the /debug and /metrics endpoints running, since this is not the main Flow HTTP server.
// We want this target to expose the least surface area possible, hence disabling dskit HTTP server metrics
// and debugging functionality.
// We don't want the /debug and /metrics endpoints running, since this is not
// the main HTTP server. We want this target to expose the least surface area
// possible, hence disabling dskit HTTP server metrics and debugging
// functionality.
ts.config.RegisterInstrumentation = false
// Add logger to dskit
ts.config.Log = ts.logger
Expand Down
12 changes: 6 additions & 6 deletions internal/component/component.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Package component describes the interfaces which Flow components implement.
// Package component describes the interfaces which components implement.
//
// A Flow component is a distinct piece of business logic that accepts inputs
// A component is a distinct piece of business logic that accepts inputs
// (Arguments) for its configuration and can optionally export a set of outputs
// (Exports).
//
Expand All @@ -23,7 +23,7 @@
//
// The set of River element names of a given component's Arguments and Exports
// types must not overlap. Additionally, the following River field and block
// names are reserved for use by the Flow controller:
// names are reserved for use by the Alloy controller:
//
// - for_each
// - enabled
Expand Down Expand Up @@ -76,9 +76,9 @@ type Arguments interface{}
// Exports implementations.
type Exports interface{}

// Component is the base interface for a Flow component. Components may
// implement extension interfaces (named <Extension>Component) to implement
// extra known behavior.
// Component is the base interface for a component. Components may implement
// extension interfaces (named <Extension>Component) to implement extra known
// behavior.
type Component interface {
// Run starts the component, blocking until ctx is canceled or the component
// suffers a fatal error. Run is guaranteed to be called exactly once per
Expand Down
2 changes: 1 addition & 1 deletion internal/component/component_health.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type HealthComponent interface {

// CurrentHealth returns the current Health status for the component.
//
// CurrentHealth may be overridden by the Flow controller if there is a
// CurrentHealth may be overridden by the Alloy controller if there is a
// higher-level issue, such as a config file being invalid or a Component
// shutting down unexpectedly.
CurrentHealth() Health
Expand Down
2 changes: 1 addition & 1 deletion internal/component/discovery/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
type Target map[string]string

// DistributedTargets uses the node's Lookup method to distribute discovery
// targets when a Flow component runs in a cluster.
// targets when a component runs in a cluster.
type DistributedTargets struct {
useClustering bool
cluster cluster.Cluster
Expand Down
10 changes: 5 additions & 5 deletions internal/component/discovery/relabel/relabel.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"sync"

"github.com/grafana/alloy/internal/component"
flow_relabel "github.com/grafana/alloy/internal/component/common/relabel"
alloy_relabel "github.com/grafana/alloy/internal/component/common/relabel"
"github.com/grafana/alloy/internal/component/discovery"
"github.com/grafana/alloy/internal/featuregate"
"github.com/prometheus/prometheus/model/labels"
Expand All @@ -31,13 +31,13 @@ type Arguments struct {
Targets []discovery.Target `alloy:"targets,attr"`

// The relabelling rules to apply to each target's label set.
RelabelConfigs []*flow_relabel.Config `alloy:"rule,block,optional"`
RelabelConfigs []*alloy_relabel.Config `alloy:"rule,block,optional"`
}

// Exports holds values which are exported by the discovery.relabel component.
type Exports struct {
Output []discovery.Target `alloy:"output,attr"`
Rules flow_relabel.Rules `alloy:"rules,attr"`
Output []discovery.Target `alloy:"output,attr"`
Rules alloy_relabel.Rules `alloy:"rules,attr"`
}

// Component implements the discovery.relabel component.
Expand Down Expand Up @@ -76,7 +76,7 @@ func (c *Component) Update(args component.Arguments) error {
newArgs := args.(Arguments)

targets := make([]discovery.Target, 0, len(newArgs.Targets))
relabelConfigs := flow_relabel.ComponentToPromRelabelConfigs(newArgs.RelabelConfigs)
relabelConfigs := alloy_relabel.ComponentToPromRelabelConfigs(newArgs.RelabelConfigs)
c.rcs = relabelConfigs

for _, t := range newArgs.Targets {
Expand Down
6 changes: 3 additions & 3 deletions internal/component/discovery/relabel/relabel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"time"

"github.com/grafana/alloy/internal/alloy/componenttest"
flow_relabel "github.com/grafana/alloy/internal/component/common/relabel"
alloy_relabel "github.com/grafana/alloy/internal/component/common/relabel"
"github.com/grafana/alloy/internal/component/discovery"
"github.com/grafana/alloy/internal/component/discovery/relabel"
"github.com/grafana/alloy/syntax"
Expand Down Expand Up @@ -118,8 +118,8 @@ rule {
require.Len(t, gotOriginal, 1)
require.Len(t, gotUpdated, 1)

require.Equal(t, gotOriginal[0].Action, flow_relabel.Keep)
require.Equal(t, gotUpdated[0].Action, flow_relabel.Drop)
require.Equal(t, gotOriginal[0].Action, alloy_relabel.Keep)
require.Equal(t, gotUpdated[0].Action, alloy_relabel.Drop)
require.Equal(t, gotUpdated[0].SourceLabels, gotOriginal[0].SourceLabels)
require.Equal(t, gotUpdated[0].Regex, gotOriginal[0].Regex)
}
2 changes: 1 addition & 1 deletion internal/component/local/file_match/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func createComponentWithLabels(t *testing.T, dir string, paths []string, exclude
}
c, err := New(component.Options{
ID: "test",
Logger: util.TestFlowLogger(t),
Logger: util.TestAlloyLogger(t),
DataPath: dir,
OnStateChange: func(e component.Exports) {

Expand Down
8 changes: 4 additions & 4 deletions internal/component/loki/process/process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func TestJSONLabelsStage(t *testing.T) {

// Create and run the component, so that it can process and forwards logs.
opts := component.Options{
Logger: util.TestFlowLogger(t),
Logger: util.TestAlloyLogger(t),
Registerer: prometheus.NewRegistry(),
OnStateChange: func(e component.Exports) {},
}
Expand Down Expand Up @@ -161,7 +161,7 @@ stage.label_keep {

// Create and run the component, so that it can process and forwards logs.
opts := component.Options{
Logger: util.TestFlowLogger(t),
Logger: util.TestAlloyLogger(t),
Registerer: prometheus.NewRegistry(),
OnStateChange: func(e component.Exports) {},
}
Expand Down Expand Up @@ -256,7 +256,7 @@ stage.labels {

// Create and run the component, so that it can process and forwards logs.
opts := component.Options{
Logger: util.TestFlowLogger(t),
Logger: util.TestAlloyLogger(t),
Registerer: prometheus.NewRegistry(),
OnStateChange: func(e component.Exports) {},
}
Expand Down Expand Up @@ -422,7 +422,7 @@ func TestDeadlockWithFrequentUpdates(t *testing.T) {

// Create and run the component, so that it can process and forwards logs.
opts := component.Options{
Logger: util.TestFlowLogger(t),
Logger: util.TestAlloyLogger(t),
Registerer: prometheus.NewRegistry(),
OnStateChange: func(e component.Exports) {},
}
Expand Down
4 changes: 2 additions & 2 deletions internal/component/loki/process/stages/drop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ func Test_dropStage_Process(t *testing.T) {
if err != nil {
t.Error(err)
}
logger := util.TestFlowLogger(t)
logger := util.TestAlloyLogger(t)
m, err := newDropStage(logger, *tt.config, prometheus.DefaultRegisterer)
require.NoError(t, err)
out := processEntries(m, newEntry(tt.extracted, tt.labels, tt.entry, tt.t))
Expand All @@ -431,7 +431,7 @@ func Test_dropStage_Process(t *testing.T) {
func TestDropPipeline(t *testing.T) {
registry := prometheus.NewRegistry()
plName := "test_drop_pipeline"
logger := util.TestFlowLogger(t)
logger := util.TestAlloyLogger(t)
pl, err := NewPipeline(logger, loadConfig(testDropRiver), &plName, registry)
require.NoError(t, err)
out := processEntries(pl,
Expand Down
6 changes: 3 additions & 3 deletions internal/component/loki/process/stages/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var testJSONLogLine = `

func TestPipeline_JSON(t *testing.T) {
t.Parallel()
logger := util.TestFlowLogger(t)
logger := util.TestAlloyLogger(t)

tests := map[string]struct {
config string
Expand Down Expand Up @@ -212,7 +212,7 @@ var logFixture = `

func TestJSONParser_Parse(t *testing.T) {
t.Parallel()
logger := util.TestFlowLogger(t)
logger := util.TestAlloyLogger(t)

var logString = "log"
tests := map[string]struct {
Expand Down Expand Up @@ -351,7 +351,7 @@ func TestJSONParser_Parse(t *testing.T) {
}

func TestValidateJSONDrop(t *testing.T) {
logger := util.TestFlowLogger(t)
logger := util.TestAlloyLogger(t)
labels := map[string]string{"foo": "bar"}
matchConfig := &JSONConfig{
DropMalformed: true,
Expand Down
2 changes: 1 addition & 1 deletion internal/component/loki/process/stages/logfmt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ var testLogfmtLogFixture = `

func TestLogfmtParser_Parse(t *testing.T) {
t.Parallel()
logger := util.TestFlowLogger(t)
logger := util.TestAlloyLogger(t)
tests := map[string]struct {
config LogfmtConfig
extracted map[string]interface{}
Expand Down
4 changes: 2 additions & 2 deletions internal/component/loki/process/stages/match_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ var testMatchLogLineApp2 = `
func TestMatchStage(t *testing.T) {
registry := prometheus.NewRegistry()
plName := "test_match_pipeline"
logger := util.TestFlowLogger(t)
logger := util.TestAlloyLogger(t)
pl, err := NewPipeline(logger, loadConfig(testMatchRiver), &plName, registry)
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -159,7 +159,7 @@ func TestMatcher(t *testing.T) {
"",
"",
}
logger := util.TestFlowLogger(t)
logger := util.TestAlloyLogger(t)
s, err := newMatcherStage(logger, nil, matchConfig, prometheus.DefaultRegisterer)
if (err != nil) != tt.wantErr {
t.Errorf("withMatcher() error = %v, wantErr %v", err, tt.wantErr)
Expand Down
6 changes: 3 additions & 3 deletions internal/component/loki/process/stages/multiline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

func TestMultilineStageProcess(t *testing.T) {
logger := util.TestFlowLogger(t)
logger := util.TestAlloyLogger(t)
mcfg := MultilineConfig{Expression: "^START", MaxWaitTime: 3 * time.Second}
err := validateMultilineConfig(&mcfg)
require.NoError(t, err)
Expand All @@ -41,7 +41,7 @@ func TestMultilineStageProcess(t *testing.T) {
}

func TestMultilineStageMultiStreams(t *testing.T) {
logger := util.TestFlowLogger(t)
logger := util.TestAlloyLogger(t)
mcfg := MultilineConfig{Expression: "^START", MaxWaitTime: 3 * time.Second}
err := validateMultilineConfig(&mcfg)
require.NoError(t, err)
Expand Down Expand Up @@ -81,7 +81,7 @@ func TestMultilineStageMultiStreams(t *testing.T) {
}

func TestMultilineStageMaxWaitTime(t *testing.T) {
logger := util.TestFlowLogger(t)
logger := util.TestAlloyLogger(t)
mcfg := MultilineConfig{Expression: "^START", MaxWaitTime: 100 * time.Millisecond}
err := validateMultilineConfig(&mcfg)
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion internal/component/loki/process/stages/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var testOutputLogLineWithMissingKey = `
`

func TestPipeline_Output(t *testing.T) {
logger := util.TestFlowLogger(t)
logger := util.TestAlloyLogger(t)
pl, err := NewPipeline(logger, loadConfig(testOutputRiver), nil, prometheus.DefaultRegisterer)
require.NoError(t, err)

Expand Down
4 changes: 2 additions & 2 deletions internal/component/loki/process/stages/pack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ stage.match {
func TestPackPipeline(t *testing.T) {
registry := prometheus.NewRegistry()
plName := "test_pack_pipeline"
logger := util.TestFlowLogger(t)
logger := util.TestAlloyLogger(t)
pl, err := NewPipeline(logger, loadConfig(testPackRiver), &plName, registry)
require.NoError(t, err)

Expand Down Expand Up @@ -335,7 +335,7 @@ func TestPackStage(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
logger := util.TestFlowLogger(t)
logger := util.TestAlloyLogger(t)
m := newPackStage(logger, *tt.config, prometheus.DefaultRegisterer)
// Normal pipeline operation will put all the labels into the extracted map
// replicate that here.
Expand Down
Loading

0 comments on commit 4574031

Please sign in to comment.