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

Configure extra log fields for SDK workflow and activity logs #1808

Open
timofurrer opened this issue Feb 10, 2025 · 2 comments
Open

Configure extra log fields for SDK workflow and activity logs #1808

timofurrer opened this issue Feb 10, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@timofurrer
Copy link

timofurrer commented Feb 10, 2025

Is your feature request related to a problem? Please describe.

I want to be able to easily attach business-related log fields to the log messages the SDK logs internally for workflows and activities.

One of such logs is

ath.logger.Error("Activity error.",

The business-related values I want to attach are only known during workflow and activity creation and NOT during worker initialization.

Describe the solution you'd like

Configuring them via StartWorkflowOptions and ActivityOptions seems desirable.

Describe alternatives you've considered

I've looked into using Interceptors, but the problem with them is that I have to register them at worker initialization and don't know the values at that point. I've looked into using custom search attributes or memos - which both would work but only exist of Workflows and not Activities. I also haven't found a way to easily retrieve the search attributes / memos of the workflow given an activity context.

The elaborate on the search attributes / memos approach: I basically would register an interceptor that reads the search attributes / memos from the workflow context and create a new logger with them that is returned.

What I want to avoid is having to query that data from within the activity interceptor from an "external" system.

Additional context
Add any other context or screenshots about the feature request here.

@timofurrer timofurrer added the enhancement New feature or request label Feb 10, 2025
@cretz
Copy link
Member

cretz commented Feb 10, 2025

but the problem with them is that I have to register them at worker initialization and don't know the values at that point

You don't need to know the values at that point, both activity and workflow outbound interceptors have GetLogger you can customize when called. https://github.com/temporalio/samples-go/tree/main/interceptor shows how to write the interceptor, but you can use the workflow/activity context in the interceptor to get workflow/activity-specific things like memo (or values via context propagation which may make more sense).

Does this help?

@timofurrer
Copy link
Author

timofurrer commented Feb 10, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants