Kafka Consumer traces show waiting time instead of actual receiving time
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Describe the bug
In the official Kafka NuGet for Dotnet, the `MessageConsumer` is implemented in such a way that it has a background Thread listening for messages from Kafka.
The `MessageConsumer` itself has a blocking `Consume()` method which blocks the current thread until a message arrives on the background thread.
The `Aspire.Confluent.Kafka` package now adds tracing to this.
The problem is that the `Activity` starts just before the call to `Consume()`.
If no message is received for a long time (maybe because there just is no message in the topic), this will lead to a very long span, although nearly all of that time was just waiting and not actually receiving a message.
Whatever is coming after that is now very disproportional.

### Expected Behavior
Use the timestamp of the message itself to set the start time after it has been received this will then report the actual time the message took to travel to the consumer instead of just a long waiting time.
### Steps To Reproduce
_No response_
### Exceptions (if any)
_No response_
### .NET Version info
.NET SDK:
Version: 9.0.201
Commit: 071aaccdc2
Workload version: 9.0.200-manifests.5c4e24dc
MSBuild version: 17.13.13+1c2026462
### Anything else?
Aspire.Confluent.Kafka 9.1.0
Contributor guide
Assessment
This issue has not been assessed yet.