Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register featuregate, otherwise does not work #16269

Merged
merged 1 commit into from
Nov 11, 2022

Conversation

bogdandrutu
Copy link
Member

No description provided.

@bogdandrutu bogdandrutu requested review from a team and dashpole November 11, 2022 16:44
@github-actions github-actions bot added the processor/spanmetrics Span Metrics processor label Nov 11, 2022
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
@bogdandrutu
Copy link
Member Author

bogdandrutu commented Nov 11, 2022

@Aneurysm9 @mx-psi @codeboten I expect that we enforce correct usages of the featuregate, see #8057. For me this is very worry that 3 leads (who are also on the core leads) missed this.

Update: may mean that the API is not well designed, but we need to investigate a bit this.

@djaglowski
Copy link
Member

may mean that the API is not well designed, but we need to investigate a bit this.

We almost want featuregate.GetRegistry().IsEnabled(id string) to panic if a gate is checked that is not registered, but there is risk that an unregistered gate is checked only in rare circumstances.

A minor improvement could have featuregate.GetRegistry().IsEnabled(id string) return an error as well as enabled.

There might be a solution that requires all feature gates to be resolved during collector startup. That way, we can panic/fail immediately without risk of rare circumstances. This probably means moving featuregate.GetRegistry() into an internal package and finding ways to provide controlled access at specific points in the code. For components, a factory option could act as the point of retrieval. Not sure about non-component packages in contrib though.

// component/processor.go
func WithFeatureGate(gateID string, callback(gateVal bool)) ProcessorFactoryOption {
	return processorFactoryOptionFunc(func(o *processorFactory) {
		enabled, err := featuregateinternal.GetRegistry().IsEnabled(gateID)
		if err != nil {
			o.unresolvedFeatureGateErr = err // fail gracefully later (or just panic now)
			return 
		}
		callback(enabled)
	})
}

// processor/myprocessor
type Config struct {
	myFeatureGate bool
}

func NewFactory() component.ProcessorFactory {
	cfg := createDefaultConfig
	return component.NewProcessorFactory(
		typeStr,
		cfg,
		component.WithTracesProcessor(createTracesProcessor, component.StabilityLevelStable),
		component.WithMetricsProcessor(createMetricsProcessor, component.StabilityLevelStable),
		component.WithLogsProcessor(createLogsProcessor, component.StabilityLevelStable)),
		component.WithFeatureGate("my.feature", func(gateVal bool) {
			cfg.myFeatureGate = gateVal
		})
}

@bogdandrutu
Copy link
Member Author

@djaglowski will post a PR with a proposal soon in core, I do have some ideas, and I like also what you suggested.

@bogdandrutu bogdandrutu merged commit 1750b99 into open-telemetry:main Nov 11, 2022
@bogdandrutu bogdandrutu deleted the fixunregistergate branch November 11, 2022 20:32
@codeboten
Copy link
Contributor

I'd missed that the unit test was not using the featuregate to turn on/off skipSanitizeLabel:

https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/8057/files#diff-5a336e1c1dce702d5f77df0fbfc22adde8470d3521537ab9c38d7e2abc7f0d80R755

This should probably be a requirement of adding featuregates, that they be used in the unit tests.

mdelapenya added a commit to mdelapenya/opentelemetry-collector-contrib that referenced this pull request Nov 15, 2022
* main:
  [chore] dependabot updates Tue Nov 15 00:17:56 UTC 2022 (open-telemetry#16300)
  [receiver/rabbitmq] Fix flaky integration test (open-telemetry#16240)
  [Docker Stats Receiver] Add @jamesmoessis as code owner (open-telemetry#16253)
  [receiver/mongodbatlas] Alerts poll mode check hostname and port (open-telemetry#16286)
  [chore] update jaeger dep (open-telemetry#16287)
  [pkg/stanza] Fix issue where specifying a non-existent storage extension caused panic during shutdown. (open-telemetry#16213)
  [pkg/ottl] Rename ottllogs to ottllog (open-telemetry#16242)
  Register featuregate, otherwise does not work (open-telemetry#16269)
  [receiver/elasticsearch]: add fielddata memory size metrics on index level (open-telemetry#14922)
  [chore] remove what looks to be debugging code from instanaexporter (open-telemetry#16258)
JaredTan95 pushed a commit to openinsight-proj/opentelemetry-collector-contrib that referenced this pull request Nov 21, 2022
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
shalper2 pushed a commit to shalper2/opentelemetry-collector-contrib that referenced this pull request Dec 6, 2022
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
@plantfansam plantfansam mentioned this pull request Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
processor/spanmetrics Span Metrics processor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants