Skip to content

Commit

Permalink
Fix fakeintake logs client which was returning an empty tags list (#2…
Browse files Browse the repository at this point in the history
  • Loading branch information
L3n41c authored Nov 24, 2023
1 parent 0937077 commit 8269452
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
Binary file modified test/fakeintake/aggregator/fixtures/log_bytes
Binary file not shown.
30 changes: 23 additions & 7 deletions test/fakeintake/aggregator/logAggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,36 @@ package aggregator
import (
"bytes"
"encoding/json"
"strings"
"time"

"github.com/DataDog/datadog-agent/test/fakeintake/api"
)

type tags []string

type Log struct {
collectedTime time.Time
Message string `json:"message"`
Status string `json:"status"`
Timestamp int `json:"timestamp"`
HostName string `json:"hostname"`
Service string `json:"service"`
Source string `json:"source"`
Tags []string `json:"tags"`
Message string `json:"message"`
Status string `json:"status"`
Timestamp int `json:"timestamp"`
HostName string `json:"hostname"`
Service string `json:"service"`
Source string `json:"ddsource"`
Tags tags `json:"ddtags"`
}

func (t *tags) UnmarshalJSON(b []byte) error {
var s string
if err := json.Unmarshal(b, &s); err != nil {
return err
}
*t = tags(strings.Split(s, ","))
return nil
}

func (t tags) MarshalJSON() ([]byte, error) {
return json.Marshal(strings.Join(t, ","))
}

func (l *Log) name() string {
Expand Down
Binary file modified test/fakeintake/server/fixture_test/log_bytes
Binary file not shown.
4 changes: 2 additions & 2 deletions test/fakeintake/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ func TestServer(t *testing.T) {
"hostname": "totoro",
"message": "Hello, can you hear me",
"service": "callme",
"source": "Adele",
"ddsource": "Adele",
"status": "Info",
"tags": []interface{}{"singer:adele"},
"ddtags": "singer:adele",
"timestamp": float64(0)}},
Encoding: "gzip",
},
Expand Down

0 comments on commit 8269452

Please sign in to comment.