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
30cca08f
Commit
30cca08f
authored
Apr 01, 2018
by
Liuhaoyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update TraceSegment
parent
9e072620
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
116 additions
and
0 deletions
+116
-0
TraceSegment.cs
src/SkyWalking.Core/Context/Trace/TraceSegment.cs
+116
-0
No files found.
src/SkyWalking.Core/Context/Trace/TraceSegment.cs
0 → 100644
View file @
30cca08f
/*
* 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.Linq
;
using
Google.Protobuf
;
using
SkyWalking.Config
;
using
SkyWalking.Context.Ids
;
using
SkyWalking.NetworkProtocol
;
namespace
SkyWalking.Context.Trace
{
public
class
TraceSegment
:
ITraceSegment
{
private
readonly
IList
<
ITraceSegmentRef
>
_refs
;
private
readonly
IList
<
AbstractTracingSpan
>
_spans
;
private
readonly
DistributedTraceIdCollection
_relatedGlobalTraces
;
private
bool
_isSizeLimited
=
false
;
public
int
ApplicationId
=>
RemoteDownstreamConfig
.
Agent
.
ApplicationId
;
public
int
ApplicationInstanceId
=>
RemoteDownstreamConfig
.
Agent
.
ApplicationInstanceId
;
public
IEnumerable
<
ITraceSegmentRef
>
Refs
=>
_refs
;
public
IEnumerable
<
DistributedTraceId
>
RelatedGlobalTraces
{
get
;
}
public
ID
TraceSegmentId
{
get
;
}
public
bool
HasRef
=>
_refs
.
Count
>
0
;
public
bool
IsIgnore
{
get
;
set
;
}
public
bool
IsSingleSpanSegment
=>
_spans
.
Count
==
1
;
public
TraceSegment
()
{
TraceSegmentId
=
GlobalIdGenerator
.
Generate
();
_spans
=
new
List
<
AbstractTracingSpan
>();
_relatedGlobalTraces
=
new
DistributedTraceIdCollection
();
_relatedGlobalTraces
.
Append
(
new
NewDistributedTraceId
());
_refs
=
new
List
<
ITraceSegmentRef
>();
}
public
void
Archive
(
AbstractTracingSpan
finishedSpan
)
{
_spans
.
Add
(
finishedSpan
);
}
public
ITraceSegment
Finish
(
bool
isSizeLimited
)
{
_isSizeLimited
=
isSizeLimited
;
return
this
;
}
/// <summary>
/// Establish the link between this segment and its parents.
/// </summary>
public
void
Ref
(
ITraceSegmentRef
refSegment
)
{
if
(!
_refs
.
Contains
(
refSegment
))
{
_refs
.
Add
(
refSegment
);
}
}
public
void
RelatedGlobalTrace
(
DistributedTraceId
distributedTraceId
)
{
_relatedGlobalTraces
.
Append
(
distributedTraceId
);
}
public
UpstreamSegment
Transform
()
{
var
upstreamSegment
=
new
UpstreamSegment
();
upstreamSegment
.
GlobalTraceIds
.
AddRange
(
_relatedGlobalTraces
.
GetRelatedGlobalTraces
()
.
Select
(
x
=>
x
.
ToUniqueId
()));
var
traceSegment
=
new
TraceSegmentObject
{
TraceSegmentId
=
TraceSegmentId
.
Transform
()};
traceSegment
.
Spans
.
AddRange
(
_spans
.
Select
(
x
=>
x
.
Transform
()));
traceSegment
.
ApplicationId
=
ApplicationId
;
traceSegment
.
ApplicationInstanceId
=
ApplicationInstanceId
;
traceSegment
.
IsSizeLimited
=
_isSizeLimited
;
upstreamSegment
.
Segment
=
traceSegment
.
ToByteString
();
return
upstreamSegment
;
}
public
override
string
ToString
()
{
return
"TraceSegment{"
+
$"traceSegmentId='
{
TraceSegmentId
}
', refs=
{
_refs
}
, spans=
{
_spans
}
, relatedGlobalTraces=
{
_relatedGlobalTraces
}
"
+
"}"
;
}
}
}
\ 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