Skip to content

Commit

Permalink
addressing comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zak-pawel committed Oct 14, 2024
1 parent e9e036c commit 22c8781
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion plugins/outputs/loki/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func uniqKeyFromTagList(ts []*telegraf.Tag) (k string) {
func newStream(ts []*telegraf.Tag) *Stream {
s := &Stream{
Logs: make([]Log, 0),
Labels: make(map[string]string),
Labels: make(map[string]string, len(ts)),
}

for _, t := range ts {
Expand Down
8 changes: 6 additions & 2 deletions plugins/outputs/mongodb/mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ import (
var sampleConfig string

func (s *MongoDB) getCollections(ctx context.Context) error {
s.collections = make(map[string]bson.M)
collections, err := s.client.Database(s.MetricDatabase).ListCollections(ctx, bson.M{})
if err != nil {
return fmt.Errorf("unable to execute ListCollections: %w", err)
}
s.collections = make(map[string]bson.M, collections.RemainingBatchLength())
for collections.Next(ctx) {
var collection bson.M
if err = collections.Decode(&collection); err != nil {
Expand Down Expand Up @@ -229,5 +229,9 @@ func (s *MongoDB) Write(metrics []telegraf.Metric) error {
}

func init() {
outputs.Add("mongodb", func() telegraf.Output { return &MongoDB{} })
outputs.Add("mongodb", func() telegraf.Output {
return &MongoDB{
collections: make(map[string]bson.M),
}
})
}

0 comments on commit 22c8781

Please sign in to comment.