-
Notifications
You must be signed in to change notification settings - Fork 333
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
SkyApm.Diagnostics for Masstransit #531
SkyApm.Diagnostics for Masstransit #531
Conversation
…sstransit a) Add Publish/Receive/Consumer Observer for tracking b) Use ActivityListener to get the operation name for trackig Note that: We need use ASPNETCORE_HOSTINGSTARTUPASSEMBLIES=SkyApm.Diagnnostics.MassTransit instead of ASPNETCORE_HOSTINGSTARTUPASSEMBLIES=SkyAPM.Agent.AspNetCore Next Step: a) Saga Statemachine b) Request and Respond c) More test
Just add a new branch for masstransit and let's complete that |
{ | ||
if (ContainsRabbitmq(host)) | ||
return 52; //rabbitmq-producer | ||
return 51; //rabbitmq |
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 is the definition of these numbers ?
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.
As component-libraries.yml in Skywalking mentioned, each component has it's int value, and it can be regonized as the rabbitmq-producer
rabbitmq-consumer
and so on.
I will need add more IComponentIdChecker to regonize the detail marker.
context.Span.Peer = $"{consumeContext.DestinationAddress.Host}"; | ||
context.Span.AddTag(Tags.MQ_TOPIC, activity.OperationName); | ||
context.Span.AddTag(Tags.MQ_BROKER, consumeContext.DestinationAddress.Host); | ||
context.Span.AddTag(MassTags.ExpirationTime, consumeContext.ExpirationTime?.ToString("yyyy-MM-dd HH:mm:ss-fff")); |
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.
ExpirationTime
is a high cardinality tag, best to use logging
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.
Thanks for your comments, will replace that with logging.
var activity = Activity.Current ?? default; | ||
|
||
var operationName = OperateNamePrefix + activity.OperationName; | ||
var context = _tracingContext.CreateLocalSegmentContext(operationName); |
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 think it would be more appropriate to use entryspan
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 have created the entryspan in ReceiveObserver that happened before the ConsumerObserver. If ConsumerObserver created the localspan which can GetParentSegmentContext created by ReceiveObserver.
|
||
var segContext = _tracingContext.CreateEntrySegmentContext("Masstransit Receiving/ " + activity.OperationName, | ||
new MasstransitCarrierHeaderCollection(context.TransportHeaders)); | ||
segContext.Span.SpanLayer = SpanLayer.DB; |
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.
The DB call cannot be an entry span, and an exit span should be used
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.
Any more pre-cautions to use the Span.SpanLayer? Just fount how to use Span.Component. Thanks.
{ | ||
public class ObserverSegmentContextDictionary | ||
{ | ||
public static readonly ConcurrentDictionary<Guid, SegmentContext> Contexts = new ConcurrentDictionary<Guid, SegmentContext>(); |
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.
not recommended usage
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.
Sure, let me seperate that in each Observer to solve the Concurrent conflict.
@@ -0,0 +1,16 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
|
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.
Need to import build\common.props
a) All observers - Removed ObserverSegmentContextDictionary.cs - Added the activity tags b) MasstransitConsumerObserver.cs - Used logging instead of the ExpirationTime tag c) MasstransitReceiveObserver.cs - Changed the Span.SpanLayer to Span.SpanLayer.MQ d) Project - Added the build\common.props
a) Combine PublishObserver and SendObserver Plan: StateMachine could use logging instead of Tracing
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 also need to add copyright header to each code file.
Apache LICENSE
SkyApm.Diagnostics for Masstransit
a) Add Publish/Receive/Consumer Observer for tracking b) Use ActivityListener to get the operation name for tracking
Note that:
We need use ASPNETCORE_HOSTINGSTARTUPASSEMBLIES=SkyApm.Diagnnostics.MassTransit instead of ASPNETCORE_HOSTINGSTARTUPASSEMBLIES=SkyAPM.Agent.AspNetCore
Next Step:
a) Saga Statemachine
b) Request and Respond
c) More test
Please answer these questions before submitting pull request
New feature or improvement