Skip to content

Commit

Permalink
[chore] Update opamp-go to v0.12.0 (#30878)
Browse files Browse the repository at this point in the history
**Description:**

Supersedes
#30872.
  • Loading branch information
evan-bradley authored Jan 30, 2024
1 parent 9dedd99 commit c7bd1ff
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 28 deletions.
12 changes: 6 additions & 6 deletions cmd/opampsupervisor/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ func newOpAMPServer(t *testing.T, connectingCallback onConnectingFuncFactory, ca
connectedChan := make(chan bool)
s := server.New(testLogger{t: t})
onConnectedFunc := callbacks.OnConnectedFunc
callbacks.OnConnectedFunc = func(conn types.Connection) {
callbacks.OnConnectedFunc = func(ctx context.Context, conn types.Connection) {
agentConn.Store(conn)
isAgentConnected.Store(true)
connectedChan <- true
if onConnectedFunc != nil {
onConnectedFunc(conn)
onConnectedFunc(ctx, conn)
}
}
onConnectionCloseFunc := callbacks.OnConnectionCloseFunc
Expand Down Expand Up @@ -175,7 +175,7 @@ func TestSupervisorStartsCollectorWithRemoteConfig(t *testing.T) {
t,
defaultConnectingHandler,
server.ConnectionCallbacksStruct{
OnMessageFunc: func(_ types.Connection, message *protobufs.AgentToServer) *protobufs.ServerToAgent {
OnMessageFunc: func(_ context.Context, _ types.Connection, message *protobufs.AgentToServer) *protobufs.ServerToAgent {
if message.EffectiveConfig != nil {
config := message.EffectiveConfig.ConfigMap.ConfigMap[""]
if config != nil {
Expand Down Expand Up @@ -235,7 +235,7 @@ func TestSupervisorRestartsCollectorAfterBadConfig(t *testing.T) {
t,
defaultConnectingHandler,
server.ConnectionCallbacksStruct{
OnMessageFunc: func(_ types.Connection, message *protobufs.AgentToServer) *protobufs.ServerToAgent {
OnMessageFunc: func(_ context.Context, _ types.Connection, message *protobufs.AgentToServer) *protobufs.ServerToAgent {
if message.Health != nil {
healthReport.Store(message.Health)
}
Expand Down Expand Up @@ -319,7 +319,7 @@ func TestSupervisorConfiguresCapabilities(t *testing.T) {
t,
defaultConnectingHandler,
server.ConnectionCallbacksStruct{
OnMessageFunc: func(_ types.Connection, message *protobufs.AgentToServer) *protobufs.ServerToAgent {
OnMessageFunc: func(_ context.Context, _ types.Connection, message *protobufs.AgentToServer) *protobufs.ServerToAgent {
capabilities.Store(message.Capabilities)

return &protobufs.ServerToAgent{}
Expand Down Expand Up @@ -372,7 +372,7 @@ func TestSupervisorBootstrapsCollector(t *testing.T) {
t,
defaultConnectingHandler,
server.ConnectionCallbacksStruct{
OnMessageFunc: func(_ types.Connection, message *protobufs.AgentToServer) *protobufs.ServerToAgent {
OnMessageFunc: func(_ context.Context, _ types.Connection, message *protobufs.AgentToServer) *protobufs.ServerToAgent {
if message.AgentDescription != nil {
agentDescription.Store(message.AgentDescription)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/opampsupervisor/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/knadh/koanf/providers/rawbytes v0.1.0
github.com/knadh/koanf/v2 v2.0.1
github.com/oklog/ulid/v2 v2.1.0
github.com/open-telemetry/opamp-go v0.11.0
github.com/open-telemetry/opamp-go v0.12.0
github.com/stretchr/testify v1.8.4
go.opentelemetry.io/collector/config/configtls v0.93.1-0.20240129215828-1ed45ec12569
go.opentelemetry.io/collector/semconv v0.93.1-0.20240129215828-1ed45ec12569
Expand Down
4 changes: 2 additions & 2 deletions cmd/opampsupervisor/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion cmd/opampsupervisor/supervisor/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package supervisor

import (
"context"
"net/http"

"github.com/open-telemetry/opamp-go/protobufs"
Expand All @@ -28,7 +29,7 @@ func newServerSettings(fs flattenedSettings) server.StartSettings {
return serverTypes.ConnectionResponse{
Accept: true,
ConnectionCallbacks: server.ConnectionCallbacksStruct{
OnMessageFunc: func(conn serverTypes.Connection, message *protobufs.AgentToServer) *protobufs.ServerToAgent {
OnMessageFunc: func(_ context.Context, conn serverTypes.Connection, message *protobufs.AgentToServer) *protobufs.ServerToAgent {
if fs.onMessageFunc != nil {
fs.onMessageFunc(conn, message)
}
Expand Down
16 changes: 8 additions & 8 deletions cmd/opampsupervisor/supervisor/supervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,37 +358,37 @@ func (s *Supervisor) startOpAMP() error {
TLSConfig: tlsConfig,
InstanceUid: s.instanceID.String(),
Callbacks: types.CallbacksStruct{
OnConnectFunc: func() {
OnConnectFunc: func(_ context.Context) {
s.logger.Debug("Connected to the server.")
},
OnConnectFailedFunc: func(err error) {
OnConnectFailedFunc: func(_ context.Context, err error) {
s.logger.Error("Failed to connect to the server", zap.Error(err))
},
OnErrorFunc: func(err *protobufs.ServerErrorResponse) {
OnErrorFunc: func(_ context.Context, err *protobufs.ServerErrorResponse) {
s.logger.Error("Server returned an error response", zap.String("message", err.ErrorMessage))
},
OnMessageFunc: s.onMessage,
OnOpampConnectionSettingsFunc: func(ctx context.Context, settings *protobufs.OpAMPConnectionSettings) error {
OnOpampConnectionSettingsFunc: func(_ context.Context, settings *protobufs.OpAMPConnectionSettings) error {
// TODO: https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/21043
s.logger.Debug("Received ConnectionSettings request")
return nil
},
OnOpampConnectionSettingsAcceptedFunc: func(settings *protobufs.OpAMPConnectionSettings) {
OnOpampConnectionSettingsAcceptedFunc: func(_ context.Context, settings *protobufs.OpAMPConnectionSettings) {
// TODO: https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/21043
s.logger.Debug("ConnectionSettings accepted")
},
OnCommandFunc: func(command *protobufs.ServerToAgentCommand) error {
OnCommandFunc: func(_ context.Context, command *protobufs.ServerToAgentCommand) error {
cmdType := command.GetType()
if *cmdType.Enum() == protobufs.CommandType_CommandType_Restart {
// TODO: https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/21077
s.logger.Debug("Received restart command")
}
return nil
},
SaveRemoteConfigStatusFunc: func(ctx context.Context, status *protobufs.RemoteConfigStatus) {
SaveRemoteConfigStatusFunc: func(_ context.Context, status *protobufs.RemoteConfigStatus) {
// TODO: https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/21079
},
GetEffectiveConfigFunc: func(ctx context.Context) (*protobufs.EffectiveConfig, error) {
GetEffectiveConfigFunc: func(_ context.Context) (*protobufs.EffectiveConfig, error) {
return s.createEffectiveConfigMsg(), nil
},
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/otelcontribcol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ require (
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/nginxinc/nginx-prometheus-exporter v0.11.0 // indirect
github.com/oklog/ulid/v2 v2.1.0 // indirect
github.com/open-telemetry/opamp-go v0.11.0 // indirect
github.com/open-telemetry/opamp-go v0.12.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding v0.93.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/extension/observer v0.93.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/awsutil v0.93.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions cmd/otelcontribcol/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion extension/opampextension/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.20
require (
github.com/google/uuid v1.6.0
github.com/oklog/ulid/v2 v2.1.0
github.com/open-telemetry/opamp-go v0.11.0
github.com/open-telemetry/opamp-go v0.12.0
github.com/stretchr/testify v1.8.4
go.opentelemetry.io/collector/component v0.93.1-0.20240129215828-1ed45ec12569
go.opentelemetry.io/collector/config/configopaque v0.93.1-0.20240129215828-1ed45ec12569
Expand Down
4 changes: 2 additions & 2 deletions extension/opampextension/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions extension/opampextension/opamp_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ func (o *opampAgent) Start(_ context.Context, _ component.Host) error {
OpAMPServerURL: o.cfg.Server.WS.Endpoint,
InstanceUid: o.instanceID.String(),
Callbacks: types.CallbacksStruct{
OnConnectFunc: func() {
OnConnectFunc: func(_ context.Context) {
o.logger.Debug("Connected to the OpAMP server")
},
OnConnectFailedFunc: func(err error) {
OnConnectFailedFunc: func(_ context.Context, err error) {
o.logger.Error("Failed to connect to the OpAMP server", zap.Error(err))
},
OnErrorFunc: func(err *protobufs.ServerErrorResponse) {
OnErrorFunc: func(_ context.Context, err *protobufs.ServerErrorResponse) {
o.logger.Error("OpAMP server returned an error response", zap.String("message", err.ErrorMessage))
},
GetEffectiveConfigFunc: func(ctx context.Context) (*protobufs.EffectiveConfig, error) {
GetEffectiveConfigFunc: func(_ context.Context) (*protobufs.EffectiveConfig, error) {
return o.composeEffectiveConfig(), nil
},
OnMessageFunc: o.onMessage,
Expand Down

0 comments on commit c7bd1ff

Please sign in to comment.