Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
CAP
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
CAP
Commits
e8846e81
Commit
e8846e81
authored
Apr 09, 2018
by
Savorboard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor Diagnostics module.
parent
11abd6dc
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
463 additions
and
0 deletions
+463
-0
DiagnosticListenerExtensions.cs
...otNetCore.CAP/Diagnostics/DiagnosticListenerExtensions.cs
+250
-0
EventData.Broker.Consume.cs
src/DotNetCore.CAP/Diagnostics/EventData.Broker.Consume.cs
+16
-0
EventData.Broker.ConsumeEnd.cs
...DotNetCore.CAP/Diagnostics/EventData.Broker.ConsumeEnd.cs
+16
-0
EventData.Broker.ConsumeError.cs
...tNetCore.CAP/Diagnostics/EventData.Broker.ConsumeError.cs
+16
-0
EventData.Broker.Publish.cs
src/DotNetCore.CAP/Diagnostics/EventData.Broker.Publish.cs
+16
-0
EventData.Broker.PublishEnd.cs
...DotNetCore.CAP/Diagnostics/EventData.Broker.PublishEnd.cs
+16
-0
EventData.Broker.PublishError.cs
...tNetCore.CAP/Diagnostics/EventData.Broker.PublishError.cs
+16
-0
EventData.Broker.cs
src/DotNetCore.CAP/Diagnostics/EventData.Broker.cs
+22
-0
EventData.SubscriberInvoke.cs
src/DotNetCore.CAP/Diagnostics/EventData.SubscriberInvoke.cs
+33
-0
EventData.SubscriberInvokeEnd.cs
...tNetCore.CAP/Diagnostics/EventData.SubscriberInvokeEnd.cs
+17
-0
EventData.SubscriberInvokeError.cs
...etCore.CAP/Diagnostics/EventData.SubscriberInvokeError.cs
+17
-0
EventData.cs
src/DotNetCore.CAP/Diagnostics/EventData.cs
+17
-0
IErrorEventData.cs
src/DotNetCore.CAP/Diagnostics/IErrorEventData.cs
+11
-0
No files found.
src/DotNetCore.CAP/Diagnostics/DiagnosticListenerExtensions.cs
0 → 100644
View file @
e8846e81
using
System
;
using
System.Diagnostics
;
using
System.Runtime.CompilerServices
;
using
DotNetCore.CAP.Internal
;
using
DotNetCore.CAP.Models
;
namespace
DotNetCore.CAP.Diagnostics
{
/// <summary>
/// Extension methods on the DiagnosticListener class to log CAP data
/// </summary>
public
static
class
CapDiagnosticListenerExtensions
{
public
const
string
DiagnosticListenerName
=
"CapDiagnosticListener"
;
private
const
string
CapPrefix
=
"DotNetCore.CAP."
;
public
const
string
CapBeforePublishMessageStore
=
CapPrefix
+
nameof
(
WritePublishMessageStoreBefore
);
public
const
string
CapAfterPublishMessageStore
=
CapPrefix
+
nameof
(
WritePublishMessageStoreAfter
);
public
const
string
CapErrorPublishMessageStore
=
CapPrefix
+
nameof
(
WritePublishMessageStoreError
);
public
const
string
CapBeforePublish
=
CapPrefix
+
nameof
(
WritePublishBefore
);
public
const
string
CapAfterPublish
=
CapPrefix
+
nameof
(
WritePublishAfter
);
public
const
string
CapErrorPublish
=
CapPrefix
+
nameof
(
WritePublishError
);
public
const
string
CapBeforeReceiveMessageStore
=
CapPrefix
+
nameof
(
WriteReceiveMessageStoreBefore
);
public
const
string
CapAfterReceiveMessageStore
=
CapPrefix
+
nameof
(
WriteReceiveMessageStoreAfter
);
public
const
string
CapErrorReceiveMessageStore
=
CapPrefix
+
nameof
(
WriteReceiveMessageStoreError
);
public
const
string
CapBeforeConsumerInvoke
=
CapPrefix
+
nameof
(
WriteConsumerInvokeBefore
);
public
const
string
CapAfterConsumerInvoke
=
CapPrefix
+
nameof
(
WriteConsumerInvokeAfter
);
public
const
string
CapErrorConsumerInvoke
=
CapPrefix
+
nameof
(
WriteConsumerInvokeError
);
public
static
Guid
WritePublishMessageStoreBefore
(
this
DiagnosticListener
@this
,
CapPublishedMessage
message
,
[
CallerMemberName
]
string
operation
=
""
)
{
if
(
@this
.
IsEnabled
(
CapBeforePublishMessageStore
))
{
Guid
operationId
=
Guid
.
NewGuid
();
@this
.
Write
(
CapBeforePublishMessageStore
,
new
{
OperationId
=
operationId
,
Operation
=
operation
,
MessageName
=
message
.
Name
,
MessageContent
=
message
.
Content
});
return
operationId
;
}
return
Guid
.
Empty
;
}
public
static
void
WritePublishMessageStoreAfter
(
this
DiagnosticListener
@this
,
Guid
operationId
,
CapPublishedMessage
message
,
[
CallerMemberName
]
string
operation
=
""
)
{
if
(
@this
.
IsEnabled
(
CapAfterPublishMessageStore
))
{
@this
.
Write
(
CapAfterPublishMessageStore
,
new
{
OperationId
=
operationId
,
Operation
=
operation
,
MessageId
=
message
.
Id
,
MessageName
=
message
.
Name
,
MessageContent
=
message
.
Content
,
Timestamp
=
Stopwatch
.
GetTimestamp
()
});
}
}
public
static
void
WritePublishMessageStoreError
(
this
DiagnosticListener
@this
,
Guid
operationId
,
CapPublishedMessage
message
,
Exception
ex
,
[
CallerMemberName
]
string
operation
=
""
)
{
if
(
@this
.
IsEnabled
(
CapErrorPublishMessageStore
))
{
@this
.
Write
(
CapErrorPublishMessageStore
,
new
{
OperationId
=
operationId
,
Operation
=
operation
,
MessageName
=
message
.
Name
,
MessageContent
=
message
.
Content
,
Exception
=
ex
,
Timestamp
=
Stopwatch
.
GetTimestamp
()
});
}
}
public
static
Guid
WritePublishBefore
(
this
DiagnosticListener
@this
,
string
topic
,
string
body
,
string
brokerAddress
,
[
CallerMemberName
]
string
operation
=
""
)
{
if
(
@this
.
IsEnabled
(
CapBeforePublish
))
{
Guid
operationId
=
Guid
.
NewGuid
();
@this
.
Write
(
CapBeforePublish
,
new
BrokerPublishEventData
(
operationId
,
operation
,
brokerAddress
,
topic
,
body
,
DateTimeOffset
.
UtcNow
));
return
operationId
;
}
return
Guid
.
Empty
;
}
public
static
void
WritePublishAfter
(
this
DiagnosticListener
@this
,
Guid
operationId
,
string
topic
,
string
body
,
string
brokerAddress
,
DateTimeOffset
startTime
,
TimeSpan
duration
,
[
CallerMemberName
]
string
operation
=
""
)
{
if
(
@this
.
IsEnabled
(
CapAfterPublish
))
{
@this
.
Write
(
CapAfterPublish
,
new
BrokerPublishEndEventData
(
operationId
,
operation
,
brokerAddress
,
topic
,
body
,
startTime
,
duration
));
}
}
public
static
void
WritePublishError
(
this
DiagnosticListener
@this
,
Guid
operationId
,
string
topic
,
string
body
,
string
brokerAddress
,
Exception
ex
,
DateTimeOffset
startTime
,
TimeSpan
duration
,
[
CallerMemberName
]
string
operation
=
""
)
{
if
(
@this
.
IsEnabled
(
CapErrorPublish
))
{
@this
.
Write
(
CapErrorPublish
,
new
BrokerPublishErrorEventData
(
operationId
,
operation
,
brokerAddress
,
topic
,
body
,
ex
,
startTime
,
duration
));
}
}
public
static
Guid
WriteReceiveMessageStoreBefore
(
this
DiagnosticListener
@this
,
string
topic
,
string
body
,
string
groupName
,
[
CallerMemberName
]
string
operation
=
""
)
{
if
(
@this
.
IsEnabled
(
CapBeforeReceiveMessageStore
))
{
Guid
operationId
=
Guid
.
NewGuid
();
@this
.
Write
(
CapBeforePublish
,
new
BrokerConsumeEventData
(
operationId
,
operation
,
groupName
,
topic
,
body
,
DateTimeOffset
.
UtcNow
));
return
operationId
;
}
return
Guid
.
Empty
;
}
public
static
void
WriteReceiveMessageStoreAfter
(
this
DiagnosticListener
@this
,
Guid
operationId
,
string
topic
,
string
body
,
string
groupName
,
DateTimeOffset
startTime
,
TimeSpan
duration
,
[
CallerMemberName
]
string
operation
=
""
)
{
if
(
@this
.
IsEnabled
(
CapAfterReceiveMessageStore
))
{
@this
.
Write
(
CapAfterPublish
,
new
BrokerConsumeEndEventData
(
operationId
,
operation
,
groupName
,
topic
,
body
,
startTime
,
duration
));
}
}
public
static
void
WriteReceiveMessageStoreError
(
this
DiagnosticListener
@this
,
Guid
operationId
,
string
topic
,
string
body
,
string
groupName
,
Exception
ex
,
DateTimeOffset
startTime
,
TimeSpan
duration
,
[
CallerMemberName
]
string
operation
=
""
)
{
if
(
@this
.
IsEnabled
(
CapErrorReceiveMessageStore
))
{
@this
.
Write
(
CapErrorPublish
,
new
BrokerConsumeErrorEventData
(
operationId
,
operation
,
groupName
,
topic
,
body
,
ex
,
startTime
,
duration
));
}
}
public
static
Guid
WriteConsumerInvokeBefore
(
this
DiagnosticListener
@this
,
ConsumerContext
context
,
[
CallerMemberName
]
string
operation
=
""
)
{
if
(
@this
.
IsEnabled
(
CapBeforeConsumerInvoke
))
{
Guid
operationId
=
Guid
.
NewGuid
();
var
methodName
=
context
.
ConsumerDescriptor
.
MethodInfo
.
Name
;
var
subscribeName
=
context
.
ConsumerDescriptor
.
Attribute
.
Name
;
var
subscribeGroup
=
context
.
ConsumerDescriptor
.
Attribute
.
Group
;
var
parameterValues
=
context
.
DeliverMessage
.
Content
;
@this
.
Write
(
CapBeforePublish
,
new
SubscriberInvokeEventData
(
operationId
,
operation
,
methodName
,
subscribeName
,
subscribeGroup
,
parameterValues
,
DateTimeOffset
.
UtcNow
));
return
operationId
;
}
return
Guid
.
Empty
;
}
public
static
void
WriteConsumerInvokeAfter
(
this
DiagnosticListener
@this
,
Guid
operationId
,
ConsumerContext
context
,
DateTimeOffset
startTime
,
TimeSpan
duration
,
[
CallerMemberName
]
string
operation
=
""
)
{
if
(
@this
.
IsEnabled
(
CapAfterConsumerInvoke
))
{
var
methodName
=
context
.
ConsumerDescriptor
.
MethodInfo
.
Name
;
var
subscribeName
=
context
.
ConsumerDescriptor
.
Attribute
.
Name
;
var
subscribeGroup
=
context
.
ConsumerDescriptor
.
Attribute
.
Group
;
var
parameterValues
=
context
.
DeliverMessage
.
Content
;
@this
.
Write
(
CapBeforePublish
,
new
SubscriberInvokeEndEventData
(
operationId
,
operation
,
methodName
,
subscribeName
,
subscribeGroup
,
parameterValues
,
startTime
,
duration
));
}
}
public
static
void
WriteConsumerInvokeError
(
this
DiagnosticListener
@this
,
Guid
operationId
,
ConsumerContext
context
,
Exception
ex
,
DateTimeOffset
startTime
,
TimeSpan
duration
,
[
CallerMemberName
]
string
operation
=
""
)
{
if
(
@this
.
IsEnabled
(
CapErrorConsumerInvoke
))
{
var
methodName
=
context
.
ConsumerDescriptor
.
MethodInfo
.
Name
;
var
subscribeName
=
context
.
ConsumerDescriptor
.
Attribute
.
Name
;
var
subscribeGroup
=
context
.
ConsumerDescriptor
.
Attribute
.
Group
;
var
parameterValues
=
context
.
DeliverMessage
.
Content
;
@this
.
Write
(
CapBeforePublish
,
new
SubscriberInvokeErrorEventData
(
operationId
,
operation
,
methodName
,
subscribeName
,
subscribeGroup
,
parameterValues
,
ex
,
startTime
,
duration
));
}
}
}
}
src/DotNetCore.CAP/Diagnostics/EventData.Broker.Consume.cs
0 → 100644
View file @
e8846e81
using
System
;
namespace
DotNetCore.CAP.Diagnostics
{
public
class
BrokerConsumeEventData
:
BrokerEventData
{
public
DateTimeOffset
StartTime
{
get
;
}
public
BrokerConsumeEventData
(
Guid
operationId
,
string
operation
,
string
groupName
,
string
brokerTopicName
,
string
brokerTopicBody
,
DateTimeOffset
startTime
)
:
base
(
operationId
,
operation
,
groupName
,
brokerTopicName
,
brokerTopicBody
)
{
StartTime
=
startTime
;
}
}
}
src/DotNetCore.CAP/Diagnostics/EventData.Broker.ConsumeEnd.cs
0 → 100644
View file @
e8846e81
using
System
;
namespace
DotNetCore.CAP.Diagnostics
{
public
class
BrokerConsumeEndEventData
:
BrokerConsumeEventData
{
public
TimeSpan
Duration
{
get
;
}
public
BrokerConsumeEndEventData
(
Guid
operationId
,
string
operation
,
string
groupName
,
string
brokerTopicName
,
string
brokerTopicBody
,
DateTimeOffset
startTime
,
TimeSpan
duration
)
:
base
(
operationId
,
operation
,
groupName
,
brokerTopicName
,
brokerTopicBody
,
startTime
)
{
Duration
=
duration
;
}
}
}
src/DotNetCore.CAP/Diagnostics/EventData.Broker.ConsumeError.cs
0 → 100644
View file @
e8846e81
using
System
;
namespace
DotNetCore.CAP.Diagnostics
{
public
class
BrokerConsumeErrorEventData
:
BrokerConsumeEndEventData
,
IErrorEventData
{
public
Exception
Exception
{
get
;
}
public
BrokerConsumeErrorEventData
(
Guid
operationId
,
string
operation
,
string
groupName
,
string
brokerTopicName
,
string
brokerTopicBody
,
Exception
exception
,
DateTimeOffset
startTime
,
TimeSpan
duration
)
:
base
(
operationId
,
operation
,
groupName
,
brokerTopicName
,
brokerTopicBody
,
startTime
,
duration
)
{
Exception
=
exception
;
}
}
}
src/DotNetCore.CAP/Diagnostics/EventData.Broker.Publish.cs
0 → 100644
View file @
e8846e81
using
System
;
namespace
DotNetCore.CAP.Diagnostics
{
public
class
BrokerPublishEventData
:
BrokerEventData
{
public
DateTimeOffset
StartTime
{
get
;
}
public
BrokerPublishEventData
(
Guid
operationId
,
string
operation
,
string
groupName
,
string
brokerTopicName
,
string
brokerTopicBody
,
DateTimeOffset
startTime
)
:
base
(
operationId
,
operation
,
groupName
,
brokerTopicName
,
brokerTopicBody
)
{
StartTime
=
startTime
;
}
}
}
src/DotNetCore.CAP/Diagnostics/EventData.Broker.PublishEnd.cs
0 → 100644
View file @
e8846e81
using
System
;
namespace
DotNetCore.CAP.Diagnostics
{
public
class
BrokerPublishEndEventData
:
BrokerPublishEventData
{
public
TimeSpan
Duration
{
get
;
}
public
BrokerPublishEndEventData
(
Guid
operationId
,
string
operation
,
string
groupName
,
string
brokerTopicName
,
string
brokerTopicBody
,
DateTimeOffset
startTime
,
TimeSpan
duration
)
:
base
(
operationId
,
operation
,
groupName
,
brokerTopicName
,
brokerTopicBody
,
startTime
)
{
Duration
=
duration
;
}
}
}
src/DotNetCore.CAP/Diagnostics/EventData.Broker.PublishError.cs
0 → 100644
View file @
e8846e81
using
System
;
namespace
DotNetCore.CAP.Diagnostics
{
public
class
BrokerPublishErrorEventData
:
BrokerPublishEndEventData
,
IErrorEventData
{
public
Exception
Exception
{
get
;
}
public
BrokerPublishErrorEventData
(
Guid
operationId
,
string
operation
,
string
groupName
,
string
brokerTopicName
,
string
brokerTopicBody
,
Exception
exception
,
DateTimeOffset
startTime
,
TimeSpan
duration
)
:
base
(
operationId
,
operation
,
groupName
,
brokerTopicName
,
brokerTopicBody
,
startTime
,
duration
)
{
Exception
=
exception
;
}
}
}
src/DotNetCore.CAP/Diagnostics/EventData.Broker.cs
0 → 100644
View file @
e8846e81
using
System
;
namespace
DotNetCore.CAP.Diagnostics
{
public
class
BrokerEventData
:
EventData
{
public
string
GroupName
{
get
;
set
;
}
public
string
BrokerTopicBody
{
get
;
set
;
}
public
string
BrokerTopicName
{
get
;
set
;
}
public
BrokerEventData
(
Guid
operationId
,
string
operation
,
string
groupName
,
string
brokerTopicName
,
string
brokerTopicBody
)
:
base
(
operationId
,
operation
)
{
GroupName
=
groupName
;
BrokerTopicName
=
brokerTopicName
;
BrokerTopicBody
=
brokerTopicBody
;
}
}
}
src/DotNetCore.CAP/Diagnostics/EventData.SubscriberInvoke.cs
0 → 100644
View file @
e8846e81
using
System
;
namespace
DotNetCore.CAP.Diagnostics
{
public
class
SubscriberInvokeEventData
:
EventData
{
public
DateTimeOffset
StartTime
{
get
;
}
public
string
MethodName
{
get
;
set
;
}
public
string
SubscribeName
{
get
;
set
;
}
public
string
SubscribeGroup
{
get
;
set
;
}
public
string
ParameterValues
{
get
;
set
;
}
public
SubscriberInvokeEventData
(
Guid
operationId
,
string
operation
,
string
methodName
,
string
subscribeName
,
string
subscribeGroup
,
string
parameterValues
,
DateTimeOffset
startTime
)
:
base
(
operationId
,
operation
)
{
MethodName
=
methodName
;
SubscribeName
=
subscribeName
;
SubscribeGroup
=
subscribeGroup
;
ParameterValues
=
parameterValues
;
StartTime
=
startTime
;
}
}
}
src/DotNetCore.CAP/Diagnostics/EventData.SubscriberInvokeEnd.cs
0 → 100644
View file @
e8846e81
using
System
;
namespace
DotNetCore.CAP.Diagnostics
{
public
class
SubscriberInvokeEndEventData
:
SubscriberInvokeEventData
{
public
TimeSpan
Duration
{
get
;
}
public
SubscriberInvokeEndEventData
(
Guid
operationId
,
string
operation
,
string
methodName
,
string
subscribeName
,
string
subscribeGroup
,
string
parameterValues
,
DateTimeOffset
startTime
,
TimeSpan
duration
)
:
base
(
operationId
,
operation
,
methodName
,
subscribeName
,
subscribeGroup
,
parameterValues
,
startTime
)
{
Duration
=
duration
;
}
}
}
src/DotNetCore.CAP/Diagnostics/EventData.SubscriberInvokeError.cs
0 → 100644
View file @
e8846e81
using
System
;
namespace
DotNetCore.CAP.Diagnostics
{
public
class
SubscriberInvokeErrorEventData
:
SubscriberInvokeEndEventData
,
IErrorEventData
{
public
Exception
Exception
{
get
;
}
public
SubscriberInvokeErrorEventData
(
Guid
operationId
,
string
operation
,
string
methodName
,
string
subscribeName
,
string
subscribeGroup
,
string
parameterValues
,
Exception
exception
,
DateTimeOffset
startTime
,
TimeSpan
duration
)
:
base
(
operationId
,
operation
,
methodName
,
subscribeName
,
subscribeGroup
,
parameterValues
,
startTime
,
duration
)
{
Exception
=
exception
;
}
}
}
src/DotNetCore.CAP/Diagnostics/EventData.cs
0 → 100644
View file @
e8846e81
using
System
;
namespace
DotNetCore.CAP.Diagnostics
{
public
class
EventData
{
public
EventData
(
Guid
operationId
,
string
operation
)
{
OperationId
=
operationId
;
Operation
=
operation
;
}
public
Guid
OperationId
{
get
;
set
;
}
public
string
Operation
{
get
;
set
;
}
}
}
src/DotNetCore.CAP/Diagnostics/IErrorEventData.cs
0 → 100644
View file @
e8846e81
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
DotNetCore.CAP.Diagnostics
{
public
interface
IErrorEventData
{
Exception
Exception
{
get
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment