Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
68aa1b2
Adding AcceptsRemoteConfig capability to opamp extension
bvigar Dec 18, 2025
e1e256e
Adding changelog and updating README
bvigar Dec 18, 2025
d6cd0b8
Merge branch 'main' into tv/collector_config_restart
bvigar Dec 18, 2025
f5dab6d
Updating capability to AcceptsRestartCommand and adding new feature gate
bvigar Dec 19, 2025
007d565
Merge branch 'tv/collector_config_restart' of github.com:bvigar/opent…
bvigar Dec 19, 2025
25d0e8a
Finished onCommand tests
bvigar Dec 22, 2025
747d634
Go mod tidy and some linter fixes
bvigar Dec 22, 2025
d9a5e3d
Updating readme
bvigar Dec 22, 2025
e0a8d98
Merge remote-tracking branch 'origin/main' into tv/collector_config_r…
bvigar Dec 22, 2025
6605a75
Removing unused var
bvigar Dec 22, 2025
0a36776
Updating signal logic to support windows
bvigar Dec 23, 2025
8acb015
gci lint fixes
bvigar Jan 5, 2026
ceeb5dc
gofmt lint fixes
bvigar Jan 5, 2026
10c35cd
Merge remote-tracking branch 'origin/main' into tv/collector_config_r…
bvigar Jan 5, 2026
eddbbe4
gogci fix again
bvigar Jan 5, 2026
06c95b8
Handling windows before signaling
bvigar Jan 5, 2026
f5d2d04
PR feedback
bvigar Jan 12, 2026
0879033
Merge remote-tracking branch 'origin/main' into tv/collector_config_r…
bvigar Jan 12, 2026
09acc3c
Go mod tidy
bvigar Jan 12, 2026
99e1e7b
README updates and refactoring how config is validated
bvigar Jan 12, 2026
aa2a2f6
Update extension/opampextension/README.md
bvigar Jan 14, 2026
ee97029
Update extension/opampextension/README.md
bvigar Jan 14, 2026
cf3723f
Update extension/opampextension/README.md
bvigar Jan 14, 2026
651ea08
Update extension/opampextension/opamp_agent.go
bvigar Jan 14, 2026
60d76bc
Update extension/opampextension/README.md
bvigar Jan 14, 2026
0d1b947
Moving feature gate enablement on windows check to config validation
bvigar Jan 15, 2026
3d9b7ed
Merge branch 'tv/collector_config_restart' of github.com:bvigar/opent…
bvigar Jan 15, 2026
ae3561e
Updating readme
bvigar Jan 15, 2026
280d4b2
PR feedback
bvigar Jan 16, 2026
3b9cf7a
Merge remote-tracking branch 'origin/main' into tv/collector_config_r…
bvigar Jan 16, 2026
b142e33
Merge remote-tracking branch 'origin/main' into tv/collector_config_r…
bvigar Jan 20, 2026
65fedc4
Merge remote-tracking branch 'origin/main' into tv/collector_config_r…
bvigar Jan 27, 2026
b7f5754
Apply suggestions from code review
evan-bradley Jan 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .chloggen/opamp-extension-accepts-remote-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# 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. receiver/filelog)
component: extension/opamp

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: This change adds support for the OpAMP AcceptsRemoteConfig capability. This capability has been implemented in the OpAMP supervisor, but this adds functionality to the extension which sends the SIGHUP signal to restart the collector which will reload the config on startup.

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [45056]

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

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# 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: [user]
1 change: 1 addition & 0 deletions extension/opampextension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ The following settings are optional for both transports:
- `reports_effective_config`: Whether to enable the OpAMP ReportsEffectiveConfig capability. Default is `true`.
- `reports_health`: Whether to enable the OpAMP ReportsHealth capability. Default is `true`.
- `reports_available_components`: Whether to enable the OpAMP ReportsAvailableComponents capability. Default is `true`.
- `accepts_remote_config`: Whether to enable the OpAMP AcceptsRemoteConfig capability. Default is `false`. The extension sends a `SIGHUP` signal to the collector to initiate a restart in order to reload the updated remote config.
- `agent_description`: Setting that modifies the agent description reported to the OpAMP server.
- `include_resource_attributes`: Copy the Collector's resource attributes into the set of non-identifying attributes in the agent description.
- `non_identifying_attributes`: A map of key value pairs that will be added to the [non-identifying attributes](https://github.com/open-telemetry/opamp-spec/blob/main/specification.md#agentdescriptionnon_identifying_attributes) reported to the OpAMP server. If an attribute collides with the default non-identifying attributes that are automatically added, the ones specified here take precedence.
Expand Down
6 changes: 5 additions & 1 deletion extension/opampextension/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ type Capabilities struct {
ReportsHealth bool `mapstructure:"reports_health"`
// ReportsAvailableComponents enables the OpAMP ReportsAvailableComponents Capability (default: true)
ReportsAvailableComponents bool `mapstructure:"reports_available_components"`
// AcceptsRemoteConfig enables the OpAMP AcceptsRemoteConfig Capability (default: false)
AcceptsRemoteConfig bool `mapstructure:"accepts_remote_config"`
}

func (caps Capabilities) toAgentCapabilities() protobufs.AgentCapabilities {
Expand All @@ -76,10 +78,12 @@ func (caps Capabilities) toAgentCapabilities() protobufs.AgentCapabilities {
if caps.ReportsHealth {
agentCapabilities |= protobufs.AgentCapabilities_AgentCapabilities_ReportsHealth
}

if caps.ReportsAvailableComponents {
agentCapabilities |= protobufs.AgentCapabilities_AgentCapabilities_ReportsAvailableComponents
}
if caps.AcceptsRemoteConfig {
agentCapabilities |= protobufs.AgentCapabilities_AgentCapabilities_AcceptsRemoteConfig
}

return agentCapabilities
}
Expand Down
1 change: 1 addition & 0 deletions extension/opampextension/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func createDefaultConfig() component.Config {
ReportsEffectiveConfig: true,
ReportsHealth: true,
ReportsAvailableComponents: true,
AcceptsRemoteConfig: false,
},
PPIDPollInterval: 5 * time.Second,
}
Expand Down
7 changes: 7 additions & 0 deletions extension/opampextension/opamp_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"sort"
"strings"
"sync"
"syscall"

"github.com/google/uuid"
"github.com/oklog/ulid/v2"
Expand Down Expand Up @@ -464,6 +465,12 @@ func (o *opampAgent) onMessage(_ context.Context, msg *types.MessageData) {
if msg.CustomMessage != nil {
o.customCapabilityRegistry.ProcessMessage(msg.CustomMessage)
}
if msg.RemoteConfig != nil {
o.logger.Info("received remote config — sending SIGHUP to reload")
if err := syscall.Kill(os.Getpid(), syscall.SIGHUP); err != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was discussed sending SIGUSR2 instead of SIGHUP here, but I noticed the collector doesn't currently handle the SIGUSR2 yet the way it currently handles SIGHUP, so that functionality can be added in a future iteration

o.logger.Error("sending sighup signal", zap.Error(err))
}
}
}

