Open cikdibest opened 5 months ago
Hi @cikdibest , thanks for reporting the issue and also for providing the suggestion.
The EntityNotFoundException
is thrown when a parent segment or subsegment is missing when a new subsegment is created. We throw this exception instead of creating a parent segment on the fly because a) a parent segment should mostly exist on incoming requests when a service is instrumented correctly. b) creating segments on the fly may cause broken traces with unintended segments.
In your case, you can do either of the following:
AWS_XRAY_CONTEXT_MISSING
to IGNORE_ERROR
and this will suppress logging the EntityNotFoundException
. More details in this doc: https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-dotnet-configuration.html#xray-sdk-dotnet-configuration-envvars
We have configured our DbContext and MassTransit Outbox pattern as follows:
Setup:
Issue Description:
When using the AddXRayInterceptor(true) configuration, the EFInterceptor attempts to create a subsegment for every database query. However, during the execution of outbox-related queries, if the parent segment hasn't been created yet, the EFInterceptor fails to create the subsegment, leading to an EntityNotFoundException.
Suggested Enhancement:
It would be beneficial if the EFInterceptor could check whether the parent segment exists before attempting to create a subsegment. If the parent segment does not exist, ideally, the interceptor should start it. This enhancement would prevent the EntityNotFoundException and ensure smoother integration between Entity Framework and AWS X-Ray within the context of using MassTransit's Outbox pattern.