Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
SkyAPM
go2sky
提交
3de27ea6
G
go2sky
项目概览
SkyAPM
/
go2sky
通知
2
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
go2sky
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
3de27ea6
编写于
3月 02, 2020
作者:
Z
zhang-wei
提交者:
GitHub
3月 02, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix entryEndpointId & parentEndpointId bug (#44)
* fix ParentEndpointID bug * language
上级
f10048c7
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
66 addition
and
8 deletion
+66
-8
noop.go
noop.go
+12
-0
propagation/propagation.go
propagation/propagation.go
+1
-1
reporter/grpc.go
reporter/grpc.go
+5
-0
segment.go
segment.go
+4
-0
span.go
span.go
+15
-0
trace.go
trace.go
+29
-7
未找到文件。
noop.go
浏览文件 @
3de27ea6
...
...
@@ -29,6 +29,10 @@ type NoopSpan struct {
func
(
*
NoopSpan
)
SetOperationName
(
string
)
{
}
func
(
*
NoopSpan
)
GetOperationName
()
string
{
return
""
}
func
(
*
NoopSpan
)
SetPeer
(
string
)
{
}
...
...
@@ -49,3 +53,11 @@ func (*NoopSpan) Error(time.Time, ...string) {
func
(
*
NoopSpan
)
End
()
{
}
func
(
*
NoopSpan
)
IsEntry
()
bool
{
return
false
}
func
(
*
NoopSpan
)
IsExit
()
bool
{
return
false
}
propagation/propagation.go
浏览文件 @
3de27ea6
...
...
@@ -181,7 +181,7 @@ func globalIDConvertString(id []int64) string {
}
func
encodeCompressedField
(
id
int32
,
text
string
)
string
{
if
id
>
0
{
if
id
!=
0
{
return
base64
.
StdEncoding
.
EncodeToString
([]
byte
(
fmt
.
Sprint
(
id
)))
}
return
base64
.
StdEncoding
.
EncodeToString
([]
byte
(
"#"
+
text
))
...
...
reporter/grpc.go
浏览文件 @
3de27ea6
...
...
@@ -162,6 +162,11 @@ func (r *gRPCReporter) registerInstance(name string) error {
props
=
append
(
props
,
kv
)
}
}
language
:=
&
common
.
KeyStringValuePair
{
Key
:
"language"
,
Value
:
"go"
,
}
props
=
append
(
props
,
language
)
in
:=
&
register
.
ServiceInstances
{
Instances
:
[]
*
register
.
ServiceInstance
{
{
...
...
segment.go
浏览文件 @
3de27ea6
...
...
@@ -54,6 +54,7 @@ type SegmentContext struct {
collect
chan
<-
ReportedSpan
refNum
*
int32
spanIDGenerator
*
int32
FirstSpan
Span
`json:"-"`
}
func
(
ctx
SegmentContext
)
GetReadableGlobalTraceID
()
string
{
...
...
@@ -180,6 +181,9 @@ func (s *segmentSpanImpl) createSegmentContext(parent segmentSpan) {
s
.
ParentSpanID
=
s
.
SpanID
s
.
SpanID
=
atomic
.
AddInt32
(
s
.
Context
()
.
spanIDGenerator
,
1
)
}
if
s
.
SegmentContext
.
FirstSpan
==
nil
{
s
.
SegmentContext
.
FirstSpan
=
s
}
}
type
rootSegmentSpan
struct
{
...
...
span.go
浏览文件 @
3de27ea6
...
...
@@ -42,6 +42,7 @@ const (
// Span interface as common span specification
type
Span
interface
{
SetOperationName
(
string
)
GetOperationName
()
string
SetPeer
(
string
)
SetSpanLayer
(
common
.
SpanLayer
)
SetComponent
(
int32
)
...
...
@@ -49,6 +50,8 @@ type Span interface {
Log
(
time
.
Time
,
...
string
)
Error
(
time
.
Time
,
...
string
)
End
()
IsEntry
()
bool
IsExit
()
bool
}
func
newLocalSpan
(
t
*
Tracer
)
*
defaultSpan
{
...
...
@@ -80,6 +83,10 @@ func (ds *defaultSpan) SetOperationName(name string) {
ds
.
OperationName
=
name
}
func
(
ds
*
defaultSpan
)
GetOperationName
()
string
{
return
ds
.
OperationName
}
func
(
ds
*
defaultSpan
)
SetPeer
(
peer
string
)
{
ds
.
Peer
=
peer
}
...
...
@@ -122,6 +129,14 @@ func (ds *defaultSpan) End() {
ds
.
EndTime
=
time
.
Now
()
}
func
(
ds
*
defaultSpan
)
IsEntry
()
bool
{
return
ds
.
SpanType
==
SpanTypeEntry
}
func
(
ds
*
defaultSpan
)
IsExit
()
bool
{
return
ds
.
SpanType
==
SpanTypeExit
}
// SpanOption allows for functional options to adjust behaviour
// of a Span to be created by CreateLocalSpan
type
SpanOption
func
(
s
*
defaultSpan
)
...
...
trace.go
浏览文件 @
3de27ea6
...
...
@@ -34,6 +34,8 @@ const (
errParameter
=
tool
.
Error
(
"parameter are nil"
)
EmptyTraceID
=
"N/A"
NoopTraceID
=
"[Ignored Trace]"
// -1 represent the object doesn't exist.
Inexistence
=
-
1
)
// Tracer is go2sky tracer implementation.
...
...
@@ -193,17 +195,37 @@ func (t *Tracer) CreateExitSpan(ctx context.Context, operationName string, peer
spanContext
.
ParentSegmentID
=
span
.
Context
()
.
SegmentID
spanContext
.
NetworkAddress
=
peer
spanContext
.
ParentServiceInstanceID
=
t
.
instanceID
spanContext
.
EntryServiceInstanceID
=
t
.
instanceID
spanContext
.
EntryEndpoint
=
operationName
spanContext
.
ParentEndpoint
=
operationName
// Since 6.6.0, if first span is not entry span, then this is an internal segment(no RPC), rather than an endpoint.
// EntryEndpoint
firstSpan
:=
span
.
Context
()
.
FirstSpan
firstSpanOperationName
:=
firstSpan
.
GetOperationName
()
ref
,
ok
:=
ctx
.
Value
(
refKeyInstance
)
.
(
*
propagation
.
SpanContext
)
var
entryEndpoint
=
""
var
entryServiceInstanceID
int32
=
0
if
ok
&&
ref
!=
nil
{
spanContext
.
Sample
=
ref
.
Sample
spanContext
.
ParentEndpoint
=
ref
.
ParentEndpoint
spanContext
.
EntryServiceInstanceID
=
ref
.
EntryServiceInstanceID
spanContext
.
EntryEndpoint
=
ref
.
EntryEndpoint
spanContext
.
EntryEndpointID
=
ref
.
EntryEndpointID
entryEndpoint
=
ref
.
EntryEndpoint
entryServiceInstanceID
=
ref
.
EntryServiceInstanceID
}
else
{
if
firstSpan
.
IsEntry
()
{
entryEndpoint
=
firstSpanOperationName
}
else
{
spanContext
.
EntryEndpointID
=
Inexistence
}
entryServiceInstanceID
=
t
.
instanceID
}
spanContext
.
EntryServiceInstanceID
=
entryServiceInstanceID
if
entryEndpoint
!=
""
{
spanContext
.
EntryEndpoint
=
entryEndpoint
}
// ParentEndpoint
if
firstSpan
.
IsEntry
()
&&
firstSpanOperationName
!=
""
{
spanContext
.
ParentEndpoint
=
firstSpanOperationName
}
else
{
spanContext
.
ParentEndpointID
=
Inexistence
}
err
=
injector
(
spanContext
.
EncodeSW6
())
if
err
!=
nil
{
return
nil
,
err
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录