|
@@ -226,46 +226,46 @@ func (t *Trace) TraceStart(method, path string, status l7.Status, duration time.
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Deprecated: use TraceEndEvent instead.
|
|
// Deprecated: use TraceEndEvent instead.
|
|
|
-func (t *Trace) TraceEnd(r *l7.RequestData) {
|
|
|
|
|
- if t == nil {
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- t.span.SetAttributes(
|
|
|
|
|
- semconv.HTTPStatusCode(int(r.Status)),
|
|
|
|
|
- attribute.String("server.trace_id_from", r.ParentSpanContext.TraceIdFrom),
|
|
|
|
|
- )
|
|
|
|
|
-
|
|
|
|
|
- CalledId, err := strconv.ParseInt(r.ParentSpanContext.CalledId, 10, 64)
|
|
|
|
|
- if err == nil && CalledId != 0 {
|
|
|
|
|
- t.span.SetAttributes(attribute.Int64("server.called_id", CalledId))
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- InstanceIdFrom, err := strconv.ParseInt(r.ParentSpanContext.InstanceIdFrom, 10, 64)
|
|
|
|
|
- if err == nil && InstanceIdFrom != 0 {
|
|
|
|
|
- t.span.SetAttributes(attribute.Int64("server.instance_id_from", InstanceIdFrom))
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- AppIdFrom, err := strconv.ParseInt(r.ParentSpanContext.AppIdFrom, 10, 64)
|
|
|
|
|
- if err == nil && AppIdFrom != 0 {
|
|
|
|
|
- t.span.SetAttributes(attribute.Int64("server.app_id_from", AppIdFrom))
|
|
|
|
|
- }
|
|
|
|
|
- if r.ParentSpanContext.SpanIdFrom != "0000000000000000" {
|
|
|
|
|
- t.span.SetAttributes(attribute.String("server.span_id_from", r.ParentSpanContext.SpanIdFrom))
|
|
|
|
|
- }
|
|
|
|
|
- // klog.Debugf("r.ParentSpanContext.TypeFrom tpp %s", r.ParentSpanContext.TypeFrom)
|
|
|
|
|
- if r.ParentSpanContext.TypeFrom == "10" {
|
|
|
|
|
- t.span.SetAttributes(attribute.String("server.type_from", "SDK"))
|
|
|
|
|
- t.span.SetAttributes(attribute.String("server.app_id_from", "-1"))
|
|
|
|
|
- t.span.SetAttributes(attribute.String("server.span_id_from", r.ParentSpanContext.TraceIdFrom))
|
|
|
|
|
- t.span.SetAttributes(attribute.String("server.instance_id_from", "-1"))
|
|
|
|
|
- t.span.SetAttributes(attribute.String("server.call_id", "-1"))
|
|
|
|
|
- }
|
|
|
|
|
- // for _, v := range t.stack {
|
|
|
|
|
- // fmt.Printf("TraceEndTraceEndTraceEnd%s\n", v)
|
|
|
|
|
- // }
|
|
|
|
|
- //t.buildFun()
|
|
|
|
|
- t.span.End(trace.WithTimestamp(time.Now()))
|
|
|
|
|
-}
|
|
|
|
|
|
|
+//func (t *Trace) TraceEnd(r *l7.RequestData) {
|
|
|
|
|
+// if t == nil {
|
|
|
|
|
+// return
|
|
|
|
|
+// }
|
|
|
|
|
+// t.span.SetAttributes(
|
|
|
|
|
+// semconv.HTTPStatusCode(int(r.Status)),
|
|
|
|
|
+// attribute.String("server.trace_id_from", r.ParentSpanContext.TraceIdFrom),
|
|
|
|
|
+// )
|
|
|
|
|
+//
|
|
|
|
|
+// CalledId, err := strconv.ParseInt(r.ParentSpanContext.CalledId, 10, 64)
|
|
|
|
|
+// if err == nil && CalledId != 0 {
|
|
|
|
|
+// t.span.SetAttributes(attribute.Int64("server.called_id", CalledId))
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// InstanceIdFrom, err := strconv.ParseInt(r.ParentSpanContext.InstanceIdFrom, 10, 64)
|
|
|
|
|
+// if err == nil && InstanceIdFrom != 0 {
|
|
|
|
|
+// t.span.SetAttributes(attribute.Int64("server.instance_id_from", InstanceIdFrom))
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// AppIdFrom, err := strconv.ParseInt(r.ParentSpanContext.AppIdFrom, 10, 64)
|
|
|
|
|
+// if err == nil && AppIdFrom != 0 {
|
|
|
|
|
+// t.span.SetAttributes(attribute.Int64("server.app_id_from", AppIdFrom))
|
|
|
|
|
+// }
|
|
|
|
|
+// if r.ParentSpanContext.SpanIdFrom != "0000000000000000" {
|
|
|
|
|
+// t.span.SetAttributes(attribute.String("server.span_id_from", r.ParentSpanContext.SpanIdFrom))
|
|
|
|
|
+// }
|
|
|
|
|
+// // klog.Debugf("r.ParentSpanContext.TypeFrom tpp %s", r.ParentSpanContext.TypeFrom)
|
|
|
|
|
+// if r.ParentSpanContext.TypeFrom == "10" {
|
|
|
|
|
+// t.span.SetAttributes(attribute.String("server.type_from", "SDK"))
|
|
|
|
|
+// t.span.SetAttributes(attribute.String("server.app_id_from", "-1"))
|
|
|
|
|
+// t.span.SetAttributes(attribute.String("server.span_id_from", r.ParentSpanContext.TraceIdFrom))
|
|
|
|
|
+// t.span.SetAttributes(attribute.String("server.instance_id_from", "-1"))
|
|
|
|
|
+// t.span.SetAttributes(attribute.String("server.call_id", "-1"))
|
|
|
|
|
+// }
|
|
|
|
|
+// // for _, v := range t.stack {
|
|
|
|
|
+// // fmt.Printf("TraceEndTraceEndTraceEnd%s\n", v)
|
|
|
|
|
+// // }
|
|
|
|
|
+// //t.buildFun()
|
|
|
|
|
+// t.span.End(trace.WithTimestamp(time.Now()))
|
|
|
|
|
+//}
|
|
|
|
|
|
|
|
// 新增结束事件
|
|
// 新增结束事件
|
|
|
func (t *Trace) TraceEndEvent(r *l7.RequestData) {
|
|
func (t *Trace) TraceEndEvent(r *l7.RequestData) {
|
|
@@ -298,7 +298,8 @@ func (t *Trace) TraceEndEvent(r *l7.RequestData) {
|
|
|
appIdFrom, err := strconv.ParseInt(r.ParentSpanContext.AppIdFrom, 10, 64)
|
|
appIdFrom, err := strconv.ParseInt(r.ParentSpanContext.AppIdFrom, 10, 64)
|
|
|
if err == nil && appIdFrom != 0 {
|
|
if err == nil && appIdFrom != 0 {
|
|
|
attr = append(attr, attribute.Int64("server.app_id_from", appIdFrom))
|
|
attr = append(attr, attribute.Int64("server.app_id_from", appIdFrom))
|
|
|
- //t.span.SetAttributes(attribute.Int64("server.app_id_from", AppIdFrom))
|
|
|
|
|
|
|
+ // Add type_from attribute for all cases
|
|
|
|
|
+ attr = append(attr, attribute.String("server.type_from", r.ParentSpanContext.TypeFrom.String()))
|
|
|
}
|
|
}
|
|
|
if r.ParentSpanContext.SpanIdFrom != "0000000000000000" {
|
|
if r.ParentSpanContext.SpanIdFrom != "0000000000000000" {
|
|
|
attr = append(attr, attribute.String("server.span_id_from", r.ParentSpanContext.SpanIdFrom))
|
|
attr = append(attr, attribute.String("server.span_id_from", r.ParentSpanContext.SpanIdFrom))
|
|
@@ -307,13 +308,10 @@ func (t *Trace) TraceEndEvent(r *l7.RequestData) {
|
|
|
|
|
|
|
|
// klog.Debugf("r.ParentSpanContext.TypeFrom event tpp %s", r.ParentSpanContext.TypeFrom)
|
|
// klog.Debugf("r.ParentSpanContext.TypeFrom event tpp %s", r.ParentSpanContext.TypeFrom)
|
|
|
if r.ParentSpanContext.TypeFrom == "10" {
|
|
if r.ParentSpanContext.TypeFrom == "10" {
|
|
|
- attr = append(attr, attribute.String("server.type_from", "SDK"))
|
|
|
|
|
attr = append(attr, attribute.String("server.app_id_from", "-1"))
|
|
attr = append(attr, attribute.String("server.app_id_from", "-1"))
|
|
|
attr = append(attr, attribute.String("server.span_id_from", r.ParentSpanContext.TraceIdFrom))
|
|
attr = append(attr, attribute.String("server.span_id_from", r.ParentSpanContext.TraceIdFrom))
|
|
|
attr = append(attr, attribute.String("server.instance_id_from", "-1"))
|
|
attr = append(attr, attribute.String("server.instance_id_from", "-1"))
|
|
|
attr = append(attr, attribute.String("server.call_id", "-1"))
|
|
attr = append(attr, attribute.String("server.call_id", "-1"))
|
|
|
- } else if r.ParentSpanContext.TypeFrom == "02" {
|
|
|
|
|
- attr = append(attr, attribute.String("server.type_from", "Nodejs"))
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
attr = append(attr, attribute.String("server.src_addr", r.DAddr.String()))
|
|
attr = append(attr, attribute.String("server.src_addr", r.DAddr.String()))
|