func (o *opampAgent) setHealth(ch *protobufs.ComponentHealth) {
Expand Down
55 changes: 55 additions & 0 deletions extension/opampextension/opamp_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
import (
"context"
"errors"
"go.uber.org/zap/zaptest"

Check failure on line 9 in extension/opampextension/opamp_agent_test.go

View workflow job for this annotation

GitHub Actions / lint-matrix (linux, extension)

File is not properly formatted (gci)
"os"
"os/signal"
"path/filepath"
"runtime"
"sync"
"syscall"
"testing"
"time"

Check failure on line 18 in extension/opampextension/opamp_agent_test.go

View workflow job for this annotation

GitHub Actions / lint-matrix (linux, extension)

File is not properly formatted (gofumpt)
"github.com/google/uuid"
"github.com/open-telemetry/opamp-go/client/types"
"github.com/open-telemetry/opamp-go/protobufs"
Expand Down Expand Up @@ -775,6 +778,58 @@
})
}

func TestOpAMPAgent_onMessage(t *testing.T) {
t.Run("happy path - SIGHUP signal", func(t *testing.T) {
agent := opampAgent{
logger: zaptest.NewLogger(t),
}

ctx, cancel := context.WithCancel(context.Background())

Check failure on line 787 in extension/opampextension/opamp_agent_test.go

View workflow job for this annotation

GitHub Actions / lint-matrix (linux, extension)

context.Background() could be replaced by t.Context() in TestOpAMPAgent_onMessage (usetesting)
t.Cleanup(cancel)

sighupReceived := make(chan bool, 1)
setupSignalHandler(t, ctx, func() {
sighupReceived <- true
})

agent.onMessage(ctx, &types.MessageData{
RemoteConfig: &protobufs.AgentRemoteConfig{},
})

select {
case <-sighupReceived:
// Success
case <-time.After(500 * time.Millisecond):
t.Error("Timed out waiting for SIGHUP reload")
}
})
}

func setupSignalHandler(t testing.TB, ctx context.Context, signalCallback func()) {

Check failure on line 808 in extension/opampextension/opamp_agent_test.go

View workflow job for this annotation

GitHub Actions / lint-matrix (linux, extension)

context-as-argument: context.Context should be the first parameter of a function (revive)
t.Helper()

sigChan := make(chan os.Signal, 1)
// Notify sigChan when SIGHUP is received
signal.Notify(sigChan, syscall.SIGHUP)

go func() {
t.Cleanup(func() {
signal.Stop(sigChan)
})

for {
select {
case sig := <-sigChan:
if sig == syscall.SIGHUP {
signalCallback()
}
case <-ctx.Done():
return
}
}
}()
}

type mockStatusAggregator struct {
statusChan chan *status.AggregateStatus
receivedEvents []eventSourcePair
Expand Down
Loading