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
546931b1
Commit
546931b1
authored
Apr 07, 2018
by
Liuhaoyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ListenerManager
parent
b6ef70c8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
136 additions
and
8 deletions
+136
-8
ITracingContextListener.cs
...kyWalking.Abstractions/Context/ITracingContextListener.cs
+3
-4
ListenerManager.cs
src/SkyWalking.Core/Context/ListenerManager.cs
+50
-0
TracingContext.cs
src/SkyWalking.Core/Context/TracingContext.cs
+15
-3
SamplingService.cs
src/SkyWalking.Core/Sampling/SamplingService.cs
+19
-1
StackExtensions.cs
src/SkyWalking.Core/Utils/StackExtensions.cs
+49
-0
No files found.
src/SkyWalking.Abstractions/Context/ITracingContextListener.cs
View file @
546931b1
...
@@ -16,13 +16,12 @@
...
@@ -16,13 +16,12 @@
*
*
*/
*/
using
System
;
using
SkyWalking.Context.Trace
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
SkyWalking.Context
namespace
SkyWalking.Context
{
{
interface
ITracingContextListener
public
interface
ITracingContextListener
{
{
void
AfterFinished
(
ITraceSegment
traceSegment
);
}
}
}
}
src/SkyWalking.Core/Context/ListenerManager.cs
0 → 100644
View file @
546931b1
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using
System.Collections.Generic
;
using
System.Runtime.CompilerServices
;
using
SkyWalking.Context.Trace
;
namespace
SkyWalking.Context
{
public
static
class
ListenerManager
{
private
static
readonly
IList
<
ITracingContextListener
>
_listeners
=
new
List
<
ITracingContextListener
>();
[
MethodImpl
(
MethodImplOptions
.
Synchronized
)]
public
static
void
Add
(
ITracingContextListener
listener
)
{
_listeners
.
Add
(
listener
);
}
[
MethodImpl
(
MethodImplOptions
.
Synchronized
)]
public
static
void
Remove
(
ITracingContextListener
listener
)
{
_listeners
.
Remove
(
listener
);
}
public
static
void
NotifyFinish
(
ITraceSegment
traceSegment
)
{
foreach
(
var
listener
in
_listeners
)
{
listener
.
AfterFinished
(
traceSegment
);
}
}
}
}
\ No newline at end of file
src/SkyWalking.Core/Context/TracingContext.cs
View file @
546931b1
...
@@ -16,16 +16,28 @@
...
@@ -16,16 +16,28 @@
*
*
*/
*/
using
System.Collections
;
using
System.Collections.Generic
;
using
SkyWalking.Context.Trace
;
using
SkyWalking.Context.Trace
;
using
SkyWalking.Sampling
;
namespace
SkyWalking.Context
namespace
SkyWalking.Context
{
{
public
class
TracingContext
:
ITracerContext
public
class
TracingContext
:
ITracerContext
{
{
private
long
_lastWarningTimestamp
=
0
;
private
long
_lastWarningTimestamp
=
0
;
private
ISampler
_sampler
;
private
ITraceSegment
_segment
;
private
Stack
<
ISpan
>
_activeSpanStacks
;
private
int
_spanIdGenerator
;
public
TracingContext
()
{
_sampler
=
new
SamplingService
();
_segment
=
new
TraceSegment
();
_activeSpanStacks
=
new
Stack
<
ISpan
>();
}
public
void
Inject
(
IContextCarrier
carrier
)
public
void
Inject
(
IContextCarrier
carrier
)
{
{
throw
new
System
.
NotImplementedException
();
throw
new
System
.
NotImplementedException
();
...
...
src/SkyWalking.Core/Sampling/SamplingService.cs
View file @
546931b1
using
System.Threading.Tasks
;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using
System.Threading.Tasks
;
namespace
SkyWalking.Sampling
namespace
SkyWalking.Sampling
{
{
...
...
src/SkyWalking.Core/Utils/StackExtensions.cs
0 → 100644
View file @
546931b1
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using
System.Collections.Generic
;
namespace
SkyWalking.Utils
{
public
static
class
StackExtensions
{
public
static
bool
TryPeek
<
T
>(
this
Stack
<
T
>
stack
,
out
T
value
)
{
if
(
stack
==
null
||
stack
.
Count
==
0
)
{
value
=
default
(
T
);
return
false
;
}
value
=
stack
.
Peek
();
return
true
;
}
public
static
bool
TryPop
<
T
>(
this
Stack
<
T
>
stack
,
out
T
value
)
{
if
(
stack
==
null
||
stack
.
Count
==
0
)
{
value
=
default
(
T
);
return
false
;
}
value
=
stack
.
Pop
();
return
true
;
}
}
}
\ No newline at end of file
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