Skip to content

No supported way for extensions to run code on OS signals (SIGTERM / SIGINT / SIGHUP and others) #15732

Description

@iypetrov

Component(s)

otelcol

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

The collector uses its own OS signal handler and consumes SIGINT, SIGTERM, and SIGHUP internally, but offers no way for external components to run custom logic in response to those (or any other) OS signals. A component that wants to react to a signal must register its own handler - for example, deriving a context from the startCtx passed to Component.Start:

sigCtx, _ := signal.NotifyContext(startCtx, syscall.SIGINT, syscall.SIGTERM)

But because the collector already owns these signals and drives shutdown from them, this races the collector's own handling. On SIGTERM, the collector's shutdown path can cancel the component's context before the signal is observed, so the component sees a plain "context canceled" instead of the signal - and cannot reliably tell a genuine termination signal apart from an ordinary shutdown.

Describe the solution you'd like

A dedicated opt-in interface. Components declare interest in specific signals and provide the code to run when one is received, via an optional capability the collector checks for - similar to the existing extension capabilities pattern. The collector keeps ownership of the signal handler and dispatches to interested components.

Describe alternatives you've considered

An optional hook passed through component settings. A component can register a callback (via its creation settings) that the collector invokes when a signal is received, without changing the Component.Start signature.

Additional context

No response

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestneeds triageNew item requiring triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions