Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(processor): enhance reports to hold transformation and tracking plan metrics #3138

Merged
merged 24 commits into from
Apr 20, 2023

Conversation

Jayachand
Copy link
Contributor

@Jayachand Jayachand commented Mar 29, 2023

Description

Enhancing reports table to hold transformation and tracking plan information
New connectionDetails columns

  • TransformationId
  • TrannsformationVersionId
  • TrackingPlanId
  • TrackingPlanVersion

New statusDetails columns

  • ViolationCount
  • ErrorType

Notion Ticket

https://www.notion.so/rudderstacks/Send-violation-information-tp-id-version-violation-message-payload-c213bd096b1744189ce570d33026cdd2

https://www.notion.so/rudderstacks/Send-Transformation-Id-information-in-report-metrics-912964eb39144675b8905639e471c8a8?pvs=4

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

@codecov
Copy link

codecov bot commented Apr 3, 2023

Codecov Report

Patch coverage: 59.34% and project coverage change: +0.07 🎉

Comparison is base (1b4698e) 51.26% compared to head (cd9826c) 51.33%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3138      +/-   ##
==========================================
+ Coverage   51.26%   51.33%   +0.07%     
==========================================
  Files         311      311              
  Lines       52463    52637     +174     
==========================================
+ Hits        26893    27022     +129     
- Misses      23943    23979      +36     
- Partials     1627     1636       +9     
Impacted Files Coverage Δ
processor/trackingplan.go 53.38% <0.00%> (ø)
router/batchrouter/batchrouter.go 37.75% <0.00%> (ø)
enterprise/reporting/reporting.go 30.76% <27.27%> (+14.87%) ⬆️
processor/processor.go 86.84% <80.76%> (-0.30%) ⬇️
processor/transformer/transformer.go 73.54% <100.00%> (ø)
router/router.go 78.45% <100.00%> (ø)
utils/types/reporting_types.go 90.00% <100.00%> (+1.76%) ⬆️

... and 4 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@Jayachand Jayachand changed the title feat(reports): add tracking plan diff status reports feat(processor): add tracking plan diff status reports Apr 10, 2023
@Jayachand Jayachand marked this pull request as ready for review April 10, 2023 08:36
@Jayachand Jayachand changed the title feat(processor): add tracking plan diff status reports feat(processor): enhance reports to hold transformation and tracking plan metrics Apr 12, 2023
router/router.go Outdated Show resolved Hide resolved
Copy link
Member

@lvrach lvrach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with minor comments

Comment on lines 98 to 101
TransformationId string `json:"transformationId"`
TransformationVersionId string `json:"transformationVersionId"`
TrackingPlanId string `json:"trackingPlanId"`
TrackingPlanVersion int `json:"trackingPlanVersion"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[minor] to keep with the idiomatic naming of go Id -> ID:

Suggested change
TransformationId string `json:"transformationId"`
TransformationVersionId string `json:"transformationVersionId"`
TrackingPlanId string `json:"trackingPlanId"`
TrackingPlanVersion int `json:"trackingPlanVersion"`
TransformationID string `json:"transformationId"`
TransformationVersionID string `json:"transformationVersionId"`
TrackingPlanID string `json:"trackingPlanId"`
TrackingPlanVersion int `json:"trackingPlanVersion"`

I would propose the same for:

	SourceDefinitionId      string `json:"sourceDefinitionId"`
	DestinationDefinitionId string `string:"destinationDefinitionId"`
	SourceCategory          string `json:"sourceCategory"`
	```

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

converted Id to ID format for newly added properties.

@@ -99,7 +113,7 @@ type PUReportedMetric struct {
StatusDetail *StatusDetail
}

