Skip to content

Commit

Permalink
faro: include measurement type
Browse files Browse the repository at this point in the history
Signed-off-by: Robbie Lankford <[email protected]>
  • Loading branch information
rlankfo committed Oct 30, 2023
1 parent 81c4b05 commit 7600a68
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ Main (unreleased)
- Fixed a bug in River where passing a non-string key to an object (such as
`{}[true]`) would incorrectly report that a number type was expected instead. (@rfratto)

- Include Faro Measurement `type` field in `faro.receiver` Flow component and legacy `app_agent_receiver` integration. (@rlankfo)

### Enhancements

- The `loki.write` WAL now has snappy compression enabled by default. (@thepalbi)
Expand Down
2 changes: 2 additions & 0 deletions component/faro/receiver/internal/payload/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ type MeasurementContext map[string]string

// Measurement holds the data for user provided measurements
type Measurement struct {
Type string `json:"type,omitempty"`
Values map[string]float64 `json:"values,omitempty"`
Timestamp time.Time `json:"timestamp,omitempty"`
Trace TraceContext `json:"trace,omitempty"`
Expand All @@ -225,6 +226,7 @@ func (m Measurement) KeyVal() *KeyVal {

KeyValAdd(kv, "timestamp", m.Timestamp.String())
KeyValAdd(kv, "kind", "measurement")
KeyValAdd(kv, "type", m.Type)

keys := make([]string, 0, len(m.Values))
for k := range m.Values {
Expand Down
1 change: 1 addition & 0 deletions component/faro/receiver/internal/payload/payload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ func TestUnmarshalPayloadJSON(t *testing.T) {

require.Equal(t, []Measurement{
{
Type: "foobar",
Values: map[string]float64{
"ttfp": 20.12,
"ttfcp": 22.12,
Expand Down
2 changes: 1 addition & 1 deletion component/faro/receiver/testdata/payload.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,12 @@
],
"measurements": [
{
"type": "foobar",
"values": {
"ttfp": 20.12,
"ttfcp": 22.12,
"ttfb": 14
},
"type": "page load",
"timestamp": "2021-09-30T10:46:17.680Z",
"trace": {
"trace_id": "abcd",
Expand Down
1 change: 1 addition & 0 deletions pkg/integrations/v2/app_agent_receiver/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ type MeasurementContext map[string]string

// Measurement holds the data for user provided measurements
type Measurement struct {
Type string `json:"type,omitempty"`
Values map[string]float64 `json:"values,omitempty"`
Timestamp time.Time `json:"timestamp,omitempty"`
Trace TraceContext `json:"trace,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions pkg/integrations/v2/app_agent_receiver/payload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ func TestUnmarshalPayloadJSON(t *testing.T) {

require.Equal(t, []Measurement{
{
Type: "foobar",
Values: map[string]float64{
"ttfp": 20.12,
"ttfcp": 22.12,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,12 @@
],
"measurements": [
{
"type": "foobar",
"values": {
"ttfp": 20.12,
"ttfcp": 22.12,
"ttfb": 14
},
"type": "page load",
"timestamp": "2021-09-30T10:46:17.680Z",
"trace": {
"trace_id": "abcd",
Expand Down

0 comments on commit 7600a68

Please sign in to comment.