Skip to content

feat: Add CallerType for request context propagation#7564

Merged
fimanishi merged 2 commits intocadence-workflow:masterfrom
fimanishi:propagate-caller-metadata
Dec 30, 2025
Merged

feat: Add CallerType for request context propagation#7564
fimanishi merged 2 commits intocadence-workflow:masterfrom
fimanishi:propagate-caller-metadata

Conversation

@fimanishi
Copy link
Member

@fimanishi fimanishi commented Dec 24, 2025

What changed?
Added CallerType infrastructure for client identification:

  • Added CallerType enum with CLI, SDK, UI, Internal, and Unknown variants in common/types
  • Added context helpers WithCallerType() and GetCallerType() for propagating caller type through request context
  • Added ParseCallerType() for string-to-enum conversion and String() for enum-to-string conversion
  • Added CadenceRequestsWithoutCallerType metric for tracking adoption

Why?
Enable client-aware operations:
Cadence currently has no visibility into which client type (CLI, SDK, UI, Internal) is making requests. This enables future capabilities like per-client-type rate limiting, client-specific features, and improved observability.

How did you test it?
Unit tests.

Potential risks
None - this change only adds type definitions and helpers without any usage. No behavior changes.

Release notes
N/A - internal infrastructure only

Documentation Changes
N/A

@fimanishi fimanishi force-pushed the propagate-caller-metadata branch from 569084a to 00b7bbb Compare December 24, 2025 18:37
Signed-off-by: fimanishi <fimanishi@gmail.com>
@fimanishi fimanishi force-pushed the propagate-caller-metadata branch from 00b7bbb to 864ef9a Compare December 29, 2025 20:47
@fimanishi fimanishi changed the title feat: Extract and Propagate JWT Caller Metadata across services feat: Add CallerType for request context propagation Dec 29, 2025
case CallerTypeUI:
return "ui"
case CallerTypeSDK:
return "sdk"
Copy link
Member

Choose a reason for hiding this comment

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

Question: This category is like 'getHistory' calls via the worker client library, for example? This refers to indirect API calls triggered by customer workers and direct API calls to say, 'StartWorkflow' via the client libraries?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the intention, yes. But how it'll depend on how the caller type is added to the context

case CallerTypeSDK:
return "sdk"
case CallerTypeService:
return "service"
Copy link
Member

Choose a reason for hiding this comment

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

Nit: This is, I assume, direct YARPC API calls?

Copy link
Member Author

Choose a reason for hiding this comment

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

this would be any calls that are initiated by the services and not by cli/sdk/UI. We will propagate the caller type in the context so requests downstream will maintain the initial caller type

Copy link
Member

Choose a reason for hiding this comment

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

as discussed in slack, this is presumably mostly intra-service calls. Imho we might need a slightly more descriptive name for this, indicating it's internal to the Cadence cluster (or clusters, in the case of replication).

Copy link
Member Author

Choose a reason for hiding this comment

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

renamed from "service" to "internal"

Copy link
Member

@davidporter-id-au davidporter-id-au left a comment

Choose a reason for hiding this comment

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

lgtm other than that renaming thing

Signed-off-by: fimanishi <fimanishi@gmail.com>
@fimanishi fimanishi force-pushed the propagate-caller-metadata branch from f0b7b0c to eb8c34a Compare December 30, 2025 01:23
@fimanishi fimanishi merged commit 6dfe968 into cadence-workflow:master Dec 30, 2025
42 checks passed
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.

2 participants