func CreateConnectionDetail(sid, did, strid, sjid, sjrid, sdid, ddid, sc string) *ConnectionDetails {
func CreateConnectionDetail(sid, did, strid, sjid, sjrid, sdid, ddid, sc, trid, trvid, tpid string, tpv int) *ConnectionDetails {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest against using this function and directly define: ConnectionDetails.

Having functions with more than 4 arguments is considered a bad practice. When dealing with many arguments is hard to understand which parameter has much with which arguments—making writing and reading harder. The struct, where you can provide the name of the fields is a better option.

processor/processor.go Outdated Show resolved Hide resolved
processor/processor.go Outdated Show resolved Hide resolved
enterprise/reporting/reporting.go Outdated Show resolved Hide resolved
Comment on lines 40 to 41
SUCCEEDED = "succeeded"
SUCCEEDED_WITHOUT_VIOLATIONS = "succeeded_without_violations"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the difference between succeeded and succeeded_without_violations?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In trackingplan stage, there will be no status SUCCEEDED unlike other stages.
SUCCEEDED is split into SUCCEEDED_WITHOUT_VIOLATIONS + SUCCEEDED_WITH_VIOLATIONS

Copy link
Contributor

@atzoum atzoum Apr 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we skip SUCCEEDED_WITHOUT_VIOLATIONS? If it succeeded, it succeeded. If there are violations, I would also skip the SUCCEEDED part and use something more straightforward, e.g. VIOLATIONS_FOUND, since what you are interested in is mostly that violations were found, not that we are ignoring these violations by considering the events as succeeded and letting them flow further in the pipeline. This, from what I understand is about to change in the future anyway, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All events sent to tracking plan stage can be categorized into 3 disjoint sets SUCCEEDED_WITHOUT_VIOLATIONS + SUCCEEDED_WITH_VIOLATIONS + ABORTED (due to violations). User is more interested in VIOLATIONS_FOUND (SUCCEEDED_WITH_VIOLATIONS+ ABORTED) and ABORTED.Also User might ask for only succeeded without violations. In view of this, 3 disjoint status data are sent to reporting, graphs shown in UI can be constructed based on user requirements

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Letting events succeed with violations is a configuration setting given to user. User might this setting always without dropping events.

utils/types/reporting_types.go Outdated Show resolved Hide resolved
processor/processor.go Outdated Show resolved Hide resolved
processor/processor.go Outdated Show resolved Hide resolved
messages = append(messages, eventsByMessageID[userTransformedEvent.Metadata.MessageID].SingularEvent)
}

for _, message := range messages {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Why are we repeating this for every message? The only thing the message affects is the sample payload. Would it be more efficient to increment counters in bulk and use a random sample?

@@ -1289,10 +1370,10 @@ func (proc *Handle) processJobsForDest(partition string, subJobs subJob, parsedE
inCountMap := make(map[string]int64)
inCountMetadataMap := make(map[string]MetricMetadata)
connectionDetailsMap := make(map[string]*types.ConnectionDetails)
statusDetailsMap := make(map[string]*types.StatusDetail)
statusDetailsMap := make(map[string]map[string]*types.StatusDetail)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What kind of key does this second map level holds? I find it hard to understand

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

second map holds this key:fmt.Sprintf("%s:%d:%s:%s:%s", status, event.StatusCode, eventName, eventType, violationErrorType)
For each violationType, one report needs to be sent

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also appear to be capturing another, aggregate report too for all types :/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, complexity is ever growing.
I think we should plan for complete refactor of reporting metrics

utils/types/reporting_types.go Outdated Show resolved Hide resolved
utils/types/reporting_types.go Outdated Show resolved Hide resolved
Comment on lines 40 to 41
SUCCEEDED = "succeeded"
SUCCEEDED_WITHOUT_VIOLATIONS = "succeeded_without_violations"
Copy link
Contributor

@atzoum atzoum Apr 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we skip SUCCEEDED_WITHOUT_VIOLATIONS? If it succeeded, it succeeded. If there are violations, I would also skip the SUCCEEDED part and use something more straightforward, e.g. VIOLATIONS_FOUND, since what you are interested in is mostly that violations were found, not that we are ignoring these violations by considering the events as succeeded and letting them flow further in the pipeline. This, from what I understand is about to change in the future anyway, no?

Copy link
Contributor

@atzoum atzoum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Collection of reporting metrics through metric maps was already a complicated affair. Unfortunately, now it appears to be even more fragile, complex and hard to follow, comprehend or reason about.
With the current design, I fear that every time there is a need to capture even more granular statistics, the complexity will grow exponentially.

processor/processor.go Show resolved Hide resolved
@@ -1289,10 +1370,10 @@ func (proc *Handle) processJobsForDest(partition string, subJobs subJob, parsedE
inCountMap := make(map[string]int64)
inCountMetadataMap := make(map[string]MetricMetadata)
connectionDetailsMap := make(map[string]*types.ConnectionDetails)
statusDetailsMap := make(map[string]*types.StatusDetail)
statusDetailsMap := make(map[string]map[string]*types.StatusDetail)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also appear to be capturing another, aggregate report too for all types :/

@Jayachand Jayachand merged commit 865ad6c into master Apr 20, 2023
16 checks passed
@atzoum atzoum deleted the feat.tpStateReportMetrics branch April 28, 2023 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants