Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 12 additions & 0 deletions service/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,15 @@ Number of items emitted from the receiver. [Development]
| Unit | Metric Type | Value Type | Monotonic | Stability |
| ---- | ----------- | ---------- | --------- | --------- |
| {item} | Sum | Int | true | Development |

## Feature Gates

This component has the following feature gates:

| Feature Gate | Stage | Description | From Version | To Version | Reference |
| ------------ | ----- | ----------- | ------------ | ---------- | --------- |
| `service.AllowNoPipelines` | alpha | Allow starting the Collector without starting any pipelines. | v0.112.0 | N/A | [Link](https://github.com/open-telemetry/opentelemetry-collector/pull/12613) |
| `service.profilesSupport` | alpha | Controls whether profiles support can be enabled | v0.112.0 | N/A | [Link](https://github.com/open-telemetry/opentelemetry-collector/pull/11477) |
| `telemetry.UseLocalHostAsDefaultMetricsAddress` | beta | Controls whether default Prometheus metrics server use localhost as the default host for their endpoints | v0.111.0 | N/A | [Link](https://github.com/open-telemetry/opentelemetry-collector/pull/11251) |

For more information about feature gates, see the [Feature Gates](https://github.com/open-telemetry/opentelemetry-collector/blob/main/featuregate/README.md) documentation.
3 changes: 1 addition & 2 deletions service/generated_package_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions service/internal/metadata/generated_feature_gates.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions service/internal/metadatatest/generated_telemetrytest.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions service/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,20 @@ telemetry:
sum:
value_type: int
monotonic: true

feature_gates:
- id: service.AllowNoPipelines
description: 'Allow starting the Collector without starting any pipelines.'
stage: alpha
from_version: 'v0.112.0'
reference_url: 'https://github.com/open-telemetry/opentelemetry-collector/pull/12613'
- id: service.profilesSupport
description: 'Controls whether profiles support can be enabled'
stage: alpha
from_version: 'v0.112.0'
reference_url: 'https://github.com/open-telemetry/opentelemetry-collector/pull/11477'
- id: telemetry.UseLocalHostAsDefaultMetricsAddress
description: 'Controls whether default Prometheus metrics server use localhost as the default host for their endpoints'
stage: beta
from_version: 'v0.111.0'
reference_url: 'https://github.com/open-telemetry/opentelemetry-collector/pull/11251'
22 changes: 5 additions & 17 deletions service/pipelines/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,49 +8,37 @@ import (
"fmt"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/featuregate"
"go.opentelemetry.io/collector/pipeline"
"go.opentelemetry.io/collector/pipeline/xpipeline"
"go.opentelemetry.io/collector/service/internal/metadata"
)

var (
errMissingServicePipelines = errors.New("service must have at least one pipeline")
errMissingServicePipelineReceivers = errors.New("must have at least one receiver")
errMissingServicePipelineExporters = errors.New("must have at least one exporter")

serviceProfileSupportGateID = "service.profilesSupport"
serviceProfileSupportGate = featuregate.GlobalRegistry().MustRegister(
serviceProfileSupportGateID,
featuregate.StageAlpha,
featuregate.WithRegisterFromVersion("v0.112.0"),
featuregate.WithRegisterDescription("Controls whether profiles support can be enabled"),
)
AllowNoPipelines = featuregate.GlobalRegistry().MustRegister(
"service.AllowNoPipelines",
featuregate.StageAlpha,
featuregate.WithRegisterFromVersion("v0.122.0"),
featuregate.WithRegisterDescription("Allow starting the Collector without starting any pipelines."),
)
AllowNoPipelines = metadata.ServiceAllowNoPipelinesFeatureGate
Copy link
Member Author

Choose a reason for hiding this comment

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

IMHO it would be nice not to make this public. But we use it in otelcol.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed it would be nice to have it private, but unfortunately the otelcol/service responsibility distinction can be a little fuzzy. It was already public before this PR, so it's fine to leave it for now.

Copy link
Member Author

Choose a reason for hiding this comment

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

One thing I've been pondering is whether it would make more sense to have 2 feature gates with the same name.
One in otelcol, and one in service. Then, both could be private. And both components would be documented.

)

// Config defines the configurable settings for service telemetry.
type Config map[pipeline.ID]*PipelineConfig

func (cfg Config) Validate() error {
// Must have at least one pipeline unless explicitly disabled.
if !AllowNoPipelines.IsEnabled() && len(cfg) == 0 {
if !metadata.ServiceAllowNoPipelinesFeatureGate.IsEnabled() && len(cfg) == 0 {
return errMissingServicePipelines
}

if !serviceProfileSupportGate.IsEnabled() {
if !metadata.ServiceProfilesSupportFeatureGate.IsEnabled() {
// Check that all pipelines have at least one receiver and one exporter, and they reference
// only configured components.
for pipelineID := range cfg {
if pipelineID.Signal() == xpipeline.SignalProfiles {
return fmt.Errorf(
"pipeline %q: profiling signal support is at alpha level, gated under the %q feature gate",
pipelineID.String(),
serviceProfileSupportGateID,
metadata.ServiceProfilesSupportFeatureGate.ID(),
)
}
}
Expand Down
5 changes: 3 additions & 2 deletions service/pipelines/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"go.opentelemetry.io/collector/featuregate"
"go.opentelemetry.io/collector/pipeline"
"go.opentelemetry.io/collector/pipeline/xpipeline"
"go.opentelemetry.io/collector/service/internal/metadata"
)

func TestConfigValidate(t *testing.T) {
Expand Down Expand Up @@ -78,7 +79,7 @@ func TestConfigValidate(t *testing.T) {
{
name: "enabled-featuregate-profiles",
cfgFn: func(t *testing.T) Config {
require.NoError(t, featuregate.GlobalRegistry().Set(serviceProfileSupportGateID, true))
require.NoError(t, featuregate.GlobalRegistry().Set(metadata.ServiceProfilesSupportFeatureGate.ID(), true))

cfg := generateConfig(t)
cfg[pipeline.NewID(xpipeline.SignalProfiles)] = &PipelineConfig{
Expand All @@ -102,7 +103,7 @@ func TestConfigValidate(t *testing.T) {
}

// Clean up the profiles support gate, which may have been enabled in `cfgFn`.
require.NoError(t, featuregate.GlobalRegistry().Set(serviceProfileSupportGateID, false))
require.NoError(t, featuregate.GlobalRegistry().Set(metadata.ServiceProfilesSupportFeatureGate.ID(), false))
})
}
}
Expand Down
11 changes: 2 additions & 9 deletions service/telemetry/otelconftelemetry/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,10 @@ import (

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/configtelemetry"
"go.opentelemetry.io/collector/featuregate"
"go.opentelemetry.io/collector/service/internal/metadata"
"go.opentelemetry.io/collector/service/telemetry"
)

var useLocalHostAsDefaultMetricsAddressFeatureGate = featuregate.GlobalRegistry().MustRegister(
"telemetry.UseLocalHostAsDefaultMetricsAddress",
featuregate.StageBeta,
featuregate.WithRegisterFromVersion("v0.111.0"),
featuregate.WithRegisterDescription("controls whether default Prometheus metrics server use localhost as the default host for their endpoints"),
)

// NewFactory creates a new telemetry.Factory that uses otelconf
// to configure opentelemetry-go SDK telemetry providers.
func NewFactory() telemetry.Factory {
Expand All @@ -36,7 +29,7 @@ func NewFactory() telemetry.Factory {

func createDefaultConfig() component.Config {
metricsHost := "localhost"
if !useLocalHostAsDefaultMetricsAddressFeatureGate.IsEnabled() {
if !metadata.TelemetryUseLocalHostAsDefaultMetricsAddressFeatureGate.IsEnabled() {
metricsHost = ""
}

Expand Down
7 changes: 4 additions & 3 deletions service/telemetry/otelconftelemetry/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/stretchr/testify/require"

"go.opentelemetry.io/collector/featuregate"
"go.opentelemetry.io/collector/service/internal/metadata"
)

func TestDefaultConfig(t *testing.T) {
Expand All @@ -30,11 +31,11 @@ func TestDefaultConfig(t *testing.T) {

for _, tt := range tests {
t.Run("UseLocalHostAsDefaultMetricsAddress/"+strconv.FormatBool(tt.gate), func(t *testing.T) {
prev := useLocalHostAsDefaultMetricsAddressFeatureGate.IsEnabled()
require.NoError(t, featuregate.GlobalRegistry().Set(useLocalHostAsDefaultMetricsAddressFeatureGate.ID(), tt.gate))
prev := metadata.TelemetryUseLocalHostAsDefaultMetricsAddressFeatureGate.IsEnabled()
require.NoError(t, featuregate.GlobalRegistry().Set(metadata.TelemetryUseLocalHostAsDefaultMetricsAddressFeatureGate.ID(), tt.gate))
defer func() {
// Restore previous value.
require.NoError(t, featuregate.GlobalRegistry().Set(useLocalHostAsDefaultMetricsAddressFeatureGate.ID(), prev))
require.NoError(t, featuregate.GlobalRegistry().Set(metadata.TelemetryUseLocalHostAsDefaultMetricsAddressFeatureGate.ID(), prev))
}()
cfg := NewFactory().CreateDefaultConfig()
require.Len(t, cfg.(*Config).Metrics.Readers, 1)
Expand Down
Loading