Skip to content

Commit 8d46a55

Browse files
committed
fix(daemon): Verify log labels are correct format
1 parent ee9a5a4 commit 8d46a55

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

daemon/internal/newrelic/log_events.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ package newrelic
88
import (
99
"bytes"
1010
"encoding/json"
11-
"github.com/newrelic/newrelic-php-agent/daemon/internal/newrelic/log"
1211
"time"
12+
13+
"github.com/newrelic/newrelic-php-agent/daemon/internal/newrelic/log"
1314
)
1415

1516
// LogEvents is a wrapper over AnalyticsEvents created for additional type
@@ -46,6 +47,15 @@ func (events *LogEvents) SetLogForwardingLabels(data []byte) {
4647
if nil != err {
4748
log.Errorf("failed to unmarshal log labels json", err)
4849
}
50+
51+
// verify valid labels
52+
for idx := range events.LogForwardingLabels {
53+
if len(events.LogForwardingLabels[idx].LabelType) == 0 || len(events.LogForwardingLabels[idx].LabelValue) == 0 {
54+
log.Errorf("invalid log label: %s log value: %s", events.LogForwardingLabels[idx].LabelType, events.LogForwardingLabels[idx].LabelValue)
55+
events.LogForwardingLabels = nil
56+
break
57+
}
58+
}
4959
}
5060

5161
// FailedHarvest is a callback invoked by the processor when an

0 commit comments

Comments
 (0)