Skip to content

Commit

Permalink
Remove Client and UserAgent from modeldecoder
Browse files Browse the repository at this point in the history
  • Loading branch information
simitt committed Aug 18, 2020
1 parent 5208c93 commit 760ecd8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 68 deletions.
10 changes: 0 additions & 10 deletions model/modeldecoder/rumv3/generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,6 @@ func (e *MetadataEvent) Decode(m *model.Metadata) error {
m.User.Email = e.User.Email
m.User.Name = e.User.Name

// Client
if m.Client.IP == nil {
m.Client.IP = e.User.IP
}

// UserAgent
if m.UserAgent == (model.UserAgent{}) {
m.UserAgent.Name = e.UserAgent.Name
m.UserAgent.Original = e.UserAgent.Original
}
return nil
}

Expand Down
24 changes: 3 additions & 21 deletions model/modeldecoder/rumv3/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package rumv3
import (
"encoding/json"
"fmt"
"net"

"github.com/elastic/apm-server/model/metadata/generated/schema"
"github.com/elastic/apm-server/validation"
Expand All @@ -46,10 +45,9 @@ type Language NameVersion

// Metadata contain event metadata
type Metadata struct {
Labels common.MapStr `json:"l"`
Service Service `json:"se"`
User User `json:"u"`
UserAgent UserAgent `json:"-"`
Labels common.MapStr `json:"l"`
Service Service `json:"se"`
User User `json:"u"`
}

//Runtime has an optional version and name
Expand All @@ -70,22 +68,6 @@ type User struct {
ID ParsedString `json:"id"`
Email string `json:"em"`
Name string `json:"un"`

// Client related fields
// IP holds the client's IP address.
IP net.IP `json:"ip"`
// TODO(axw) add client.geo fields, when we have
// GeoIP lookup implemented in the server.
}

type UserAgent struct {
// Original holds the original, full, User-Agent string.
Original string

// Name holds the user_agent.name value from the parsed User-Agent string.
// If Original is set, then this should typically not be set, as the full
// User-Agent string can be parsed by ingest node.
Name string
}

// helper types
Expand Down
15 changes: 2 additions & 13 deletions model/modeldecoder/v2/generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ func (e *MetadataEvent) Decode(m *model.Metadata) error {
if e.System.ConfiguredHostname == "" && e.System.DetectedHostname == "" {
m.System.DetectedHostname = e.System.HostnameDeprecated
}
if m.System.IP == nil {
m.System.IP = net.ParseIP(e.System.IP)
if ip := net.ParseIP(e.System.IP); ip != nil {
m.System.IP = ip
}
m.System.Kubernetes.Namespace = e.System.Kubernetes.Namespace
m.System.Kubernetes.NodeName = e.System.Kubernetes.Node.Name
Expand All @@ -87,17 +87,6 @@ func (e *MetadataEvent) Decode(m *model.Metadata) error {
m.User.Email = e.User.Email
m.User.Name = e.User.Name

// Client
if m.Client.IP == nil {
m.Client.IP = e.User.IP
}

// UserAgent
if m.UserAgent == (model.UserAgent{}) {
m.UserAgent.Name = e.UserAgent.Name
m.UserAgent.Original = e.UserAgent.Original
}

return nil
}

Expand Down
30 changes: 6 additions & 24 deletions model/modeldecoder/v2/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package v2
import (
"encoding/json"
"fmt"
"net"

"github.com/elastic/apm-server/model/metadata/generated/schema"
"github.com/elastic/apm-server/validation"
Expand All @@ -37,13 +36,12 @@ type MetadataEvent struct {

// Metadata contains event metadata
type Metadata struct {
Cloud Cloud `json:"cloud"`
Labels common.MapStr `json:"labels"`
Process Process `json:"process"`
Service Service `json:"service"`
System System `json:"system"`
User User `json:"user"`
UserAgent UserAgent `json:"-"`
Cloud Cloud `json:"cloud"`
Labels common.MapStr `json:"labels"`
Process Process `json:"process"`
Service Service `json:"service"`
System System `json:"system"`
User User `json:"user"`
}

//Agent has an optional version, name and an ephemeral id
Expand Down Expand Up @@ -148,22 +146,6 @@ type User struct {
ID ParsedString `json:"id"`
Email string `json:"email"`
Name string `json:"username"`

// Client related fields
// IP holds the client's IP address.
IP net.IP `json:"ip"`
// TODO(axw) add client.geo fields, when we have
// GeoIP lookup implemented in the server.
}

type UserAgent struct {
// Original holds the original, full, User-Agent string.
Original string `json:"original"`

// Name holds the user_agent.name value from the parsed User-Agent string.
// If Original is set, then this should typically not be set, as the full
// User-Agent string can be parsed by ingest node.
Name string `json:"name"`
}

// helper types
Expand Down

0 comments on commit 760ecd8

Please sign in to comment.