@@ -10,6 +10,7 @@ import (
1010 "log/slog"
1111 "sync"
1212
13+ "github.com/nginx/agent/v3/internal/logger"
1314 "github.com/nginx/agent/v3/internal/model"
1415
1516 pkg "github.com/nginx/agent/v3/pkg/config"
@@ -50,9 +51,14 @@ func addCommandAndFilePlugins(ctx context.Context, plugins []bus.Plugin, agentCo
5051 manifestLock * sync.RWMutex ,
5152) []bus.Plugin {
5253 if agentConfig .IsCommandGrpcClientConfigured () {
53- grpcConnection , err := grpc .NewGrpcConnection (ctx , agentConfig , agentConfig .Command )
54+ newCtx := context .WithValue (
55+ ctx ,
56+ logger .ServerTypeContextKey , slog .Any (logger .ServerTypeKey , model .Command ),
57+ )
58+
59+ grpcConnection , err := grpc .NewGrpcConnection (newCtx , agentConfig , agentConfig .Command )
5460 if err != nil {
55- slog .WarnContext (ctx , "Failed to create gRPC connection for command server" , "error" , err )
61+ slog .WarnContext (newCtx , "Failed to create gRPC connection for command server" , "error" , err )
5662 } else {
5763 commandPlugin := command .NewCommandPlugin (agentConfig , grpcConnection , model .Command )
5864 plugins = append (plugins , commandPlugin )
@@ -71,9 +77,14 @@ func addAuxiliaryCommandAndFilePlugins(ctx context.Context, plugins []bus.Plugin
7177 agentConfig * config.Config , manifestLock * sync.RWMutex ,
7278) []bus.Plugin {
7379 if agentConfig .IsAuxiliaryCommandGrpcClientConfigured () {
74- auxGRPCConnection , err := grpc .NewGrpcConnection (ctx , agentConfig , agentConfig .AuxiliaryCommand )
80+ newCtx := context .WithValue (
81+ ctx ,
82+ logger .ServerTypeContextKey , slog .Any (logger .ServerTypeKey , model .Auxiliary ),
83+ )
84+
85+ auxGRPCConnection , err := grpc .NewGrpcConnection (newCtx , agentConfig , agentConfig .AuxiliaryCommand )
7586 if err != nil {
76- slog .WarnContext (ctx , "Failed to create gRPC connection for auxiliary command server" , "error" , err )
87+ slog .WarnContext (newCtx , "Failed to create gRPC connection for auxiliary command server" , "error" , err )
7788 } else {
7889 auxCommandPlugin := command .NewCommandPlugin (agentConfig , auxGRPCConnection , model .Auxiliary )
7990 plugins = append (plugins , auxCommandPlugin )
0 commit comments