Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
27 changes: 27 additions & 0 deletions .chloggen/47526.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# 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. receiver/filelog)
component: extension/health_check

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Migrate extension.healthcheck.useComponentStatus feature gate registration from manual code to metadata.yaml for mdatagen code generation

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [46116]

# (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:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
3 changes: 0 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,6 @@ linters:
- linters:
- forbidigo
path: extension/encoding/awslogsencodingextension/
- linters:
- forbidigo
path: extension/healthcheckextension/
- linters:
- forbidigo
path: extension/jaegerremotesampling/
Expand Down
3 changes: 2 additions & 1 deletion extension/healthcheckextension/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package healthcheckextension // import "github.com/open-telemetry/opentelemetry-
import (
"errors"

"github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension/internal/metadata"
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/healthcheck"
)

Expand All @@ -16,7 +17,7 @@ type Config struct {

// Validate checks if the extension configuration is valid, including feature gate checks.
func (c *Config) Validate() error {
if !useComponentStatusGate.IsEnabled() && (c.HTTPConfig != nil || c.GRPCConfig != nil) {
if !metadata.ExtensionHealthcheckUseComponentStatusFeatureGate.IsEnabled() && (c.HTTPConfig != nil || c.GRPCConfig != nil) {
return errors.New(
"v2 healthcheck configuration (http/grpc fields) detected but feature gate is disabled. " +
"Either remove the v2 config fields or enable the feature gate with: " +
Expand Down
6 changes: 3 additions & 3 deletions extension/healthcheckextension/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ func TestLoadConfigV2WithoutGate(t *testing.T) {
}

func TestLoadConfigV2WithGate(t *testing.T) {
prev := useComponentStatusGate.IsEnabled()
require.NoError(t, featuregate.GlobalRegistry().Set(useComponentStatusGate.ID(), true))
prev := metadata.ExtensionHealthcheckUseComponentStatusFeatureGate.IsEnabled()
require.NoError(t, featuregate.GlobalRegistry().Set(metadata.ExtensionHealthcheckUseComponentStatusFeatureGate.ID(), true))
t.Cleanup(func() {
require.NoError(t, featuregate.GlobalRegistry().Set(useComponentStatusGate.ID(), prev))
require.NoError(t, featuregate.GlobalRegistry().Set(metadata.ExtensionHealthcheckUseComponentStatusFeatureGate.ID(), prev))
})

cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml"))
Expand Down
13 changes: 13 additions & 0 deletions extension/healthcheckextension/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[comment]: <> (Code generated by mdatagen. DO NOT EDIT.)

# health_check

## Feature Gates

This component has the following feature gates:

| Feature Gate | Stage | Description | From Version | To Version | Reference |
| ------------ | ----- | ----------- | ------------ | ---------- | --------- |
| `extension.healthcheck.useComponentStatus` | alpha | Switch to the shared healthcheck implementation powered by component status events | v0.142.0 | N/A | [Link](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/42256) |

For more information about feature gates, see the [Feature Gates](https://github.com/open-telemetry/opentelemetry-collector/blob/main/featuregate/README.md) documentation.
13 changes: 1 addition & 12 deletions extension/healthcheckextension/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"go.opentelemetry.io/collector/config/confighttp"
"go.opentelemetry.io/collector/config/confignet"
"go.opentelemetry.io/collector/extension"
"go.opentelemetry.io/collector/featuregate"

"github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension/internal/metadata"
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/testutil"
Expand All @@ -19,16 +18,6 @@ import (

const defaultPort = 13133

// Feature gate that switches the extension to the shared healthcheck implementation
var useComponentStatusGate = featuregate.GlobalRegistry().MustRegister(
"extension.healthcheck.useComponentStatus",
featuregate.StageAlpha,
featuregate.WithRegisterDescription("Switch to the shared healthcheck implementation powered by component status events"),
featuregate.WithRegisterFromVersion("v0.142.0"),
featuregate.WithRegisterToVersion("v0.147.0"),
featuregate.WithRegisterReferenceURL("https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/42256"),
)

// NewFactory creates a factory for HealthCheck extension.
func NewFactory() extension.Factory {
return extension.NewFactory(
Expand Down Expand Up @@ -63,7 +52,7 @@ func createDefaultConfig() component.Config {
func createExtension(ctx context.Context, set extension.Settings, cfg component.Config) (extension.Extension, error) {
config := cfg.(*Config)

if useComponentStatusGate.IsEnabled() {
if metadata.ExtensionHealthcheckUseComponentStatusFeatureGate.IsEnabled() {
// When feature gate is enabled, use v2 implementation directly.
// The feature gate controls behavior, not the presence of v2 config fields.
config.UseV2 = true
Expand Down
7 changes: 4 additions & 3 deletions extension/healthcheckextension/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"go.opentelemetry.io/collector/extension/extensiontest"
"go.opentelemetry.io/collector/featuregate"

"github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension/internal/metadata"
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/testutil"
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/healthcheck"
)
Expand Down Expand Up @@ -93,10 +94,10 @@ func TestLegacyExtensionPortAlreadyInUse(t *testing.T) {
}

func TestFactory_CreateV2Extension(t *testing.T) {
prev := useComponentStatusGate.IsEnabled()
require.NoError(t, featuregate.GlobalRegistry().Set(useComponentStatusGate.ID(), true))
prev := metadata.ExtensionHealthcheckUseComponentStatusFeatureGate.IsEnabled()
require.NoError(t, featuregate.GlobalRegistry().Set(metadata.ExtensionHealthcheckUseComponentStatusFeatureGate.ID(), true))
t.Cleanup(func() {
require.NoError(t, featuregate.GlobalRegistry().Set(useComponentStatusGate.ID(), prev))
require.NoError(t, featuregate.GlobalRegistry().Set(metadata.ExtensionHealthcheckUseComponentStatusFeatureGate.ID(), prev))
})

cfg := createDefaultConfig().(*Config)
Expand Down
7 changes: 4 additions & 3 deletions extension/healthcheckextension/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"go.opentelemetry.io/collector/extension/extensiontest"
"go.opentelemetry.io/collector/featuregate"

"github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension/internal/metadata"
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/testutil"
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/healthcheck"
)
Expand Down Expand Up @@ -95,10 +96,10 @@ func TestLegacyReadyNotReadyBehavior(t *testing.T) {
}

func TestV2ExtensionEnabledByGate(t *testing.T) {
prev := useComponentStatusGate.IsEnabled()
require.NoError(t, featuregate.GlobalRegistry().Set(useComponentStatusGate.ID(), true))
prev := metadata.ExtensionHealthcheckUseComponentStatusFeatureGate.IsEnabled()
require.NoError(t, featuregate.GlobalRegistry().Set(metadata.ExtensionHealthcheckUseComponentStatusFeatureGate.ID(), true))
t.Cleanup(func() {
require.NoError(t, featuregate.GlobalRegistry().Set(useComponentStatusGate.ID(), prev))
require.NoError(t, featuregate.GlobalRegistry().Set(metadata.ExtensionHealthcheckUseComponentStatusFeatureGate.ID(), prev))
})

transport := &http.Transport{
Expand Down

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

7 changes: 7 additions & 0 deletions extension/healthcheckextension/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ status:
active: [evan-bradley]
seeking_new: true

feature_gates:
- id: extension.healthcheck.useComponentStatus
description: >-
Switch to the shared healthcheck implementation powered by component status events
stage: alpha
from_version: "v0.142.0"
reference_url: https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/42256
tests:
config:
endpoint: localhost:0
Loading