diff --git a/v3/integrations/nrgrpc/nrgrpc_server.go b/v3/integrations/nrgrpc/nrgrpc_server.go index 057975707..a0fab1866 100644 --- a/v3/integrations/nrgrpc/nrgrpc_server.go +++ b/v3/integrations/nrgrpc/nrgrpc_server.go @@ -377,7 +377,9 @@ func StreamServerInterceptor(app *newrelic.Application, options ...HandlerOption return func(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { txn := startTransaction(ss.Context(), app, info.FullMethod) defer txn.End() - newrelic.GetSecurityAgentInterface().SendEvent("GRPC_INFO", info.IsClientStream, info.IsServerStream) + if newrelic.IsSecurityAgentPresent() { + newrelic.GetSecurityAgentInterface().SendEvent("GRPC_INFO", info.IsClientStream, info.IsServerStream) + } err := handler(srv, newWrappedServerStream(ss, txn)) reportInterceptorStatus(ss.Context(), txn, localHandlerMap, err) return err diff --git a/v3/newrelic/secure_agent.go b/v3/newrelic/secure_agent.go index 1b9114ace..5011a3e7d 100644 --- a/v3/newrelic/secure_agent.go +++ b/v3/newrelic/secure_agent.go @@ -43,9 +43,9 @@ type securityAgent interface { func (app *Application) RegisterSecurityAgent(s securityAgent) { if app != nil && app.app != nil && s != nil { secureAgent = s - } - if app.app.run != nil { - secureAgent.RefreshState(getLinkedMetaData(app.app)) + if app.app.run != nil { + secureAgent.RefreshState(getLinkedMetaData(app.app)) + } } }