-
Notifications
You must be signed in to change notification settings - Fork 607
feat: add activity on connection #1734
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@michaelklishin build seems broken due to some new CVE related to system text json ? |
dc89271
to
177ccbd
Compare
@eerhardt - do you have time to review this PR? Thanks! |
6587ffe
to
2a99147
Compare
@lukebakken when i implement the activity i create a new activity source but i m wondering if it s really usefull to have 3 ActivitySource and not use only one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way to write some tests around this?
@@ -226,11 +226,10 @@ internal void TakeOver(Connection other) | |||
internal async ValueTask<IConnection> OpenAsync(CancellationToken cancellationToken) | |||
{ | |||
cancellationToken.ThrowIfCancellationRequested(); | |||
|
|||
Activity? connectionActivity = RabbitMQActivitySource.OpenConnection(_frameHandler); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How/where does this activity get completed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are totally right. Missing some using keyword.
By reading the experimental activity on dotnet 9 http client I don't know if at some point we should link producer and consumer activity to the connection activity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by "should link producer and consumer activity"? My thinking was that creating the connection is the activity. Once the connection is created/established, the activity can be completed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link how? Have the connection activity be the parent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://opentelemetry.io/docs/concepts/signals/traces/#span-links => here is what i mean by link
if (!s_connectionSource.HasListeners()) | ||
{ | ||
return null; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!s_connectionSource.HasListeners()) | |
{ | |
return null; | |
} |
I don't think this is necessary. ActivitySource.CreateActivity
will do this check and return null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I take the same logic as the rest of the implem but you are right when I read the Microsoft code this line is useless
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I end up cleaning all has listener code
Thank you @eerhardt !!! |
2a99147
to
c9b91a2
Compare
@aygalinc just FYI, I rebased this on |
@eerhardt to the best of my knowledge Microsoft don't provide any testing support fort distributed tracing (contrary to metrics) . I do not find any test related to the other activity creation in rabbit. Maybe you have some resources that I miss to do this ? |
The main way I've seen it done is to hook listeners to the activity source, do the test, and then verify the activities were emitted as expected. Some examples:
|
c9b91a2
to
9bb228a
Compare
ae71fbf
to
a057ae2
Compare
@lukebakken do you now if it's possible to explicitly add System.Diagnostics.DiagnosticSource in version 9.0 in order to gain access to AddException method as suggested by @paulomorgado ? |
@eerhardt I use the dotnet runtime approach in the test to capture Activity |
It's safe to add. |
@eerhardt I check the code and I don't know what you envision on this use case : we can provide a list of endpoint the client will try to connect to one of them. Did we expect that each TCP connection will trigger a dedicated activity or we have a single activity with dedicated events that describe each TCP connection attempts? |
I'm not sure. My naive thoughts are that the CreateConnectionAsync creates a single Activity, and each connection attempt inside of it would be a child Activity. But I haven't given it any major thought. https://github.com/open-telemetry/semantic-conventions/tree/main/docs/messaging doesn't seem to have conventions for connection Activities, so that isn't much help. |
1 parent - 1 child activity per connection attempt : how an error is managed when the last attempt succeeded ? Individual Error should be attached to child activity but the activity who will be flag as error should be the parent one. In the actual design it is pretty complicated to have this behaviour from a bird eyes view. TCP connection establishment and open frame send are not so easy to correlate. 1 activity - 1 event per connection attempt: aggregated error is managed in the only activity. Activity does not contains so much useful information as they will be store in events (like ip, port etc) , can be a problem because some observability backend doesn't allowed to filter on event ( Tempo as example). |
Proposed Changes
Add activity on connection creation.
In case of creation exception register an error event.
Types of Changes
What types of changes does your code introduce to this project?
Put an
x
in the boxes that applyRefer to #1731