Observation(event): adding op instead of type details paylaod (#4043)

* Observation(event): adding op instead of type details paylaod

* Observation(events): removing op check in details
This commit is contained in:
Sepehr authored and GitHub committed 2023-11-15 13:03:04 -08:00
1 parent 6ef015e1d1
commit 5c84a8861a
2 files changed
+47 -2

No files matched your search

+1 -1
View File
@@ -108,7 +108,7 @@ func (o *observation) ComposeFrom(events []*eventlogger.Event) (eventlogger.Even
payload[DetailsField] = []gated.EventPayloadDetails{}
}
payload[DetailsField] = append(payload[DetailsField].([]gated.EventPayloadDetails), gated.EventPayloadDetails{
Type: string(v.Type),
Type: string(g.Op),
CreatedAt: v.CreatedAt.String(),
Payload: g.Detail,
})
+46 -1
View File
@@ -11,6 +11,7 @@ import (
"github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/scopes"
"github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/workers"
"github.com/hashicorp/eventlogger"
"github.com/hashicorp/eventlogger/filters/gated"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/proto"
@@ -161,7 +162,43 @@ func Test_composeFromTelemetryFiltering(t *testing.T) {
wantErrContains string
wantFilteredRequest *Request
wantFilteredResponse *Response
wantDetailsPaylaod []gated.EventPayloadDetails
}{
{
name: "authenticate-op",
fromOp: Op("ldap.Authenticate"),
opts: []Option{
WithId("authenticate-op"),
WithRequestInfo(TestRequestInfo(t)),
WithNow(now),
WithDetails(
"user_id", "u_1234567890",
"auth_toke_start", "12345789",
"auth_toke_end", "12345789"),
},
wantObservation: &observation{
ID: "authenticate-op",
Version: errorVersion,
Op: Op("ldap.Authenticate"),
RequestInfo: TestRequestInfo(t),
Detail: map[string]any{
"user_id": "u_1234567890",
"auth_toke_start": "12345789",
"auth_toke_end": "12345789",
},
},
wantDetailsPaylaod: []gated.EventPayloadDetails{
{
CreatedAt: now.String(),
Type: "ldap.Authenticate",
Payload: map[string]interface{}{
"user_id": "u_1234567890",
"auth_toke_start": "12345789",
"auth_toke_end": "12345789",
},
},
},
},
{
name: "with-request-no-telemetry",
fromOp: Op("with-request-no-telemetry"),
@@ -517,7 +554,15 @@ func Test_composeFromTelemetryFiltering(t *testing.T) {
assert.True(ok)
assert.NotNil(pmsg)
assert.True(proto.Equal(tt.wantFilteredResponse.Details, pmsg.Details), "protos differ:\nexpected: %+v\nactual: %+v", tt.wantFilteredResponse.Details, pmsg.Details)
}
if tt.wantDetailsPaylaod != nil {
details, ok := payload["details"]
assert.True(ok)
assert.NotNil(details)
detailsPayload, ok := details.([]gated.EventPayloadDetails)
assert.True(ok)
assert.NotNil(detailsPayload)
assert.Equal(tt.wantDetailsPaylaod, detailsPayload)
}
})
}