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
b3d0126d
Commit
b3d0126d
authored
Apr 09, 2018
by
Savorboard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove file
parent
19edfbd2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
250 deletions
+0
-250
CapDiagnosticListenerExtensions.cs
...otNetCore.CAP/Internal/CapDiagnosticListenerExtensions.cs
+0
-250
No files found.
src/DotNetCore.CAP/Internal/CapDiagnosticListenerExtensions.cs
deleted
100644 → 0
View file @
19edfbd2
using
System
;
using
System.Diagnostics
;
using
System.Runtime.CompilerServices
;
using
DotNetCore.CAP.Models
;
namespace
DotNetCore.CAP.Internal
{
/// <summary>
/// Extension methods on the DiagnosticListener class to log CAP data
/// </summary>
internal
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
,
CapPublishedMessage
message
,
[
CallerMemberName
]
string
operation
=
""
)
{
if
(
@this
.
IsEnabled
(
CapBeforePublish
))
{
Guid
operationId
=
Guid
.
NewGuid
();
@this
.
Write
(
CapBeforePublish
,
new
{
OperationId
=
operationId
,
Operation
=
operation
,
MessageId
=
message
.
Id
,
MessageName
=
message
.
Name
,
MessageContent
=
message
.
Content
});
return
operationId
;
}
return
Guid
.
Empty
;
}
public
static
void
WritePublishAfter
(
this
DiagnosticListener
@this
,
Guid
operationId
,
CapPublishedMessage
message
,
[
CallerMemberName
]
string
operation
=
""
)
{
if
(
@this
.
IsEnabled
(
CapAfterPublish
))
{
@this
.
Write
(
CapAfterPublish
,
new
{
OperationId
=
operationId
,
Operation
=
operation
,
MessageId
=
message
.
Id
,
MessageName
=
message
.
Name
,
MessageContent
=
message
.
Content
,
Timestamp
=
Stopwatch
.
GetTimestamp
()
});
}
}
public
static
void
WritePublishError
(
this
DiagnosticListener
@this
,
Guid
operationId
,
CapPublishedMessage
message
,
Exception
ex
,
[
CallerMemberName
]
string
operation
=
""
)
{
if
(
@this
.
IsEnabled
(
CapErrorPublish
))
{
@this
.
Write
(
CapErrorPublish
,
new
{
OperationId
=
operationId
,
Operation
=
operation
,
MessageId
=
message
.
Id
,
MessageName
=
message
.
Name
,
MessageContent
=
message
.
Content
,
Exception
=
ex
,
Timestamp
=
Stopwatch
.
GetTimestamp
()
});
}
}
public
static
Guid
WriteReceiveMessageStoreBefore
(
this
DiagnosticListener
@this
,
CapReceivedMessage
message
,
[
CallerMemberName
]
string
operation
=
""
)
{
if
(
@this
.
IsEnabled
(
CapBeforeReceiveMessageStore
))
{
Guid
operationId
=
Guid
.
NewGuid
();
@this
.
Write
(
CapBeforeReceiveMessageStore
,
new
{
OperationId
=
operationId
,
Operation
=
operation
,
MessageName
=
message
.
Name
,
MessageContent
=
message
.
Content
});
return
operationId
;
}
return
Guid
.
Empty
;
}
public
static
void
WriteReceiveMessageStoreAfter
(
this
DiagnosticListener
@this
,
Guid
operationId
,
CapReceivedMessage
message
,
[
CallerMemberName
]
string
operation
=
""
)
{
if
(
@this
.
IsEnabled
(
CapAfterReceiveMessageStore
))
{
@this
.
Write
(
CapAfterReceiveMessageStore
,
new
{
OperationId
=
operationId
,
Operation
=
operation
,
MessageId
=
message
.
Id
,
MessageName
=
message
.
Name
,
MessageContent
=
message
.
Content
,
Timestamp
=
Stopwatch
.
GetTimestamp
()
});
}
}
public
static
void
WriteReceiveMessageStoreError
(
this
DiagnosticListener
@this
,
Guid
operationId
,
CapReceivedMessage
message
,
Exception
ex
,
[
CallerMemberName
]
string
operation
=
""
)
{
if
(
@this
.
IsEnabled
(
CapErrorReceiveMessageStore
))
{
@this
.
Write
(
CapErrorReceiveMessageStore
,
new
{
OperationId
=
operationId
,
Operation
=
operation
,
MessageId
=
message
.
Id
,
MessageName
=
message
.
Name
,
MessageContent
=
message
.
Content
,
Exception
=
ex
,
Timestamp
=
Stopwatch
.
GetTimestamp
()
});
}
}
public
static
Guid
WriteConsumerInvokeBefore
(
this
DiagnosticListener
@this
,
ConsumerContext
context
,
[
CallerMemberName
]
string
operation
=
""
)
{
if
(
@this
.
IsEnabled
(
CapBeforeConsumerInvoke
))
{
Guid
operationId
=
Guid
.
NewGuid
();
@this
.
Write
(
CapBeforeConsumerInvoke
,
new
{
OperationId
=
operationId
,
Operation
=
operation
,
MethodName
=
context
.
ConsumerDescriptor
.
MethodInfo
.
Name
,
ConsumerGroup
=
context
.
ConsumerDescriptor
.
Attribute
.
Group
,
MessageName
=
context
.
DeliverMessage
.
Name
,
MessageContent
=
context
.
DeliverMessage
.
Content
,
Timestamp
=
Stopwatch
.
GetTimestamp
()
});
return
operationId
;
}
return
Guid
.
Empty
;
}
public
static
void
WriteConsumerInvokeAfter
(
this
DiagnosticListener
@this
,
Guid
operationId
,
ConsumerContext
context
,
[
CallerMemberName
]
string
operation
=
""
)
{
if
(
@this
.
IsEnabled
(
CapAfterConsumerInvoke
))
{
@this
.
Write
(
CapAfterConsumerInvoke
,
new
{
OperationId
=
operationId
,
Operation
=
operation
,
MethodName
=
context
.
ConsumerDescriptor
.
MethodInfo
.
Name
,
ConsumerGroup
=
context
.
ConsumerDescriptor
.
Attribute
.
Group
,
MessageName
=
context
.
DeliverMessage
.
Name
,
MessageContent
=
context
.
DeliverMessage
.
Content
,
Timestamp
=
Stopwatch
.
GetTimestamp
()
});
}
}
public
static
void
WriteConsumerInvokeError
(
this
DiagnosticListener
@this
,
Guid
operationId
,
ConsumerContext
context
,
Exception
ex
,
[
CallerMemberName
]
string
operation
=
""
)
{
if
(
@this
.
IsEnabled
(
CapErrorConsumerInvoke
))
{
@this
.
Write
(
CapErrorConsumerInvoke
,
new
{
OperationId
=
operationId
,
Operation
=
operation
,
MethodName
=
context
.
ConsumerDescriptor
.
MethodInfo
.
Name
,
ConsumerGroup
=
context
.
ConsumerDescriptor
.
Attribute
.
Group
,
MessageName
=
context
.
DeliverMessage
.
Name
,
MessageContent
=
context
.
DeliverMessage
.
Content
,
Exception
=
ex
,
Timestamp
=
Stopwatch
.
GetTimestamp
()
});
}
}
}
}
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