public override async Task <ProcessedMessageStatus> HandleMessageAsync(MotorCloudEvent <TInput> dataCloudEvent, CancellationToken token = default) { var parentContext = dataCloudEvent.GetActivityContext(); using var activity = OpenTelemetryOptions.ActivitySource.StartActivity(nameof(HandleMessageAsync), ActivityKind.Server, parentContext); if (activity is null) { return(await base.HandleMessageAsync(dataCloudEvent, token)); } using (activity.Start()) using (_logger.BeginScope("TraceId: {traceid}, SpanId: {spanid}", activity.TraceId, activity.SpanId)) { var processedMessageStatus = ProcessedMessageStatus.CriticalFailure; try { dataCloudEvent.SetActivity(activity); processedMessageStatus = await base.HandleMessageAsync(dataCloudEvent, token); } finally { activity.SetTag(nameof(ProcessedMessageStatus), processedMessageStatus.ToString()); switch (processedMessageStatus) { case ProcessedMessageStatus.Success: activity.SetStatus(Status.Ok); break; case ProcessedMessageStatus.TemporaryFailure: activity.SetStatus(Status.Error.WithDescription(nameof(ProcessedMessageStatus.TemporaryFailure))); break; case ProcessedMessageStatus.InvalidInput: activity.SetStatus(Status.Error.WithDescription(nameof(ProcessedMessageStatus.InvalidInput))); break; case ProcessedMessageStatus.CriticalFailure: activity.SetStatus(Status.Error.WithDescription(nameof(ProcessedMessageStatus.CriticalFailure))); break; default: throw new ArgumentOutOfRangeException(); } } return(processedMessageStatus); } }
public Task <MotorCloudEvent <string>?> ConvertMessageAsync(MotorCloudEvent <string> dataCloudEvent, CancellationToken token = default) { var parentContext = dataCloudEvent.GetActivityContext(); Assert.NotEqual(default, parentContext);