Skip to content

Commit

Permalink
chore: revert update error table with new columns (#4380)
Browse files Browse the repository at this point in the history
- fix: count column in errors table
  • Loading branch information
ItsSudip authored and atzoum committed Feb 12, 2024
1 parent bb321c8 commit 8119fe3
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 150 deletions.
30 changes: 6 additions & 24 deletions enterprise/reporting/error_reporting.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ var ErrorDetailReportsColumns = []string{
"count",
"status_code",
"event_type",
"event_name",
"sample_event",
"sample_response",
"error_code",
"error_message",
}
Expand Down Expand Up @@ -191,6 +188,7 @@ func (edr *ErrorDetailReporter) Report(ctx context.Context, metrics []*types.PUR
"sourceId": metric.ConnectionDetails.SourceID,
"destinationId": metric.ConnectionDetails.DestinationID,
}).Count(int(metric.StatusDetail.Count))

_, err = stmt.Exec(
workspaceID,
edr.namespace,
Expand All @@ -205,9 +203,6 @@ func (edr *ErrorDetailReporter) Report(ctx context.Context, metrics []*types.PUR
metric.StatusDetail.Count,
metric.StatusDetail.StatusCode,
metric.StatusDetail.EventType,
metric.StatusDetail.EventName,
string(metric.StatusDetail.SampleEvent),
metric.StatusDetail.SampleResponse,
errDets.ErrorCode,
errDets.ErrorMessage,
)
Expand Down Expand Up @@ -403,9 +398,6 @@ func (edr *ErrorDetailReporter) getReports(ctx context.Context, currentMs int64,
"count",
"status_code",
"event_type",
"event_name",
"sample_event",
"sample_response",
"error_code",
"error_message",
"dest_type",
Expand Down Expand Up @@ -435,9 +427,6 @@ func (edr *ErrorDetailReporter) getReports(ctx context.Context, currentMs int64,
"count",
"status_code",
"event_type",
"event_name"
"sample_event",
"sample_response",
"error_code",
"error_message",
"dest_type",
Expand All @@ -459,9 +448,6 @@ func (edr *ErrorDetailReporter) getReports(ctx context.Context, currentMs int64,
&dbEdMetric.Count,
&dbEdMetric.EDErrorDetails.StatusCode,
&dbEdMetric.EDErrorDetails.EventType,
&dbEdMetric.EDErrorDetails.EventName,
&dbEdMetric.EDErrorDetails.SampleEvent,
&dbEdMetric.EDErrorDetails.SampleResponse,
&dbEdMetric.EDErrorDetails.ErrorCode,
&dbEdMetric.EDErrorDetails.ErrorMessage,
&dbEdMetric.EDConnectionDetails.DestType,
Expand Down Expand Up @@ -528,7 +514,6 @@ func (edr *ErrorDetailReporter) aggregate(reports []*types.EDReportsDB) []*types
ErrorCode: rep.ErrorCode,
ErrorMessage: rep.ErrorMessage,
EventType: rep.EventType,
EventName: rep.EventName,
}
reportsCountMap[errDet] += rep.Count
}
Expand All @@ -544,14 +529,11 @@ func (edr *ErrorDetailReporter) aggregate(reports []*types.EDReportsDB) []*types
})
errs := lo.MapToSlice(reportsCountMap, func(rep types.EDErrorDetails, count int64) types.EDErrorDetails {
return types.EDErrorDetails{
StatusCode: rep.StatusCode,
ErrorCode: rep.ErrorCode,
ErrorMessage: rep.ErrorMessage,
EventType: rep.EventType,
EventName: rep.EventName,
SampleEvent: reports[messageMap[rep.ErrorMessage]].SampleEvent,
SampleResponse: reports[messageMap[rep.ErrorMessage]].SampleResponse,
Count: count,
StatusCode: rep.StatusCode,
ErrorCode: rep.ErrorCode,
ErrorMessage: rep.ErrorMessage,
EventType: rep.EventType,
Count: count,
}
})
edrSchema.Errors = errs
Expand Down
140 changes: 30 additions & 110 deletions enterprise/reporting/reporting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ func TestAggregationLogic(t *testing.T) {
ReportMetadata: types.ReportMetadata{
ReportedAt: 124335445,
},
Count: 5,
Count: 10,
},
{
PU: "dest_transformer",
Expand All @@ -480,7 +480,7 @@ func TestAggregationLogic(t *testing.T) {
ReportMetadata: types.ReportMetadata{
ReportedAt: 124335445,
},
Count: 10,
Count: 5,
},
{
PU: "dest_transformer",
Expand All @@ -505,7 +505,7 @@ func TestAggregationLogic(t *testing.T) {
ReportMetadata: types.ReportMetadata{
ReportedAt: 124335445,
},
Count: 10,
Count: 15,
},
{
PU: "dest_transformer",
Expand All @@ -530,7 +530,7 @@ func TestAggregationLogic(t *testing.T) {
ReportMetadata: types.ReportMetadata{
ReportedAt: 124335446,
},
Count: 1,
Count: 20,
},
// error occurred at router level(assume this is batching enabled)
{
Expand All @@ -548,74 +548,15 @@ func TestAggregationLogic(t *testing.T) {
DestType: "DES_1",
},
EDErrorDetails: types.EDErrorDetails{
StatusCode: 500,
ErrorCode: "",
ErrorMessage: "Cannot read type property of undefined", // some error during batching
EventType: "track",
EventName: "Page View",
SampleResponse: "some response",
SampleEvent: "some sample event",
},
ReportMetadata: types.ReportMetadata{
ReportedAt: 124335446,
},
Count: 6,
},
{
PU: "router",
EDInstanceDetails: types.EDInstanceDetails{
WorkspaceID: "wsp1",
InstanceID: "instance-1",
Namespace: "nmspc",
},
EDConnectionDetails: types.EDConnectionDetails{
SourceID: "src-1",
SourceDefinitionId: "src-def-1",
DestinationDefinitionId: "des-def-1",
DestinationID: "des-1",
DestType: "DES_1",
},
EDErrorDetails: types.EDErrorDetails{
StatusCode: 500,
ErrorCode: "",
ErrorMessage: "Cannot read type property of undefined", // some error during batching
EventType: "track",
EventName: "Page View",
SampleResponse: "different response",
SampleEvent: "different sample event",
},
ReportMetadata: types.ReportMetadata{
ReportedAt: 124335446,
},
Count: 10,
},
{
PU: "router",
EDInstanceDetails: types.EDInstanceDetails{
WorkspaceID: "wsp1",
InstanceID: "instance-1",
Namespace: "nmspc",
},
EDConnectionDetails: types.EDConnectionDetails{
SourceID: "src-1",
SourceDefinitionId: "src-def-1",
DestinationDefinitionId: "des-def-1",
DestinationID: "des-1",
DestType: "DES_1",
},
EDErrorDetails: types.EDErrorDetails{
StatusCode: 401,
ErrorCode: "",
ErrorMessage: "Request had invalid authentication credentials Expected OAuth access token login cookie or other valid authentication credential See ",
EventType: "track",
EventName: "Page View",
SampleResponse: "some different response",
SampleEvent: "some different sample event",
StatusCode: 500,
ErrorCode: "",
ErrorMessage: "Cannot read type property of undefined", // some error during batching
EventType: "identify",
},
ReportMetadata: types.ReportMetadata{
ReportedAt: 124335446,
},
Count: 10,
Count: 15,
},
}
configSubscriber := newConfigSubscriber(logger.NOP)
Expand All @@ -642,24 +583,18 @@ func TestAggregationLogic(t *testing.T) {
},
Errors: []types.EDErrorDetails{
{
StatusCode: dbErrs[0].StatusCode,
ErrorCode: dbErrs[0].ErrorCode,
ErrorMessage: dbErrs[0].ErrorMessage,
EventType: dbErrs[0].EventType,
EventName: dbErrs[0].EventName,
Count: 5,
SampleResponse: dbErrs[0].SampleResponse,
SampleEvent: dbErrs[0].SampleEvent,
StatusCode: dbErrs[0].StatusCode,
ErrorCode: dbErrs[0].ErrorCode,
ErrorMessage: dbErrs[0].ErrorMessage,
EventType: dbErrs[0].EventType,
Count: 10,
},
{
StatusCode: dbErrs[1].StatusCode,
ErrorCode: dbErrs[1].ErrorCode,
ErrorMessage: dbErrs[1].ErrorMessage,
EventType: dbErrs[1].EventType,
EventName: dbErrs[1].EventName,
Count: 20,
SampleResponse: dbErrs[1].SampleResponse,
SampleEvent: dbErrs[1].SampleEvent,
StatusCode: dbErrs[1].StatusCode,
ErrorCode: dbErrs[1].ErrorCode,
ErrorMessage: dbErrs[1].ErrorMessage,
EventType: dbErrs[1].EventType,
Count: 20,
},
},
},
Expand All @@ -682,14 +617,11 @@ func TestAggregationLogic(t *testing.T) {
},
Errors: []types.EDErrorDetails{
{
StatusCode: dbErrs[3].StatusCode,
ErrorCode: dbErrs[3].ErrorCode,
ErrorMessage: dbErrs[3].ErrorMessage,
EventType: dbErrs[3].EventType,
EventName: dbErrs[3].EventName,
Count: 1,
SampleResponse: dbErrs[3].SampleResponse,
SampleEvent: dbErrs[3].SampleEvent,
StatusCode: dbErrs[3].StatusCode,
ErrorCode: dbErrs[3].ErrorCode,
ErrorMessage: dbErrs[3].ErrorMessage,
EventType: dbErrs[3].EventType,
Count: 20,
},
},
},
Expand All @@ -712,27 +644,15 @@ func TestAggregationLogic(t *testing.T) {
},
Errors: []types.EDErrorDetails{
{
StatusCode: dbErrs[4].StatusCode,
ErrorCode: dbErrs[4].ErrorCode,
ErrorMessage: dbErrs[4].ErrorMessage,
EventType: dbErrs[4].EventType,
EventName: dbErrs[4].EventName,
Count: 16,
SampleResponse: dbErrs[5].SampleResponse,
SampleEvent: dbErrs[5].SampleEvent,
},
{
StatusCode: dbErrs[6].StatusCode,
ErrorCode: dbErrs[6].ErrorCode,
ErrorMessage: dbErrs[6].ErrorMessage,
EventType: dbErrs[6].EventType,
EventName: dbErrs[6].EventName,
Count: 10,
SampleResponse: dbErrs[6].SampleResponse,
SampleEvent: dbErrs[6].SampleEvent,
StatusCode: dbErrs[4].StatusCode,
ErrorCode: dbErrs[4].ErrorCode,
ErrorMessage: dbErrs[4].ErrorMessage,
EventType: dbErrs[4].EventType,
Count: 15,
},
},
},
}

require.Equal(t, reportResults, reportingMetrics)
}

This file was deleted.

7 changes: 2 additions & 5 deletions utils/types/reporting_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,8 @@ type EDErrorDetails struct {
ErrorCode string `json:"errorCode"`
ErrorMessage string `json:"errorMessage"`
// TODO: need to check with team if this makes sense ?
EventType string `json:"eventType"`
EventName string `json:"eventName"`
Count int64 `json:"count"`
SampleResponse string `json:"sampleResponse"`
SampleEvent string `json:"sampleEvent"`
EventType string `json:"-"`
Count int64 `json:"count"`
}

type EDReportsDB struct {
Expand Down

0 comments on commit 8119fe3

Please sign in to comment.