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: add context propagator and use it to enrich metrics with flow metadata #2493

Merged
merged 10 commits into from
Jan 29, 2025

Conversation

iamKunalGupta
Copy link
Member

@iamKunalGupta iamKunalGupta commented Jan 28, 2025

The context is propagated as temporal headers:
image

Metrics automatically have the desired attributes:
image

@iamKunalGupta iamKunalGupta linked an issue Jan 28, 2025 that may be closed by this pull request
@iamKunalGupta iamKunalGupta force-pushed the feat/add-flow-metadata-ctx branch from c853a75 to 91652be Compare January 28, 2025 01:26
flow/shared/context.go Outdated Show resolved Hide resolved
func (a *FlowableActivity) GetFlowMetadata(ctx context.Context, flowName string, sourceName string,
destinationName string) (*shared.FlowMetadata, error) {
logger := log.With(activity.GetLogger(ctx), slog.String(string(shared.FlowNameKey), flowName))
peerTypes, err := connectors.LoadPeerTypes(ctx, a.CatalogPool, []string{sourceName, destinationName})
Copy link
Contributor

Choose a reason for hiding this comment

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

do we want to cache this somewhere? not sure how often this will hit catalog with the metrics we will add

Copy link
Contributor

@serprex serprex Jan 28, 2025

Choose a reason for hiding this comment

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

This function is meant to be run once by workflows

Copy link
Contributor

Choose a reason for hiding this comment

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

missed the shared function my bad
could be a LocalActivity?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, was thinking the same

@iamKunalGupta iamKunalGupta force-pushed the feat/add-flow-metadata-ctx branch from 91652be to 2598e7b Compare January 29, 2025 12:14
@iamKunalGupta iamKunalGupta force-pushed the feat/add-flow-metadata-ctx branch from b01f3e4 to 64c7ee8 Compare January 29, 2025 16:35
@iamKunalGupta iamKunalGupta marked this pull request as ready for review January 29, 2025 16:43
@iamKunalGupta iamKunalGupta requested review from serprex, heavycrystal and a team January 29, 2025 16:43
@@ -568,3 +574,15 @@ func CDCFlowWorkflow(
}
}
}

func GetFlowMetadataContext(ctx workflow.Context, flowJobName string, sourceName string, destinationName string) (workflow.Context, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

there's another utility method around in these workflow files (GetSideEffect?), these could be in a util.go

flow/workflows/cdc_flow.go Outdated Show resolved Hide resolved
@iamKunalGupta iamKunalGupta enabled auto-merge (squash) January 29, 2025 17:40
@iamKunalGupta iamKunalGupta merged commit 3664789 into main Jan 29, 2025
15 checks passed
@iamKunalGupta iamKunalGupta deleted the feat/add-flow-metadata-ctx branch January 29, 2025 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add sourcePeerType information to all metrics emitted
3 participants