Skip to content

Conversation

@ConnorKirk
Copy link
Contributor

@ConnorKirk ConnorKirk commented Dec 2, 2025

Issue number: closes #7763

Summary

This PR updates the Logger and Metric decorators to handle DurableContexts. If a DurableContext is present, it is unwrapped to access the Lambda Context

The logger.inject_lambda_context() and metrics.log_metrics() decorators raise an error in some configurations when used with a Durable Execution.
The decorators access the Lambda Context. In durable executions, the Lambda Context is wrapped with the Durable Context. The Durable Context is now passed to the handler and thus the decorators.
This affects the @logger.inject_lambda_context(log_event=True) and @metrics.log_metrics(capture_cold_start_metric=True) decorators (when included params are True). These decorators work without these parameters set. Other decorators do not use the context object, so are not affected

Changes

  • Logger - decorate - Detect if a context is durable or lambda. Extract the lambda context
  • Metrics - decorate - Detect if a context is durable or lambda. Extract the lambda context
  • Metrics Provider - decorate - Detect if a context is durable or lambda. Extract the lambda context
  • Extract is_durable_context typeguard
  • Add tests to verify inject_lambda_context and log_metrics functions handle durable contexts correctly

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Dec 2, 2025
@ConnorKirk ConnorKirk changed the title Support Durable Function Context in logger and metric decorators feat(decorators): Support Durable Context in logger and metric decorators Dec 2, 2025
@github-actions github-actions bot added the feature New feature or functionality label Dec 2, 2025
@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.72%. Comparing base (11b68ff) to head (1aed09a).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #7765      +/-   ##
===========================================
+ Coverage    96.54%   96.72%   +0.17%     
===========================================
  Files          275      275              
  Lines        13209    13214       +5     
  Branches      1006     1006              
===========================================
+ Hits         12753    12781      +28     
+ Misses         353      325      -28     
- Partials       103      108       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ConnorKirk
Copy link
Contributor Author

This PR needs rebasing and updating based on the changes of #7764

@ConnorKirk
Copy link
Contributor Author

I'll rebase and finish this today

@leandrodamascena
Copy link
Contributor

I'll rebase and finish this today

Thanks!

@pull-request-size pull-request-size bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jan 5, 2026
@ConnorKirk ConnorKirk force-pushed the feat/df-decorators branch 2 times, most recently from c46c4fa to 53acf5b Compare January 5, 2026 16:28
This commit updates the Logger and Metric decorators to handle
DurableContexts. If a DurableContext is present, it is unwrapped to
access the Lambda Context
* Extract is_durable_context type guard
* Add tests to verify inject_lambda_context handles durable context
* Add tests to verify log_metrics handles durable context
@ConnorKirk ConnorKirk marked this pull request as ready for review January 6, 2026 11:01
@ConnorKirk ConnorKirk requested a review from a team as a code owner January 6, 2026 11:01
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 6, 2026

Copy link
Contributor

@leandrodamascena leandrodamascena left a comment

Choose a reason for hiding this comment

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

Thanks a lot @ConnorKirk! APPROVED!

@leandrodamascena leandrodamascena merged commit a3255e9 into develop Jan 6, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commons feature New feature or functionality logger metrics size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: support passing durable context in Logging and Metrics decorators

2 participants