Skip to content

Handle nil pointer #1036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions src/core/metrics/metrics_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"github.com/nginx/agent/v2/src/core/config"

"github.com/gogo/protobuf/types"

log "github.com/sirupsen/logrus"
)

type Collector interface {
Expand Down Expand Up @@ -402,6 +404,11 @@ func GenerateMetricsReportBundle(entities []*StatsEntityWrapper) core.Payload {
reportMap := make(map[proto.MetricsReport_Type]*proto.MetricsReport, 0)

for _, entity := range entities {
if entity == nil || entity.Data == nil {
log.Debugf("Skipping nil entity in metrics generation")
continue
}

if _, ok := reportMap[entity.Type]; !ok {
reportMap[entity.Type] = &proto.MetricsReport{
Meta: &proto.Metadata{
Expand Down
Loading