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
24d36f36
Unverified
Commit
24d36f36
authored
Jul 05, 2018
by
Lemon
Committed by
GitHub
Jul 05, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix issue#66 (#67)
parent
3e72e125
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
45 additions
and
4 deletions
+45
-4
ValuesController.cs
.../SkyWalking.Sample.AspNet/Controllers/ValuesController.cs
+2
-4
ITracerContext.cs
src/SkyWalking.Abstractions/Context/ITracerContext.cs
+3
-0
ContextManager.cs
src/SkyWalking.Core/Context/ContextManager.cs
+3
-0
IgnoredTracerContext.cs
src/SkyWalking.Core/Context/IgnoredTracerContext.cs
+10
-0
TracingContext.cs
src/SkyWalking.Core/Context/TracingContext.cs
+10
-0
EntityFrameworkCoreDiagnosticProcessor.cs
...tyFrameworkCore/EntityFrameworkCoreDiagnosticProcessor.cs
+4
-0
SqlClientDiagnosticProcessor.cs
...ing.Diagnostics.SqlClient/SqlClientDiagnosticProcessor.cs
+13
-0
No files found.
sample/SkyWalking.Sample.AspNet/Controllers/ValuesController.cs
View file @
24d36f36
...
...
@@ -9,10 +9,8 @@ namespace SkyWalking.Sample.AspNet.Controllers
{
public
async
Task
<
IHttpActionResult
>
Get
()
{
// var httpClient = new HttpClient(new HttpTracingHandler());
// var values = await httpClient.GetStringAsync("http://localhost:5002/api/values");
var
values
=
1
;
var
httpClient
=
new
HttpClient
(
new
HttpTracingHandler
());
var
values
=
await
httpClient
.
GetStringAsync
(
"http://localhost:5001/api/values"
);
return
Json
(
values
);
}
}
...
...
src/SkyWalking.Abstractions/Context/ITracerContext.cs
View file @
24d36f36
...
...
@@ -16,6 +16,7 @@
*
*/
using
System.Collections.Generic
;
using
SkyWalking.Context.Trace
;
namespace
SkyWalking.Context
...
...
@@ -29,6 +30,8 @@ namespace SkyWalking.Context
IContextSnapshot
Capture
{
get
;
}
ISpan
ActiveSpan
{
get
;
}
IDictionary
<
string
,
object
>
Properties
{
get
;
}
void
Continued
(
IContextSnapshot
snapshot
);
...
...
src/SkyWalking.Core/Context/ContextManager.cs
View file @
24d36f36
...
...
@@ -17,6 +17,7 @@
*/
using
System
;
using
System.Collections.Generic
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
SkyWalking.Boot
;
...
...
@@ -98,6 +99,8 @@ namespace SkyWalking.Context
public
static
IContextSnapshot
Capture
=>
_context
.
Value
?.
Capture
;
public
static
IDictionary
<
string
,
object
>
ContextProperties
=>
_context
.
Value
?.
Properties
;
public
static
ISpan
CreateEntrySpan
(
string
operationName
,
IContextCarrier
carrier
)
{
var
samplingService
=
ServiceManager
.
Instance
.
GetService
<
SamplingService
>();
...
...
src/SkyWalking.Core/Context/IgnoredTracerContext.cs
View file @
24d36f36
...
...
@@ -16,6 +16,7 @@
*
*/
using
System
;
using
System.Collections.Generic
;
using
System.Runtime.CompilerServices
;
using
SkyWalking.Context.Trace
;
...
...
@@ -49,6 +50,8 @@ namespace SkyWalking.Context
}
}
public
IDictionary
<
string
,
object
>
Properties
{
get
;
}
=
new
Dictionary
<
string
,
object
>();
public
void
Continued
(
IContextSnapshot
snapshot
)
{
}
...
...
@@ -83,6 +86,13 @@ namespace SkyWalking.Context
if
(
_spans
.
Count
==
0
)
{
ListenerManager
.
NotifyFinish
(
this
);
foreach
(
var
item
in
Properties
)
{
if
(
item
.
Value
is
IDisposable
disposable
)
{
disposable
.
Dispose
();
}
}
}
}
...
...
src/SkyWalking.Core/Context/TracingContext.cs
View file @
24d36f36
...
...
@@ -121,6 +121,8 @@ namespace SkyWalking.Context
public
IContextSnapshot
Capture
=>
InternalCapture
();
public
ISpan
ActiveSpan
=>
InternalActiveSpan
();
public
IDictionary
<
string
,
object
>
Properties
{
get
;
}
=
new
Dictionary
<
string
,
object
>();
public
void
Continued
(
IContextSnapshot
snapshot
)
{
...
...
@@ -288,6 +290,14 @@ namespace SkyWalking.Context
}
ListenerManager
.
NotifyFinish
(
finishedSegment
);
foreach
(
var
item
in
Properties
)
{
if
(
item
.
Value
is
IDisposable
disposable
)
{
disposable
.
Dispose
();
}
}
}
private
ISpan
InternalActiveSpan
()
...
...
src/SkyWalking.Diagnostics.EntityFrameworkCore/EntityFrameworkCoreDiagnosticProcessor.cs
View file @
24d36f36
...
...
@@ -32,6 +32,7 @@ namespace SkyWalking.Diagnostics.EntityFrameworkCore
{
public
class
EntityFrameworkCoreDiagnosticProcessor
:
ITracingDiagnosticProcessor
{
private
const
string
TRACE_ORM
=
"TRACE_ORM"
;
private
Func
<
CommandEventData
,
string
>
_operationNameResolver
;
private
readonly
IEfCoreSpanFactory
_efCoreSpanFactory
;
...
...
@@ -69,12 +70,14 @@ namespace SkyWalking.Diagnostics.EntityFrameworkCore
Tags
.
DbInstance
.
Set
(
span
,
eventData
.
Command
.
Connection
.
Database
);
Tags
.
DbStatement
.
Set
(
span
,
eventData
.
Command
.
CommandText
);
Tags
.
DbBindVariables
.
Set
(
span
,
BuildParameterVariables
(
eventData
.
Command
.
Parameters
));
ContextManager
.
ContextProperties
[
TRACE_ORM
]
=
true
;
}
[
DiagnosticName
(
"Microsoft.EntityFrameworkCore.Database.Command.CommandExecuted"
)]
public
void
CommandExecuted
()
{
ContextManager
.
StopSpan
();
ContextManager
.
ContextProperties
.
Remove
(
TRACE_ORM
);
}
[
DiagnosticName
(
"Microsoft.EntityFrameworkCore.Database.Command.CommandError"
)]
...
...
@@ -92,6 +95,7 @@ namespace SkyWalking.Diagnostics.EntityFrameworkCore
}
span
.
ErrorOccurred
();
ContextManager
.
StopSpan
(
span
);
ContextManager
.
ContextProperties
.
Remove
(
TRACE_ORM
);
}
private
string
BuildParameterVariables
(
DbParameterCollection
dbParameters
)
...
...
src/SkyWalking.Diagnostics.SqlClient/SqlClientDiagnosticProcessor.cs
View file @
24d36f36
...
...
@@ -28,6 +28,7 @@ namespace SkyWalking.Diagnostics.SqlClient
{
public
class
SqlClientDiagnosticProcessor
:
ITracingDiagnosticProcessor
{
private
const
string
TRACE_ORM
=
"TRACE_ORM"
;
public
string
ListenerName
{
get
;
}
=
SqlClientDiagnosticStrings
.
DiagnosticListenerName
;
private
static
string
ResolveOperationName
(
SqlCommand
sqlCommand
)
...
...
@@ -39,6 +40,10 @@ namespace SkyWalking.Diagnostics.SqlClient
[
DiagnosticName
(
SqlClientDiagnosticStrings
.
SqlBeforeExecuteCommand
)]
public
void
BeforeExecuteCommand
([
Property
(
Name
=
"Command"
)]
SqlCommand
sqlCommand
)
{
if
(
ContextManager
.
ContextProperties
.
ContainsKey
(
TRACE_ORM
))
{
return
;
}
var
peer
=
sqlCommand
.
Connection
.
DataSource
;
var
span
=
ContextManager
.
CreateExitSpan
(
ResolveOperationName
(
sqlCommand
),
peer
);
span
.
SetLayer
(
SpanLayer
.
DB
);
...
...
@@ -52,12 +57,20 @@ namespace SkyWalking.Diagnostics.SqlClient
[
DiagnosticName
(
SqlClientDiagnosticStrings
.
SqlAfterExecuteCommand
)]
public
void
AfterExecuteCommand
()
{
if
(
ContextManager
.
ContextProperties
.
ContainsKey
(
TRACE_ORM
))
{
return
;
}
ContextManager
.
StopSpan
();
}
[
DiagnosticName
(
SqlClientDiagnosticStrings
.
SqlErrorExecuteCommand
)]
public
void
ErrorExecuteCommand
([
Property
(
Name
=
"Exception"
)]
Exception
ex
)
{
if
(
ContextManager
.
ContextProperties
.
ContainsKey
(
TRACE_ORM
))
{
return
;
}
var
span
=
ContextManager
.
ActiveSpan
;
span
?.
ErrorOccurred
();
span
?.
Log
(
ex
);
...
...
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