Skip to content

Commit 6f5d885

Browse files
committed
feat(outputs.nats): fix linter issues
1 parent 6b008f7 commit 6f5d885

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

plugins/outputs/nats/nats.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ type subMsgPair struct {
9494
metric telegraf.Metric
9595
}
9696
type metricSubjectTmplCtx struct {
97-
Name string
98-
//Field func() string
97+
Name string
9998
getTag func(string) string
10099
getField func() string
101100
}
@@ -152,7 +151,7 @@ func (n *NATS) Connect() error {
152151
n.Log.Infof("Reconnected to NATS at %s", nc.ConnectedUrl())
153152
}),
154153
nats.ClosedHandler(func(nc *nats.Conn) {
155-
n.Log.Error("Connection permanently closed.")
154+
n.Log.Errorf("Connection permanently closed: %v", nc.LastError())
156155
}),
157156
}
158157

@@ -393,7 +392,6 @@ func (n *NATS) Write(metrics []telegraf.Metric) error {
393392
metric: metric,
394393
})
395394
}
396-
397395
}
398396

399397
if len(n.SubjectLayout) > 0 && n.includeFieldInSubject {
@@ -424,7 +422,7 @@ func (n *NATS) Write(metrics []telegraf.Metric) error {
424422

425423
for i, pair := range subMsgPairList {
426424
if strings.Contains(pair.subject, "..") {
427-
n.Log.Errorf("double dots are not allowed in the subject: %s, most likely caused by a missing value in the template with_subject_layout", pair.subject)
425+
n.Log.Errorf("double dots are not allowed in the subject: %s, most likely a missing value in the template", pair.subject)
428426
continue
429427
}
430428

@@ -434,7 +432,7 @@ func (n *NATS) Write(metrics []telegraf.Metric) error {
434432
continue
435433
}
436434

437-
//n.Log.Debugf("Publishing on Subject: %s, Metrics: %s", pair.subject, string(buf))
435+
n.Log.Debugf("Publishing on Subject: %s, Metrics: %s", pair.subject, string(buf))
438436
if n.Jetstream != nil {
439437
if n.Jetstream.AsyncPublish {
440438
pafs[i], err = n.jetstreamClient.PublishAsync(pair.subject, buf, jetstream.WithExpectStream(n.Jetstream.Name))

plugins/outputs/nats/nats_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,6 @@ func TestWriteWithLayoutIntegration(t *testing.T) {
441441

442442
require.Len(t, msgs, tc.msgCount, "unexpected number of messages")
443443
}
444-
445444
}) // end of test case
446445
}
447446
}

0 commit comments

Comments
 (0)