aws-powertools / powertools-lambda-dotnet

Powertools is a developer toolkit to implement Serverless best practices and increase developer velocity.
https://docs.powertools.aws.dev/lambda/dotnet/
MIT No Attribution
152 stars 24 forks source link

Maintenance: Bring Amazon.XRay.Recorder.Core.Internal.Entities into PT Tracing #603

Open sliedig opened 2 months ago

sliedig commented 2 months ago

Summary

When creating an trace inside a method using Tracing's WithSubsegment method, the action requires no additional imports are required for a file, just the reference to AWS.Lambda.Powertools.Tracing.

using AWS.Lambda.Powertools.Tracing;
...

Tracing.WithSubsegment("SendGrid", async s =>
{
    var response = await client.SendEmailAsync(msg);
    Logger.LogInformation(response.StatusCode);

    if (response.StatusCode == HttpStatusCode.Accepted)
    {
        nextExam.NotificationSent = true;
    }
});

however, if this call is refactored to use a local function for example, all of a sudden you need to ing a using reference to Amazon.XRay.Recorder.Core.Internal.Entities:

using AWS.Lambda.Powertools.Tracing;
using Amazon.XRay.Recorder.Core.Internal.Entities;
...

async void Subsegment(Subsegment subsegment)
{
    var response = await client.SendEmailAsync(msg);
    Logger.LogInformation(response.StatusCode);

    if (response.StatusCode == HttpStatusCode.Accepted)
    {
        nextExam.NotificationSent = true;
    }
}

Tracing.WithSubsegment("SendGrid", Subsegment);

This causes some confusion since the X-Ray libraries are included with PT. Ideally, we would want to hide this implementation also and bring Amazon.XRay.Recorder.Core.Internal.Entities under Powertools.

Why is this needed?

It exposes the internals of Tracing utility.

Which area does this relate to?

Tracing

Solution

No response

Acknowledgment