Skip to content

Conversation

hjgraca
Copy link
Contributor

@hjgraca hjgraca commented Sep 30, 2025

Please provide the issue number

Issue number: #1010

Summary

Changes

  • Fixed LitJson serialization crashes that were causing Lambda function failures when tracing complex objects

  • Resolved test isolation issues where environment variables from one test affected subsequent tests

  • XRayRecorder.cs: Added multi-layer sanitization with type conversion, property filtering, and fallback serialization

  • TracingSubsegment.cs: Enhanced subsegment lifecycle management with proper disposal patterns

  • Tracing.cs: Added new BeginSubsegment() API for manual subsegment creation

  • Enhanced Tracing API: Added Tracing.BeginSubsegment() method for manual subsegment management

User experience

You can create subsegments using the familiar using statement pattern for automatic cleanup and exception safety.

  using AWS.Lambda.Powertools.Tracing;

  public class Function
  {
      public async Task<APIGatewayProxyResponse> FunctionHandler
          (APIGatewayProxyRequest apigProxyEvent, ILambdaContext context)
      {
          using var gatewaySegment = Tracing.BeginSubsegment("PaymentGatewayIntegration");
          gatewaySegment.AddAnnotation("Operation", "ProcessPayment");
          gatewaySegment.AddAnnotation("PaymentMethod", "CreditCard");

          var result = await ProcessPaymentAsync();
          gatewaySegment.AddAnnotation("ProcessingTimeMs", result.ProcessingTimeMs);
          // Subsegment automatically ends when disposed
      }
  }

Checklist

Please leave checklist items unchecked if they do not apply to your change.

Is this a breaking change?

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

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.

@boring-cyborg boring-cyborg bot added area/tracing Core tracing utility tests labels Sep 30, 2025
@pull-request-size pull-request-size bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Sep 30, 2025
@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Sep 30, 2025
@github-actions github-actions bot added the internal Maintenance changes label Sep 30, 2025
@hjgraca hjgraca self-assigned this Sep 30, 2025
@hjgraca hjgraca linked an issue Sep 30, 2025 that may be closed by this pull request
2 tasks
Copy link

codecov bot commented Sep 30, 2025

Codecov Report

❌ Patch coverage is 84.94624% with 56 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.12%. Comparing base (0a5659d) to head (f5485a1).
⚠️ Report is 9 commits behind head on develop.

Files with missing lines Patch % Lines
...Lambda.Powertools.Tracing/Internal/XRayRecorder.cs 83.01% 41 Missing and 12 partials ⚠️
...a.Powertools.Tracing/Internal/TracingSubsegment.cs 92.50% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1011      +/-   ##
===========================================
+ Coverage    77.86%   78.12%   +0.25%     
===========================================
  Files          298      298              
  Lines        11643    12003     +360     
  Branches      1394     1441      +47     
===========================================
+ Hits          9066     9377     +311     
- Misses        2126     2163      +37     
- Partials       451      463      +12     

☔ 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.

@hjgraca hjgraca marked this pull request as draft September 30, 2025 15:13
Copy link

sonarqubecloud bot commented Oct 1, 2025

@hjgraca hjgraca marked this pull request as ready for review October 1, 2025 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/tracing Core tracing utility documentation Improvements or additions to documentation internal Maintenance changes size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Sanitize Metadata for X-Ray
1 participant