diff --git a/.chloggen/codeboten_add-featuregate-telemetry.yaml b/.chloggen/codeboten_add-featuregate-telemetry.yaml new file mode 100755 index 00000000000..fb8696f2c91 --- /dev/null +++ b/.chloggen/codeboten_add-featuregate-telemetry.yaml @@ -0,0 +1,16 @@ +# 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. otlpreceiver) +component: service + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: "Add feature gate `telemetry.useOtelWithSDKConfigurationForInternalTelemetry` that will add support for configuring the export of internal telemetry to additional destinations in future releases" + +# One or more tracking issues or pull requests related to the change +issues: [7641] + +# (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: diff --git a/internal/obsreportconfig/obsreportconfig.go b/internal/obsreportconfig/obsreportconfig.go index 21501d6e8d3..ab0d101a7ce 100644 --- a/internal/obsreportconfig/obsreportconfig.go +++ b/internal/obsreportconfig/obsreportconfig.go @@ -39,6 +39,14 @@ var DisableHighCardinalityMetricsfeatureGate = featuregate.GlobalRegistry().Must featuregate.WithRegisterDescription("controls whether the collector should enable potentially high"+ "cardinality metrics. The gate will be removed when the collector allows for view configuration.")) +// UseOtelWithSDKConfigurationForInternalTelemetryFeatureGate is the feature gate that controls whether the collector +// supports configuring the OpenTelemetry SDK via configuration +var UseOtelWithSDKConfigurationForInternalTelemetryFeatureGate = featuregate.GlobalRegistry().MustRegister( + "telemetry.useOtelWithSDKConfigurationForInternalTelemetry", + featuregate.StageAlpha, + featuregate.WithRegisterDescription("controls whether the collector supports extended OpenTelemetry"+ + "configuration for internal telemetry")) + // AllViews returns all the OpenCensus views requires by obsreport package. func AllViews(level configtelemetry.Level) []*view.View { if level == configtelemetry.LevelNone { diff --git a/service/service.go b/service/service.go index d28bba03a06..c3a2e6b4e60 100644 --- a/service/service.go +++ b/service/service.go @@ -87,6 +87,7 @@ func New(ctx context.Context, set Settings, cfg Config) (*Service, error) { useOtel = *set.useOtel } disableHighCard := obsreportconfig.DisableHighCardinalityMetricsfeatureGate.IsEnabled() + extendedConfig := obsreportconfig.UseOtelWithSDKConfigurationForInternalTelemetryFeatureGate.IsEnabled() srv := &Service{ buildInfo: set.BuildInfo, host: &serviceHost{ @@ -98,7 +99,7 @@ func New(ctx context.Context, set Settings, cfg Config) (*Service, error) { buildInfo: set.BuildInfo, asyncErrorChannel: set.AsyncErrorChannel, }, - telemetryInitializer: newColTelemetry(useOtel, disableHighCard), + telemetryInitializer: newColTelemetry(useOtel, disableHighCard, extendedConfig), } var err error srv.telemetry, err = telemetry.New(ctx, telemetry.Settings{ZapOptions: set.LoggingOptions}, cfg.Telemetry) diff --git a/service/telemetry.go b/service/telemetry.go index 98149ea0ff1..587e1d6341b 100644 --- a/service/telemetry.go +++ b/service/telemetry.go @@ -90,13 +90,15 @@ type telemetryInitializer struct { useOtel bool disableHighCardinality bool + extendedConfig bool } -func newColTelemetry(useOtel bool, disableHighCardinality bool) *telemetryInitializer { +func newColTelemetry(useOtel bool, disableHighCardinality bool, extendedConfig bool) *telemetryInitializer { return &telemetryInitializer{ mp: noop.NewMeterProvider(), useOtel: useOtel, disableHighCardinality: disableHighCardinality, + extendedConfig: extendedConfig, } } diff --git a/service/telemetry/config.go b/service/telemetry/config.go index b508e4727fc..1a8d2eacca4 100644 --- a/service/telemetry/config.go +++ b/service/telemetry/config.go @@ -104,6 +104,19 @@ type LogsSamplingConfig struct { Thereafter int `mapstructure:"thereafter"` } +// MetricReader exposes configuration of metric readers to end users. +// TODO: replace this temporary struct w/ auto-generated struct from jsonschema +// https://github.com/open-telemetry/opentelemetry-configuration/tree/main/schema +// +// Experimental: *NOTE* this structure is subject to change or removal in the future. +type MetricReader struct { + // Args corresponds to the JSON schema field "args". + Args any `mapstructure:"args"` + + // Type corresponds to the JSON schema field "type". + Type string `mapstructure:"type"` +} + // MetricsConfig exposes the common Telemetry configuration for one component. // Experimental: *NOTE* this structure is subject to change or removal in the future. type MetricsConfig struct { @@ -116,6 +129,10 @@ type MetricsConfig struct { // Address is the [address]:port that metrics exposition should be bound to. Address string `mapstructure:"address"` + + // Readers allow configuration of metric readers to emit metrics to + // any number of supported backends. + Readers []MetricReader `mapstructure:"metric_readers"` } // TracesConfig exposes the common Telemetry configuration for collector's internal spans. diff --git a/service/telemetry_test.go b/service/telemetry_test.go index e84313993df..12126b28217 100644 --- a/service/telemetry_test.go +++ b/service/telemetry_test.go @@ -113,6 +113,7 @@ func TestTelemetryInit(t *testing.T) { useOtel bool disableHighCard bool expectedMetrics map[string]metricValue + extendedConfig bool }{ { name: "UseOpenCensusForInternalMetrics", @@ -198,7 +199,7 @@ func TestTelemetryInit(t *testing.T) { }, } { t.Run(tc.name, func(t *testing.T) { - tel := newColTelemetry(tc.useOtel, tc.disableHighCard) + tel := newColTelemetry(tc.useOtel, tc.disableHighCard, tc.extendedConfig) buildInfo := component.NewDefaultBuildInfo() cfg := telemetry.Config{ Resource: map[string]*string{