-
Notifications
You must be signed in to change notification settings - Fork 603
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. |
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