diff --git a/cmd/operator-opamp-bridge/agent/agent.go b/cmd/operator-opamp-bridge/agent/agent.go index 9282fd5444..c41d9461c1 100644 --- a/cmd/operator-opamp-bridge/agent/agent.go +++ b/cmd/operator-opamp-bridge/agent/agent.go @@ -174,17 +174,17 @@ func (agent *Agent) generateCollectorHealth(selectorLabels map[string]string, na } // onConnect is called when an agent is successfully connected to a server. -func (agent *Agent) onConnect() { +func (agent *Agent) onConnect(ctx context.Context) { agent.logger.V(3).Info("Connected to the server.") } // onConnectFailed is called when an agent was unable to connect to a server. -func (agent *Agent) onConnectFailed(err error) { +func (agent *Agent) onConnectFailed(ctx context.Context, err error) { agent.logger.Error(err, "failed to connect to the server") } // onError is called when an agent receives an error response from the server. -func (agent *Agent) onError(err *protobufs.ServerErrorResponse) { +func (agent *Agent) onError(ctx context.Context, err *protobufs.ServerErrorResponse) { agent.logger.Error(fmt.Errorf(err.GetErrorMessage()), "server returned an error response") } diff --git a/cmd/operator-opamp-bridge/agent/agent_test.go b/cmd/operator-opamp-bridge/agent/agent_test.go index 726d883e29..996e746ab2 100644 --- a/cmd/operator-opamp-bridge/agent/agent_test.go +++ b/cmd/operator-opamp-bridge/agent/agent_test.go @@ -121,6 +121,10 @@ type mockOpampClient struct { settings types.StartSettings } +func (m *mockOpampClient) RequestConnectionSettings(request *protobufs.ConnectionSettingsRequest) error { + return nil +} + func (m *mockOpampClient) Start(_ context.Context, settings types.StartSettings) error { m.settings = settings return nil diff --git a/cmd/operator-opamp-bridge/logger/logger.go b/cmd/operator-opamp-bridge/logger/logger.go index 0beb8cbea6..e07cef207d 100644 --- a/cmd/operator-opamp-bridge/logger/logger.go +++ b/cmd/operator-opamp-bridge/logger/logger.go @@ -15,6 +15,7 @@ package logger import ( + "context" "fmt" "github.com/go-logr/logr" @@ -31,10 +32,10 @@ func NewLogger(logger logr.Logger) *Logger { return &Logger{Logger: logger} } -func (l *Logger) Debugf(format string, v ...interface{}) { +func (l *Logger) Debugf(ctx context.Context, format string, v ...interface{}) { l.Logger.V(4).Info(fmt.Sprintf(format, v...)) } -func (l *Logger) Errorf(format string, v ...interface{}) { +func (l *Logger) Errorf(ctx context.Context, format string, v ...interface{}) { l.Logger.V(0).Error(nil, fmt.Sprintf(format, v...)) } diff --git a/go.mod b/go.mod index cb0c66d729..cee4165c13 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/mitchellh/mapstructure v1.5.0 github.com/oklog/run v1.1.0 github.com/oklog/ulid/v2 v2.1.0 - github.com/open-telemetry/opamp-go v0.10.0 + github.com/open-telemetry/opamp-go v0.12.0 github.com/openshift/api v0.0.0-20240124164020-e2ce40831f2e github.com/operator-framework/operator-lib v0.12.0 github.com/prometheus-operator/prometheus-operator v0.71.0 @@ -123,7 +123,7 @@ require ( github.com/googleapis/enterprise-certificate-proxy v0.3.1 // indirect github.com/googleapis/gax-go/v2 v2.12.0 // indirect github.com/gophercloud/gophercloud v1.7.0 // indirect - github.com/gorilla/websocket v1.5.0 // indirect + github.com/gorilla/websocket v1.5.1 // indirect github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect github.com/hashicorp/consul/api v1.25.1 // indirect diff --git a/go.sum b/go.sum index 7ff28e6813..71c5fba824 100644 --- a/go.sum +++ b/go.sum @@ -335,6 +335,8 @@ github.com/gophercloud/gophercloud v1.7.0 h1:fyJGKh0LBvIZKLvBWvQdIgkaV5yTM3Jh9EY github.com/gophercloud/gophercloud v1.7.0/go.mod h1:aAVqcocTSXh2vYFZ1JTvx4EQmfgzxRcNupUfxZbBNDM= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= +github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd h1:PpuIBO5P3e9hpqBD0O/HjhShYuM6XE0i/lbE6J94kww= github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd/go.mod h1:M5qHK+eWfAv8VR/265dIuEpL3fNfeC21tXXp9itM24A= github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rHAxPBD8KFhJpmcqms= @@ -516,6 +518,8 @@ github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/open-telemetry/opamp-go v0.10.0 h1:3PdhoKcKY1lPrfdXnsxeLlXluE+Xe1Uc/CpJ4I8uUJ0= github.com/open-telemetry/opamp-go v0.10.0/go.mod h1:Pfmm5EdWqZCG0dZAJjAinlra3yEpqK5StCblxpbEp6Q= +github.com/open-telemetry/opamp-go v0.12.0 h1:N97R8BY5FfaB9SzG5pURrOfXQk7MT9a4RD8oERlii5o= +github.com/open-telemetry/opamp-go v0.12.0/go.mod h1:bk3WZ4RjbVdzsHT3gaPZscUdGvoz9Bi2+AvG8/5X824= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM=