diff --git a/enterprise/reporting/error_reporting.go b/enterprise/reporting/error_reporting.go index 06e1fa153d..90fef85519 100644 --- a/enterprise/reporting/error_reporting.go +++ b/enterprise/reporting/error_reporting.go @@ -288,7 +288,7 @@ func (edr *ErrorDetailReporter) Report(ctx context.Context, metrics []*types.PUR metric.StatusDetail.ErrorDetails.Code, metric.StatusDetail.ErrorDetails.Message, sampleResponse, - string(sampleEvent), + sampleEvent, metric.StatusDetail.EventName, ) if err != nil { diff --git a/enterprise/reporting/label_set_test.go b/enterprise/reporting/label_set_test.go index 6f2cbef4e2..ddd7658761 100644 --- a/enterprise/reporting/label_set_test.go +++ b/enterprise/reporting/label_set_test.go @@ -26,7 +26,7 @@ func createMetricObject(eventName, errorMessage string) types.PUReportedMetric { Count: 3, StatusCode: 0, SampleResponse: `{"some-sample-response-key": "some-sample-response-value"}`, - SampleEvent: []byte(`{"some-sample-event-key": "some-sample-event-value"}`), + SampleEvent: `{"some-sample-event-key": "some-sample-event-value"}`, EventName: eventName, EventType: "some-event-type", }, diff --git a/enterprise/reporting/reporting.go b/enterprise/reporting/reporting.go index 8497b5b87f..77b98fd42d 100644 --- a/enterprise/reporting/reporting.go +++ b/enterprise/reporting/reporting.go @@ -250,12 +250,12 @@ func (r *DefaultReporter) getReports(currentMs, aggregationIntervalMin int64, sy SELECT %s, MAX(reported_at), COALESCE( - (ARRAY_AGG(sample_response ORDER BY id DESC) FILTER (WHERE (sample_event != '{}'::jsonb AND sample_event IS NOT NULL) OR (sample_response IS NOT NULL AND sample_response != '')))[1], + (ARRAY_AGG(sample_response ORDER BY id DESC) FILTER (WHERE (sample_event != '{}' AND sample_event IS NOT NULL) OR (sample_response IS NOT NULL AND sample_response != '')))[1], '' ) AS sample_response, COALESCE( - (ARRAY_AGG(sample_event ORDER BY id DESC) FILTER (WHERE (sample_event != '{}'::jsonb AND sample_event IS NOT NULL) OR (sample_response IS NOT NULL AND sample_response != '')))[1], - '{}'::jsonb + (ARRAY_AGG(sample_event ORDER BY id DESC) FILTER (WHERE (sample_event != '{}' AND sample_event IS NOT NULL) OR (sample_response IS NOT NULL AND sample_response != '')))[1], + '{}' ) AS sample_event, SUM(count), SUM(violation_count) @@ -715,7 +715,7 @@ func (r *DefaultReporter) Report(ctx context.Context, metrics []*types.PUReporte metric.StatusDetail.Count, metric.StatusDetail.ViolationCount, metric.PUDetails.TerminalPU, metric.PUDetails.InitialPU, metric.StatusDetail.StatusCode, - sampleResponse, string(sampleEvent), + sampleResponse, sampleEvent, metric.StatusDetail.EventName, metric.StatusDetail.EventType, metric.StatusDetail.ErrorType, ) diff --git a/enterprise/reporting/reporting_test.go b/enterprise/reporting/reporting_test.go index 6a2f60469c..f92fa455cf 100644 --- a/enterprise/reporting/reporting_test.go +++ b/enterprise/reporting/reporting_test.go @@ -36,7 +36,7 @@ var _ = Describe("Reporting", func() { Count: 3, StatusCode: 0, SampleResponse: `{"some-sample-response-key": "some-sample-response-value"}`, - SampleEvent: []byte(`{"some-sample-event-key": "some-sample-event-value"}`), + SampleEvent: `{"some-sample-event-key": "some-sample-event-value"}`, EventName: "some-event-name", EventType: "some-event-type", }, @@ -61,7 +61,7 @@ var _ = Describe("Reporting", func() { Count: 3, StatusCode: 0, SampleResponse: "", - SampleEvent: []byte(`{}`), + SampleEvent: `{}`, EventName: "", EventType: "", }, @@ -118,7 +118,7 @@ func TestGetAggregatedReports(t *testing.T) { ViolationCount: 5, StatusCode: 200, SampleResponse: "", - SampleEvent: []byte(`{}`), + SampleEvent: `{}`, ErrorType: "", }, }, @@ -145,7 +145,7 @@ func TestGetAggregatedReports(t *testing.T) { ViolationCount: 10, StatusCode: 200, SampleResponse: "", - SampleEvent: []byte(`{}`), + SampleEvent: `{}`, ErrorType: "some-error-type", }, }, @@ -172,7 +172,7 @@ func TestGetAggregatedReports(t *testing.T) { ViolationCount: 10, StatusCode: 200, SampleResponse: "", - SampleEvent: []byte(`{}`), + SampleEvent: `{}`, ErrorType: "some-error-type", }, }, @@ -212,7 +212,7 @@ func TestGetAggregatedReports(t *testing.T) { ViolationCount: 5, StatusCode: 200, SampleResponse: "", - SampleEvent: []byte(`{}`), + SampleEvent: `{}`, ErrorType: "", }, }, @@ -242,7 +242,7 @@ func TestGetAggregatedReports(t *testing.T) { ViolationCount: 10, StatusCode: 200, SampleResponse: "", - SampleEvent: []byte(`{}`), + SampleEvent: `{}`, ErrorType: "some-error-type", }, }, @@ -272,7 +272,7 @@ func TestGetAggregatedReports(t *testing.T) { ViolationCount: 10, StatusCode: 200, SampleResponse: "", - SampleEvent: []byte(`{}`), + SampleEvent: `{}`, ErrorType: "some-error-type", }, }, @@ -313,7 +313,7 @@ func TestGetAggregatedReports(t *testing.T) { ViolationCount: 5, StatusCode: 200, SampleResponse: "", - SampleEvent: []byte(`{}`), + SampleEvent: `{}`, ErrorType: "", }, { @@ -322,7 +322,7 @@ func TestGetAggregatedReports(t *testing.T) { ViolationCount: 10, StatusCode: 200, SampleResponse: "", - SampleEvent: []byte(`{}`), + SampleEvent: `{}`, ErrorType: "some-error-type", }, }, @@ -352,7 +352,7 @@ func TestGetAggregatedReports(t *testing.T) { ViolationCount: 10, StatusCode: 200, SampleResponse: "", - SampleEvent: []byte(`{}`), + SampleEvent: `{}`, ErrorType: "some-error-type", }, }, @@ -390,7 +390,7 @@ func TestGetAggregatedReports(t *testing.T) { ViolationCount: 10, StatusCode: 200, SampleResponse: "", - SampleEvent: []byte(`{}`), + SampleEvent: `{}`, ErrorType: "another-error-type", }, } @@ -421,7 +421,7 @@ func TestGetAggregatedReports(t *testing.T) { ViolationCount: 5, StatusCode: 200, SampleResponse: "", - SampleEvent: []byte(`{}`), + SampleEvent: `{}`, ErrorType: "", }, { @@ -430,7 +430,7 @@ func TestGetAggregatedReports(t *testing.T) { ViolationCount: 10, StatusCode: 200, SampleResponse: "", - SampleEvent: []byte(`{}`), + SampleEvent: `{}`, ErrorType: "some-error-type", }, }, @@ -460,7 +460,7 @@ func TestGetAggregatedReports(t *testing.T) { ViolationCount: 10, StatusCode: 200, SampleResponse: "", - SampleEvent: []byte(`{}`), + SampleEvent: `{}`, ErrorType: "some-error-type", }, }, @@ -490,7 +490,7 @@ func TestGetAggregatedReports(t *testing.T) { ViolationCount: 10, StatusCode: 200, SampleResponse: "", - SampleEvent: []byte(`{}`), + SampleEvent: `{}`, ErrorType: "another-error-type", }, }, diff --git a/enterprise/reporting/util_test.go b/enterprise/reporting/util_test.go index 45ff7ced80..36e196d9b5 100644 --- a/enterprise/reporting/util_test.go +++ b/enterprise/reporting/util_test.go @@ -1,7 +1,6 @@ package reporting import ( - "encoding/json" "errors" "testing" "time" @@ -226,7 +225,7 @@ func TestGetAggregationBucket(t *testing.T) { } func TestGetSampleWithEventSamplingWithNilEventSampler(t *testing.T) { - inputSampleEvent := json.RawMessage(`{"event": "1"}`) + inputSampleEvent := `{"event": "1"}` inputSampleResponse := "response" metric := types.PUReportedMetric{ StatusDetail: &types.StatusDetail{ @@ -269,9 +268,9 @@ func TestFloorFactor(t *testing.T) { } func TestGetSampleWithEventSampling(t *testing.T) { - sampleEvent := json.RawMessage(`{"event": "2"}`) + sampleEvent := `{"event": "2"}` sampleResponse := "sample response" - emptySampleEvent := json.RawMessage(`{}`) + emptySampleEvent := `{}` emptySampleResponse := "" tests := []struct { @@ -284,19 +283,6 @@ func TestGetSampleWithEventSampling(t *testing.T) { shouldPut bool putError error }{ - { - name: "Nil sample event", - metric: types.PUReportedMetric{ - StatusDetail: &types.StatusDetail{ - SampleEvent: nil, - }, - }, - wantMetric: types.PUReportedMetric{ - StatusDetail: &types.StatusDetail{ - SampleEvent: nil, - }, - }, - }, { name: "Empty sample event", metric: types.PUReportedMetric{ diff --git a/enterprise/reporting/utils.go b/enterprise/reporting/utils.go index 3dc78d5325..7b5e78aba0 100644 --- a/enterprise/reporting/utils.go +++ b/enterprise/reporting/utils.go @@ -1,12 +1,12 @@ package reporting import ( - "encoding/json" "sort" "strings" "github.com/rudderlabs/rudder-go-kit/config" "github.com/rudderlabs/rudder-server/enterprise/reporting/event_sampler" + "github.com/rudderlabs/rudder-server/utils/misc" "github.com/rudderlabs/rudder-server/utils/types" ) @@ -45,7 +45,7 @@ func getAggregationBucketMinute(timeMs, intervalMs int64) (int64, int64) { return bucketStart, bucketEnd } -func getSampleWithEventSampling(metric types.PUReportedMetric, reportedAt int64, eventSampler event_sampler.EventSampler, eventSamplingEnabled bool, eventSamplingDuration int64) (sampleEvent json.RawMessage, sampleResponse string, err error) { +func getSampleWithEventSampling(metric types.PUReportedMetric, reportedAt int64, eventSampler event_sampler.EventSampler, eventSamplingEnabled bool, eventSamplingDuration int64) (sampleEvent, sampleResponse string, err error) { sampleEvent = metric.StatusDetail.SampleEvent sampleResponse = metric.StatusDetail.SampleResponse @@ -53,7 +53,7 @@ func getSampleWithEventSampling(metric types.PUReportedMetric, reportedAt int64, return sampleEvent, sampleResponse, nil } - isValidSample := (sampleEvent != nil && string(sampleEvent) != "{}") || sampleResponse != "" + isValidSample := (sampleEvent != misc.EmptyPayloadString || sampleResponse != "") if isValidSample { sampleEventBucket, _ := getAggregationBucketMinute(reportedAt, eventSamplingDuration) @@ -66,7 +66,7 @@ func getSampleWithEventSampling(metric types.PUReportedMetric, reportedAt int64, } if found { - sampleEvent = json.RawMessage(`{}`) + sampleEvent = misc.EmptyPayloadString sampleResponse = "" } else { err = eventSampler.Put(hash) @@ -80,7 +80,7 @@ func transformMetricForPII(metric types.PUReportedMetric, piiColumns []string) t for _, col := range piiColumns { switch col { case "sample_event": - metric.StatusDetail.SampleEvent = []byte(`{}`) + metric.StatusDetail.SampleEvent = misc.EmptyPayloadString case "sample_response": metric.StatusDetail.SampleResponse = "" case "event_name": diff --git a/processor/processor.go b/processor/processor.go index 9c1a785c47..5a4e4afce2 100644 --- a/processor/processor.go +++ b/processor/processor.go @@ -1147,12 +1147,12 @@ func (proc *Handle) getTransformerEvents( ) for _, message := range messages { - proc.updateMetricMaps(successCountMetadataMap, successCountMap, connectionDetailsMap, statusDetailsMap, userTransformedEvent, jobsdb.Succeeded.State, pu, func() json.RawMessage { + proc.updateMetricMaps(successCountMetadataMap, successCountMap, connectionDetailsMap, statusDetailsMap, userTransformedEvent, jobsdb.Succeeded.State, pu, func() string { if pu != types.TRACKINGPLAN_VALIDATOR { - return []byte(`{}`) + return misc.EmptyPayloadString } if proc.transientSources.Apply(commonMetaData.SourceID) { - return []byte(`{}`) + return misc.EmptyPayloadString } sampleEvent, err := jsonfast.Marshal(message) @@ -1160,7 +1160,7 @@ func (proc *Handle) getTransformerEvents( proc.logger.Errorf(`[Processor: getDestTransformerEvents] Failed to unmarshal first element in transformed events: %v`, err) sampleEvent = []byte(`{}`) } - return sampleEvent + return string(sampleEvent) }, nil) } @@ -1218,7 +1218,7 @@ func (proc *Handle) updateMetricMaps( statusDetailsMap map[string]map[string]*types.StatusDetail, event *transformer.TransformerResponse, status, stage string, - payload func() json.RawMessage, + payload func() string, eventsByMessageID map[string]types.SingularEventWithReceivedAt, ) { if !proc.isReportingEnabled() { @@ -1450,16 +1450,16 @@ func (proc *Handle) getTransformationMetrics( failedEvent, state, pu, - func() json.RawMessage { + func() string { if proc.transientSources.Apply(commonMetaData.SourceID) { - return []byte(`{}`) + return misc.EmptyPayloadString } sampleEvent, err := jsonfast.Marshal(message) if err != nil { proc.logger.Errorf(`[Processor: getTransformationMetrics] Failed to unmarshal first element in failed events: %v`, err) sampleEvent = []byte(`{}`) } - return sampleEvent + return string(sampleEvent) }, eventsByMessageID) } @@ -1613,7 +1613,7 @@ func getDiffMetrics( StatusDetail: &types.StatusDetail{ Status: types.DiffStatus, Count: diff, - SampleEvent: []byte(`{}`), + SampleEvent: misc.EmptyPayloadString, EventName: eventName, EventType: eventType, }, @@ -1938,14 +1938,14 @@ func (proc *Handle) processJobsForDest(partition string, subJobs subJob) (*preTr transformerEvent, jobsdb.Succeeded.State, types.GATEWAY, - func() json.RawMessage { + func() string { if sourceIsTransient { - return []byte(`{}`) + return misc.EmptyPayloadString } if payload := event.payloadFunc(); payload != nil { - return payload + return string(payload) } - return []byte("{}") + return misc.EmptyPayloadString }, nil, ) @@ -1988,7 +1988,7 @@ func (proc *Handle) processJobsForDest(partition string, subJobs subJob) (*preTr groupedEventsBySourceId[SourceIDT(sourceId)] = append(groupedEventsBySourceId[SourceIDT(sourceId)], shallowEventCopy) if proc.isReportingEnabled() { - proc.updateMetricMaps(inCountMetadataMap, outCountMap, connectionDetailsMap, destFilterStatusDetailMap, transformerEvent, jobsdb.Succeeded.State, types.DESTINATION_FILTER, func() json.RawMessage { return []byte(`{}`) }, nil) + proc.updateMetricMaps(inCountMetadataMap, outCountMap, connectionDetailsMap, destFilterStatusDetailMap, transformerEvent, jobsdb.Succeeded.State, types.DESTINATION_FILTER, func() string { return misc.EmptyPayloadString }, nil) } } @@ -2946,7 +2946,7 @@ func (proc *Handle) transformSrcDest( successCountMap := make(map[string]int64) for i := range response.Events { // Update metrics maps - proc.updateMetricMaps(nil, successCountMap, connectionDetailsMap, statusDetailsMap, &response.Events[i], jobsdb.Succeeded.State, types.DEST_TRANSFORMER, func() json.RawMessage { return []byte(`{}`) }, nil) + proc.updateMetricMaps(nil, successCountMap, connectionDetailsMap, statusDetailsMap, &response.Events[i], jobsdb.Succeeded.State, types.DEST_TRANSFORMER, func() string { return misc.EmptyPayloadString }, nil) } types.AssertSameKeys(connectionDetailsMap, statusDetailsMap) diff --git a/processor/processor_test.go b/processor/processor_test.go index 0989811f67..61437c4f5e 100644 --- a/processor/processor_test.go +++ b/processor/processor_test.go @@ -4983,7 +4983,7 @@ var _ = Describe("Static Function Tests", func() { Count: 5, StatusCode: 0, SampleResponse: "", - SampleEvent: []byte(`{}`), + SampleEvent: `{}`, }, }, { @@ -5005,7 +5005,7 @@ var _ = Describe("Static Function Tests", func() { Count: 7, StatusCode: 0, SampleResponse: "", - SampleEvent: []byte(`{}`), + SampleEvent: `{}`, }, }, } @@ -5101,7 +5101,7 @@ var _ = Describe("Static Function Tests", func() { countMap := make(map[string]int64) countMetadataMap := make(map[string]MetricMetadata) // update metric maps - proc.updateMetricMaps(countMetadataMap, countMap, connectionDetailsMap, statusDetailsMap, inputEvent, jobsdb.Succeeded.State, types.TRACKINGPLAN_VALIDATOR, func() json.RawMessage { return []byte(`{}`) }, nil) + proc.updateMetricMaps(countMetadataMap, countMap, connectionDetailsMap, statusDetailsMap, inputEvent, jobsdb.Succeeded.State, types.TRACKINGPLAN_VALIDATOR, func() string { return `{}` }, nil) Expect(len(countMetadataMap)).To(Equal(1)) Expect(len(countMap)).To(Equal(1)) diff --git a/router/batchrouter/handle.go b/router/batchrouter/handle.go index b54c214d6d..2c19e5becd 100644 --- a/router/batchrouter/handle.go +++ b/router/batchrouter/handle.go @@ -707,9 +707,9 @@ func (brt *Handle) updateJobStatus(batchJobs *BatchedJobs, isWarehouse bool, err } sd, ok := statusDetailsMap[key] if !ok { - sampleEvent := job.EventPayload + sampleEvent := string(job.EventPayload) if brt.transientSources.Apply(parameters.SourceID) { - sampleEvent = []byte(`{}`) + sampleEvent = misc.EmptyPayloadString } sd = &types.StatusDetail{ Status: jobState, diff --git a/router/batchrouter/handle_async.go b/router/batchrouter/handle_async.go index 67e4b075e5..fcdec897c7 100644 --- a/router/batchrouter/handle_async.go +++ b/router/batchrouter/handle_async.go @@ -639,7 +639,7 @@ func (brt *Handle) getReportMetrics(params getReportMetricsParams) []*utilTypes. Status: status.JobState, StatusCode: errorCode, SampleResponse: string(status.ErrorResponse), - SampleEvent: sampleEvent, + SampleEvent: string(sampleEvent), EventName: eventName, EventType: eventType, } diff --git a/router/handle.go b/router/handle.go index 93674cd371..de76d3d48a 100644 --- a/router/handle.go +++ b/router/handle.go @@ -376,7 +376,7 @@ func (rt *Handle) commitStatusList(workerJobStatuses *[]workerJobStatus) { Status: workerJobStatus.status.JobState, StatusCode: errorCode, SampleResponse: string(workerJobStatus.status.ErrorResponse), - SampleEvent: sampleEvent, + SampleEvent: string(sampleEvent), EventName: eventName, EventType: eventType, StatTags: workerJobStatus.statTags, diff --git a/router/router_test.go b/router/router_test.go index 68c4fcc88d..7c6a2fb1cb 100644 --- a/router/router_test.go +++ b/router/router_test.go @@ -1298,7 +1298,7 @@ var _ = Describe("router", func() { Expect(metrics).To(HaveLen(1)) Expect(metrics[0].StatusDetail.StatusCode).To(Equal(200)) Expect(metrics[0].StatusDetail.Status).To(Equal(jobsdb.Succeeded.State)) - Expect(metrics[0].StatusDetail.SampleEvent).To(Equal(toRetryJobsList[0].EventPayload)) + Expect(metrics[0].StatusDetail.SampleEvent).To(Equal(string(toRetryJobsList[0].EventPayload))) return nil }, ) @@ -1452,7 +1452,7 @@ var _ = Describe("router", func() { Expect(metrics).To(HaveLen(1)) Expect(metrics[0].StatusDetail.StatusCode).To(Equal(500)) Expect(metrics[0].StatusDetail.Status).To(Equal(jobsdb.Failed.State)) - Expect(metrics[0].StatusDetail.SampleEvent).To(Equal(json.RawMessage(gaPayload))) + Expect(metrics[0].StatusDetail.SampleEvent).To(Equal(gaPayload)) Expect(metrics[0].StatusDetail.SampleResponse).To(ContainSubstring(`"routerSubStage":"router_dest_transformer"`)) return nil diff --git a/sql/migrations/error_detail_reports/000003_alter_error_detail_reports_change_sample_event_column_to_text.up.sql b/sql/migrations/error_detail_reports/000003_alter_error_detail_reports_change_sample_event_column_to_text.up.sql new file mode 100644 index 0000000000..03cedd6995 --- /dev/null +++ b/sql/migrations/error_detail_reports/000003_alter_error_detail_reports_change_sample_event_column_to_text.up.sql @@ -0,0 +1,2 @@ +ALTER TABLE error_detail_reports +ALTER COLUMN sample_event TYPE TEXT; \ No newline at end of file diff --git a/sql/migrations/reports/000006_alter_reports_change_sample_event_column_to_text.up.sql b/sql/migrations/reports/000006_alter_reports_change_sample_event_column_to_text.up.sql new file mode 100644 index 0000000000..7e116093e5 --- /dev/null +++ b/sql/migrations/reports/000006_alter_reports_change_sample_event_column_to_text.up.sql @@ -0,0 +1,2 @@ +ALTER TABLE reports +ALTER COLUMN sample_event TYPE TEXT; \ No newline at end of file diff --git a/utils/misc/misc.go b/utils/misc/misc.go index 0c0677e114..6f22dbfec2 100644 --- a/utils/misc/misc.go +++ b/utils/misc/misc.go @@ -50,6 +50,8 @@ const ( NOTIMEZONEFORMATPARSE = "2006-01-02T15:04:05" ) +var EmptyPayloadString = `{}` + const ( RudderAsyncDestinationLogs = "rudder-async-destination-logs" RudderArchives = "rudder-archives" diff --git a/utils/types/reporting_types.go b/utils/types/reporting_types.go index 08b1a6bcc9..a4c98c0346 100644 --- a/utils/types/reporting_types.go +++ b/utils/types/reporting_types.go @@ -2,7 +2,6 @@ package types import ( "database/sql" - "encoding/json" "time" ) @@ -52,7 +51,7 @@ type StatusDetail struct { Count int64 `json:"count"` StatusCode int `json:"statusCode"` SampleResponse string `json:"sampleResponse"` - SampleEvent json.RawMessage `json:"sampleEvent"` + SampleEvent string `json:"sampleEvent"` EventName string `json:"eventName"` EventType string `json:"eventType"` ErrorType string `json:"errorType"` @@ -124,9 +123,9 @@ type EDErrorDetailsKey struct { type EDErrorDetails struct { EDErrorDetailsKey - SampleResponse string `json:"sampleResponse"` - SampleEvent json.RawMessage `json:"sampleEvent"` - ErrorCount int64 `json:"count"` + SampleResponse string `json:"sampleResponse"` + SampleEvent string `json:"sampleEvent"` + ErrorCount int64 `json:"count"` } type EDReportsDB struct { @@ -142,7 +141,7 @@ type EDReportsDB struct { type EDReportMapValue struct { Count int64 SampleResponse string - SampleEvent json.RawMessage + SampleEvent string } // EDMetric The structure in which the error detail data is being sent to reporting service diff --git a/utils/types/reporting_types_test.go b/utils/types/reporting_types_test.go index 01501902c5..d536f61a40 100644 --- a/utils/types/reporting_types_test.go +++ b/utils/types/reporting_types_test.go @@ -41,7 +41,7 @@ func TestMetricJSONMarshaling(t *testing.T) { "statusCode": 400, "violationCount": 12, "sampleResponse": "error email not valid", - "sampleEvent": {"key": "value-1"}, + "sampleEvent": "{\"key\": \"value-1\"}", "eventName": "SomeEventName1", "eventType": "SomeEventType" }, @@ -52,7 +52,7 @@ func TestMetricJSONMarshaling(t *testing.T) { "statusCode": 400, "violationCount": 12, "sampleResponse": "error email not valid", - "sampleEvent": {"key": "value-1"}, + "sampleEvent": "{\"key\": \"value-1\"}", "eventName": "SomeEventName2", "eventType": "SomeEventType" } @@ -96,7 +96,7 @@ func TestMetricJSONMarshaling(t *testing.T) { Count: 20, StatusCode: 400, SampleResponse: "error email not valid", - SampleEvent: json.RawMessage(`{"key": "value-1"}`), + SampleEvent: `{"key": "value-1"}`, EventName: "SomeEventName1", EventType: "SomeEventType", ErrorType: "this is errorType", @@ -116,7 +116,7 @@ func TestMetricJSONMarshaling(t *testing.T) { Count: 20, StatusCode: 400, SampleResponse: "error email not valid", - SampleEvent: json.RawMessage(`{"key": "value-1"}`), + SampleEvent: `{"key": "value-1"}`, EventName: "SomeEventName2", EventType: "SomeEventType", ErrorType: "this is errorType", diff --git a/warehouse/router/upload.go b/warehouse/router/upload.go index 9fd0284203..4f4858b0b0 100644 --- a/warehouse/router/upload.go +++ b/warehouse/router/upload.go @@ -408,7 +408,7 @@ func (job *UploadJob) run() (err error) { Status: jobsdb.Succeeded.State, StatusCode: 200, Count: rowCount, - SampleEvent: []byte("{}"), + SampleEvent: misc.EmptyPayloadString, }, } uploadStatusOpts.ReportingMetric = reportingMetric @@ -733,7 +733,7 @@ func (job *UploadJob) setUploadError(statusError error, state string) (string, e Status: reportingStatus, StatusCode: 400, // TODO: Change this to error specific code Count: failCount, - SampleEvent: []byte("{}"), + SampleEvent: misc.EmptyPayloadString, SampleResponse: string(serializedErr), }, }} @@ -755,7 +755,7 @@ func (job *UploadJob) setUploadError(statusError error, state string) (string, e Status: jobsdb.Succeeded.State, StatusCode: 200, // TODO: Change this to error specific code Count: outputCount, - SampleEvent: []byte("{}"), + SampleEvent: misc.EmptyPayloadString, SampleResponse: string(serializedErr), }, })