Skip to content

Commit

Permalink
remove featuregate
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Kruse <[email protected]>
  • Loading branch information
c-kruse committed Sep 28, 2023
1 parent faa54b1 commit e849e2b
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 53 deletions.
8 changes: 0 additions & 8 deletions pkg/receiver/jobreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@ executable at defined intervals, and propagates the output from that process
as log events. In addition, the monitoring job receiver simplifies the process
of downloading runtime assets necessary to run a particular monitoring job.

## Feature Gate

This receiver is currently gated behind a [featuregate][featuregate]
`receiver.monitoringjob.enabled`. To start the collector with monitoringjobs
enabled use the `--feature-gates=receiver.monitoringjob.enabled` flag.

[featuregate]: https://github.com/open-telemetry/opentelemetry-collector/tree/main/featuregate

## Configuration

| Configuration | Default | Description
Expand Down
4 changes: 2 additions & 2 deletions pkg/receiver/jobreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/stretchr/testify v1.8.4
go.opentelemetry.io/collector/component v0.85.0
go.opentelemetry.io/collector/confmap v0.85.0
go.opentelemetry.io/collector/featuregate v1.0.0-rcv0014
go.opentelemetry.io/collector/consumer v0.85.0
go.opentelemetry.io/collector/receiver v0.85.0
go.uber.org/zap v1.25.0
)
Expand Down Expand Up @@ -36,9 +36,9 @@ require (
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/collector v0.85.0 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.85.0 // indirect
go.opentelemetry.io/collector/consumer v0.85.0 // indirect
go.opentelemetry.io/collector/exporter v0.85.0 // indirect
go.opentelemetry.io/collector/extension v0.85.0 // indirect
go.opentelemetry.io/collector/featuregate v1.0.0-rcv0014 // indirect
go.opentelemetry.io/collector/pdata v1.0.0-rcv0014 // indirect
go.opentelemetry.io/collector/processor v0.85.0 // indirect
go.opentelemetry.io/otel v1.17.0 // indirect
Expand Down
22 changes: 0 additions & 22 deletions pkg/receiver/jobreceiver/receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/consumer/consumertest"
"go.opentelemetry.io/collector/featuregate"
"go.opentelemetry.io/collector/receiver/receivertest"
)

Expand All @@ -22,9 +21,6 @@ func TestMain(m *testing.M) {

func TestMonitoringJob(t *testing.T) {
// basic test
require.NoError(t, featuregate.GlobalRegistry().Set(featureEnabledId, true))
t.Cleanup(func() { require.NoError(t, featuregate.GlobalRegistry().Set(featureEnabledId, false)) })

f := NewFactory()
cfg := testdataConfigSimple()

Expand All @@ -43,24 +39,6 @@ func TestMonitoringJob(t *testing.T) {
first := sink.AllLogs()[0]
firstRecord := first.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(0)
assert.Equal(t, "hello world", firstRecord.Body().AsString())

t.Run("disabled by feature gate", func(t *testing.T) {
require.NoError(t, featuregate.GlobalRegistry().Set(featureEnabledId, false))

f := NewFactory()
cfg := testdataConfigSimple()

sink := new(consumertest.LogsSink)

rec, err := f.CreateLogsReceiver(context.Background(), receivertest.NewNopCreateSettings(), cfg, sink)
require.NoError(t, err)

require.NoError(t, rec.Start(context.Background(), componenttest.NewNopHost()))
// TODO(ck) bleh.
<-time.After(time.Millisecond * 1500)

assert.Equal(t, 0, sink.LogRecordCount())
})
}

func testdataConfigSimple() *Config {
Expand Down
21 changes: 0 additions & 21 deletions pkg/receiver/jobreceiver/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,12 @@ import (
"github.com/SumoLogic/sumologic-otel-collector/pkg/receiver/jobreceiver/command"
"github.com/SumoLogic/sumologic-otel-collector/pkg/receiver/jobreceiver/output/consumer"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator"
"go.opentelemetry.io/collector/featuregate"
"go.uber.org/zap"
)

const (
featureEnabledId = "receiver.monitoringjob.enabled"
featureEnabledStage = featuregate.StageAlpha
featureEnabledDescription = "When enabled, the collector will schedule monitoring jobs."
)

var enabledGate *featuregate.Gate

func init() {
enabledGate = featuregate.GlobalRegistry().MustRegister(
featureEnabledId,
featureEnabledStage,
featuregate.WithRegisterDescription(featureEnabledDescription),
)
}

// Build returns the job runner, the process responsible for scheduling and
// running commands and piping their output to the output consumer.
func (c Config) Build(logger *zap.SugaredLogger, out consumer.Interface) (builder.JobRunner, error) {
if !enabledGate.IsEnabled() {
logger.Warn("monitoringjob feature is not enabled, will not run.")
return &nopRunner{}, nil
}
return &runner{
exec: c.Exec,
schedule: c.Schedule,
Expand Down

0 comments on commit e849e2b

Please sign in to comment.