Skip to content

Commit

Permalink
[extension] Move optional interfaces to extensioncapabilities (#11000)
Browse files Browse the repository at this point in the history
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

<!-- Issue number if applicable -->

Moves extension optional interfaces to a new module,
`extensioncapabilities`.

The intent is to be able to evolve these interfaces independently from
the core interfaces on core.

These are used by at most one component/project, so I think they are not
mature yet for 1.0

---------

Co-authored-by: Evan Bradley <11745660+evan-bradley@users.noreply.github.com>
  • Loading branch information
mx-psi and evan-bradley authored Sep 4, 2024
1 parent a26068b commit 46d0f73
Show file tree
Hide file tree
Showing 22 changed files with 297 additions and 44 deletions.
25 changes: 25 additions & 0 deletions .chloggen/mx-psi_extensioncapabilities-depr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: deprecation

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Deprecate `extension.ConfigWatcher`, `extension.PipelineWatcher` and `extension.Dependent` in favor of equivalents in the `extensioncapabilities` module.

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

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

# 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: [api]
25 changes: 25 additions & 0 deletions .chloggen/mx-psi_extensioncapabilities.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: new_component

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Create a new module for optional extension capabilities.

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

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

# 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: [api]
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ check-contrib:
-replace go.opentelemetry.io/collector/extension=$(CURDIR)/extension \
-replace go.opentelemetry.io/collector/extension/auth=$(CURDIR)/extension/auth \
-replace go.opentelemetry.io/collector/extension/experimental/storage=$(CURDIR)/extension/experimental/storage \
-replace go.opentelemetry.io/collector/extension/extensioncapabilities=$(CURDIR)/extension/extensioncapabilities \
-replace go.opentelemetry.io/collector/extension/memorylimiterextension=$(CURDIR)/extension/memorylimiterextension \
-replace go.opentelemetry.io/collector/extension/zpagesextension=$(CURDIR)/extension/zpagesextension \
-replace go.opentelemetry.io/collector/featuregate=$(CURDIR)/featuregate \
Expand Down
1 change: 1 addition & 0 deletions cmd/builder/internal/builder/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ var (
"/extension",
"/extension/auth",
"/extension/experimental/storage",
"/extension/extensioncapabilities",
"/extension/zpagesextension",
"/featuregate",
"/internal/globalgates",
Expand Down
1 change: 1 addition & 0 deletions cmd/builder/test/core.builder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ replaces:
- go.opentelemetry.io/collector/extension => ${WORKSPACE_DIR}/extension
- go.opentelemetry.io/collector/extension/auth => ${WORKSPACE_DIR}/extension/auth
- go.opentelemetry.io/collector/extension/experimental/storage => ${WORKSPACE_DIR}/extension/experimental/storage
- go.opentelemetry.io/collector/extension/extensioncapabilities => ${WORKSPACE_DIR}/extension/extensioncapabilities
- go.opentelemetry.io/collector/extension/zpagesextension => ${WORKSPACE_DIR}/extension/zpagesextension
- go.opentelemetry.io/collector/featuregate => ${WORKSPACE_DIR}/featuregate
- go.opentelemetry.io/collector/internal/globalgates => ${WORKSPACE_DIR}/internal/globalgates
Expand Down
1 change: 1 addition & 0 deletions cmd/otelcorecol/builder-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ replaces:
- go.opentelemetry.io/collector/extension => ../../extension
- go.opentelemetry.io/collector/extension/auth => ../../extension/auth
- go.opentelemetry.io/collector/extension/experimental/storage => ../../extension/experimental/storage
- go.opentelemetry.io/collector/extension/extensioncapabilities => ../../extension/extensioncapabilities
- go.opentelemetry.io/collector/extension/memorylimiterextension => ../../extension/memorylimiterextension
- go.opentelemetry.io/collector/extension/zpagesextension => ../../extension/zpagesextension
- go.opentelemetry.io/collector/featuregate => ../../featuregate
Expand Down
3 changes: 3 additions & 0 deletions cmd/otelcorecol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ require (
go.opentelemetry.io/collector/exporter/exporterprofiles v0.108.1 // indirect
go.opentelemetry.io/collector/extension/auth v0.108.1 // indirect
go.opentelemetry.io/collector/extension/experimental/storage v0.0.0-20240902085631-cd1f7623fe67 // indirect
go.opentelemetry.io/collector/extension/extensioncapabilities v0.108.1 // indirect
go.opentelemetry.io/collector/featuregate v1.14.1 // indirect
go.opentelemetry.io/collector/internal/globalgates v0.108.1 // indirect
go.opentelemetry.io/collector/pdata v1.14.1 // indirect
Expand Down Expand Up @@ -223,6 +224,8 @@ replace go.opentelemetry.io/collector/extension/auth => ../../extension/auth

replace go.opentelemetry.io/collector/extension/experimental/storage => ../../extension/experimental/storage

replace go.opentelemetry.io/collector/extension/extensioncapabilities => ../../extension/extensioncapabilities

replace go.opentelemetry.io/collector/extension/memorylimiterextension => ../../extension/memorylimiterextension

replace go.opentelemetry.io/collector/extension/zpagesextension => ../../extension/zpagesextension
Expand Down
44 changes: 9 additions & 35 deletions extension/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,22 @@ import (
"fmt"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/confmap"
"go.opentelemetry.io/collector/extension/internal"
)

// Extension is the interface for objects hosted by the OpenTelemetry Collector that
// don't participate directly on data pipelines but provide some functionality
// to the service, examples: health check endpoint, z-pages, etc.
type Extension = component.Component

// Dependent is an optional interface that can be implemented by extensions
// that depend on other extensions and must be started only after their dependencies.
// See https://github.com/open-telemetry/opentelemetry-collector/pull/8768 for examples.
type Dependent interface {
Extension
Dependencies() []component.ID
}
type Extension = internal.Extension

// PipelineWatcher is an extra interface for Extension hosted by the OpenTelemetry
// Collector that is to be implemented by extensions interested in changes to pipeline
// states. Typically this will be used by extensions that change their behavior if data is
// being ingested or not, e.g.: a k8s readiness probe.
type PipelineWatcher interface {
// Ready notifies the Extension that all pipelines were built and the
// receivers were started, i.e.: the service is ready to receive data
// (note that it may already have received data when this method is called).
Ready() error

// NotReady notifies the Extension that all receivers are about to be stopped,
// i.e.: pipeline receivers will not accept new data.
// This is sent before receivers are stopped, so the Extension can take any
// appropriate actions before that happens.
NotReady() error
}
// Deprecated: [v0.109.0] Use [extensioncapabilities.Dependent] instead.
type Dependent = internal.Dependent

// ConfigWatcher is an interface that should be implemented by an extension that
// wishes to be notified of the Collector's effective configuration.
type ConfigWatcher interface {
// NotifyConfig notifies the extension of the Collector's current effective configuration.
// The extension owns the `confmap.Conf`. Callers must ensure that it's safe for
// extensions to store the `conf` pointer and use it concurrently with any other
// instances of `conf`.
NotifyConfig(ctx context.Context, conf *confmap.Conf) error
}
// Deprecated: [v0.109.0] Use [extensioncapabilities.PipelineWatcher] instead.
type PipelineWatcher = internal.PipelineWatcher

// Deprecated: [v0.109.0] Use [extensioncapabilities.ConfigWatcher] instead.
type ConfigWatcher = internal.ConfigWatcher

// ModuleInfo describes the go module for each component.
type ModuleInfo struct {
Expand Down
1 change: 1 addition & 0 deletions extension/extensioncapabilities/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../Makefile.Common
43 changes: 43 additions & 0 deletions extension/extensioncapabilities/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
module go.opentelemetry.io/collector/extension/extensioncapabilities

go 1.22.0

require go.opentelemetry.io/collector/extension v0.108.0

require (
github.com/go-viper/mapstructure/v2 v2.1.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/knadh/koanf/maps v0.1.1 // indirect
github.com/knadh/koanf/providers/confmap v0.1.0 // indirect
github.com/knadh/koanf/v2 v2.1.1 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
go.opentelemetry.io/collector/component v0.108.1 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.108.1 // indirect
go.opentelemetry.io/collector/confmap v1.14.1 // indirect
go.opentelemetry.io/collector/pdata v1.14.1 // indirect
go.opentelemetry.io/otel v1.29.0 // indirect
go.opentelemetry.io/otel/metric v1.29.0 // indirect
go.opentelemetry.io/otel/trace v1.29.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 // indirect
google.golang.org/grpc v1.66.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace go.opentelemetry.io/collector/extension => ../

replace go.opentelemetry.io/collector/pdata => ../../pdata

replace go.opentelemetry.io/collector/confmap => ../../confmap

replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/configtelemetry

replace go.opentelemetry.io/collector/component => ../../component

replace go.opentelemetry.io/collector/component/componentstatus => ../../component/componentstatus
90 changes: 90 additions & 0 deletions extension/extensioncapabilities/go.sum

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

25 changes: 25 additions & 0 deletions extension/extensioncapabilities/interfaces.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

// Package extensioncapabilities provides interfaces that can be implemented by extensions
// to provide additional capabilities.
package extensioncapabilities // import "go.opentelemetry.io/collector/extension/extensioncapabilities"

import (
"go.opentelemetry.io/collector/extension/internal"
)

// Dependent is an optional interface that can be implemented by extensions
// that depend on other extensions and must be started only after their dependencies.
// See https://github.com/open-telemetry/opentelemetry-collector/pull/8768 for examples.
type Dependent = internal.Dependent

// PipelineWatcher is an extra interface for Extension hosted by the OpenTelemetry
// Collector that is to be implemented by extensions interested in changes to pipeline
// states. Typically this will be used by extensions that change their behavior if data is
// being ingested or not, e.g.: a k8s readiness probe.
type PipelineWatcher = internal.PipelineWatcher

// ConfigWatcher is an interface that should be implemented by an extension that
// wishes to be notified of the Collector's effective configuration.
type ConfigWatcher = internal.ConfigWatcher
Loading

0 comments on commit 46d0f73

Please sign in to comment.