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

[processor/resourcedetection] support for periodically do detect action #34876

Open
JaredTan95 opened this issue Aug 27, 2024 · 2 comments
Open
Assignees
Labels
enhancement New feature or request processor/resourcedetection Resource detection processor Stale waiting for author

Comments

@JaredTan95
Copy link
Member

JaredTan95 commented Aug 27, 2024

Component(s)

processor/resourcedetection

Is your feature request related to a problem? Please describe.

When user is using consul detector and the resource attributes of consul changed, otel col will still using out-dated attributes unless restart otel col.

Describe the solution you'd like

  1. Add an optionnal configuration for detection to periodically invoke the detect action:

Attributes []string `mapstructure:"attributes"`

type Config struct {
	Attributes []string `mapstructure:"attributes"`
+	// interval of detect action
+	DetectInterval time.Duration `mapstructure:"detect_interval"`
}
  1. Update the start logical with TimeTicker to get resource attributes if DetectInterval great than 0ms
    rdp.resource, rdp.schemaURL, err = rdp.provider.Get(ctx, client)
	client, _ := rdp.httpClientSettings.ToClient(ctx, host, rdp.telemetrySettings)
	ctx = internal.ContextWithClient(ctx, client)
	var err error
+      //TODO: only create ticker if `DetectInterval` great than `0ms`
+	intervalTicker := time.NewTicker(rdp.detectInterval)
+	defer intervalTicker.Stop()
+
+	for range intervalTicker.C {
+		rdp.resource, rdp.schemaURL, err = rdp.provider.Get(ctx, client)
+		if err != nil {
+			rdp.telemetrySettings.Logger.Error("failed to retrieve resource from provider: %v", zap.Error(err))
+		}
+	}

Describe alternatives you've considered

No response

Additional context

No response

@JaredTan95 JaredTan95 added enhancement New feature or request needs triage New item requiring triage labels Aug 27, 2024
@JaredTan95 JaredTan95 self-assigned this Aug 27, 2024
@github-actions github-actions bot added the processor/resourcedetection Resource detection processor label Aug 27, 2024
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@JaredTan95 JaredTan95 added waiting for author and removed needs triage New item requiring triage labels Aug 27, 2024
JaredTan95 added a commit to JaredTan95/opentelemetry-collector-contrib that referenced this issue Sep 2, 2024
Signed-off-by: Jared Tan <jian.tan@daocloud.io>
Copy link
Contributor

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@github-actions github-actions bot added the Stale label Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request processor/resourcedetection Resource detection processor Stale waiting for author
Projects
None yet
Development

No branches or pull requests

1 participant