Skip to content

Commit

Permalink
switch data_stream to object notation
Browse files Browse the repository at this point in the history
  • Loading branch information
dmathieu committed Jul 20, 2023
1 parent 88a3977 commit b6e2dd5
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 20 deletions.
16 changes: 10 additions & 6 deletions model/internal/modeljson/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,10 @@ type Document struct {
Process *Process `json:"process,omitempty"`
Event *Event `json:"event,omitempty"`

Timestamp Time `json:"@timestamp"`
DataStreamType string `json:"data_stream.type,omitempty"`
DataStreamDataset string `json:"data_stream.dataset,omitempty"`
DataStreamNamespace string `json:"data_stream.namespace,omitempty"`
Message string `json:"message,omitempty"`
DocCount int64 `json:"_doc_count,omitempty"`
Timestamp Time `json:"@timestamp"`
DataStream *DataStream `json:"data_stream"`
Message string `json:"message,omitempty"`
DocCount int64 `json:"_doc_count,omitempty"`
}

type Time time.Time
Expand All @@ -88,3 +86,9 @@ func (t Time) MarshalFastJSON(w *fastjson.Writer) error {
func (t Time) isZero() bool {
return time.Time(t).IsZero()
}

type DataStream struct {
Type string `json:"type,omitempty"`
Dataset string `json:"dataset,omitempty"`
Namespace string `json:"namespace,omitempty"`
}
53 changes: 42 additions & 11 deletions model/internal/modeljson/marshal_fastjson.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions model/modelpb/apmevent.pb.json.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ func (e *APMEvent) MarshalFastJSON(w *fastjson.Writer) error {
}

if e.DataStream != nil {
doc.DataStreamType = e.DataStream.Type
doc.DataStreamDataset = e.DataStream.Dataset
doc.DataStreamNamespace = e.DataStream.Namespace
doc.DataStream.Type = e.DataStream.Type
doc.DataStream.Dataset = e.DataStream.Dataset
doc.DataStream.Namespace = e.DataStream.Namespace
}

var transaction modeljson.Transaction
Expand Down

0 comments on commit b6e2dd5

Please sign in to comment.