@@ -1014,68 +1014,96 @@ func testHTTPTracesNestedSelfCalls(t *testing.T) {
1014
1014
traces := tq .FindBySpan (jaeger.Tag {Key : "url.path" , Type : "string" , Value : "/api1" })
1015
1015
require .Len (t , traces , 1 )
1016
1016
trace = traces [0 ]
1017
- }, test .Interval (100 * time .Millisecond ))
1018
1017
1019
- // Check the information of the parent span
1020
- res := trace .FindByOperationName ("GET /api1" , "" )
1021
- require .Len (t , res , 1 )
1022
- server := res [0 ]
1023
- require .NotEmpty (t , server .TraceID )
1024
- require .NotEmpty (t , server .SpanID )
1025
- parentID = server .SpanID
1018
+ // Check the information of the parent span
1019
+ res := trace .FindByOperationName ("GET /api1" , "" )
1020
+ require .Len (t , res , 1 )
1021
+ server := res [0 ]
1022
+ require .NotEmpty (t , server .TraceID )
1023
+ require .NotEmpty (t , server .SpanID )
1024
+ parentID = server .SpanID
1026
1025
1027
- // check span attributes
1028
- sd := server .Diff (
1029
- jaeger.Tag {Key : "http.request.method" , Type : "string" , Value : "GET" },
1030
- jaeger.Tag {Key : "http.response.status_code" , Type : "int64" , Value : float64 (200 )},
1031
- jaeger.Tag {Key : "url.path" , Type : "string" , Value : "/api1" },
1032
- jaeger.Tag {Key : "server.port" , Type : "int64" , Value : float64 (7771 )},
1033
- jaeger.Tag {Key : "http.route" , Type : "string" , Value : "/api1" },
1034
- jaeger.Tag {Key : "span.kind" , Type : "string" , Value : "server" },
1035
- )
1036
- assert .Empty (t , sd , sd .String ())
1026
+ // check span attributes
1027
+ sd := server .Diff (
1028
+ jaeger.Tag {Key : "http.request.method" , Type : "string" , Value : "GET" },
1029
+ jaeger.Tag {Key : "http.response.status_code" , Type : "int64" , Value : float64 (200 )},
1030
+ jaeger.Tag {Key : "url.path" , Type : "string" , Value : "/api1" },
1031
+ jaeger.Tag {Key : "server.port" , Type : "int64" , Value : float64 (7771 )},
1032
+ jaeger.Tag {Key : "http.route" , Type : "string" , Value : "/api1" },
1033
+ jaeger.Tag {Key : "span.kind" , Type : "string" , Value : "server" },
1034
+ )
1035
+ assert .Empty (t , sd , sd .String ())
1037
1036
1038
- children := trace .ChildrenOf (parentID )
1039
- require .Len (t , children , 1 )
1040
- child := children [0 ]
1037
+ children := trace .ChildrenOf (parentID )
1038
+ require .GreaterOrEqual (t , len (children ), 1 )
1041
1039
1042
- sd = child .Diff (
1043
- jaeger.Tag {Key : "http.request.method" , Type : "string" , Value : "GET" },
1044
- jaeger.Tag {Key : "http.response.status_code" , Type : "int64" , Value : float64 (200 )},
1045
- jaeger.Tag {Key : "url.path" , Type : "string" , Value : "/api2" },
1046
- jaeger.Tag {Key : "server.port" , Type : "int64" , Value : float64 (7772 )},
1047
- jaeger.Tag {Key : "http.route" , Type : "string" , Value : "/api2" },
1048
- jaeger.Tag {Key : "span.kind" , Type : "string" , Value : "server" },
1049
- )
1050
- assert .Empty (t , sd , sd .String ())
1040
+ // We've created the in-queue and processing spans
1041
+ for _ , c := range children {
1042
+ children = trace .ChildrenOf (c .SpanID )
1043
+ if len (children ) > 0 {
1044
+ break
1045
+ }
1046
+ }
1051
1047
1052
- children = trace .ChildrenOf (child .SpanID )
1053
- require .Len (t , children , 1 )
1054
- child = children [0 ]
1048
+ require .Len (t , children , 1 )
1049
+ child := children [0 ]
1055
1050
1056
- sd = child .Diff (
1057
- jaeger.Tag {Key : "http.request.method" , Type : "string" , Value : "GET" },
1058
- jaeger.Tag {Key : "http.response.status_code" , Type : "int64" , Value : float64 (200 )},
1059
- jaeger.Tag {Key : "url.path" , Type : "string" , Value : "/api3 " },
1060
- jaeger.Tag {Key : "server.port" , Type : "int64" , Value : float64 (7773 )},
1061
- jaeger.Tag {Key : "http.route" , Type : "string" , Value : "/api3 " },
1062
- jaeger.Tag {Key : "span.kind" , Type : "string" , Value : "server" },
1063
- )
1064
- assert .Empty (t , sd , sd .String ())
1051
+ sd = child .Diff (
1052
+ jaeger.Tag {Key : "http.request.method" , Type : "string" , Value : "GET" },
1053
+ jaeger.Tag {Key : "http.response.status_code" , Type : "int64" , Value : float64 (200 )},
1054
+ jaeger.Tag {Key : "url.path" , Type : "string" , Value : "/api2 " },
1055
+ jaeger.Tag {Key : "server.port" , Type : "int64" , Value : float64 (7772 )},
1056
+ jaeger.Tag {Key : "http.route" , Type : "string" , Value : "/api2 " },
1057
+ jaeger.Tag {Key : "span.kind" , Type : "string" , Value : "server" },
1058
+ )
1059
+ assert .Empty (t , sd , sd .String ())
1065
1060
1066
- children = trace .ChildrenOf (child .SpanID )
1067
- require .Len (t , children , 1 )
1068
- child = children [0 ]
1061
+ children = trace .ChildrenOf (child .SpanID )
1062
+ require .GreaterOrEqual (t , len (children ), 1 )
1069
1063
1070
- sd = child .Diff (
1071
- jaeger.Tag {Key : "http.request.method" , Type : "string" , Value : "GET" },
1072
- jaeger.Tag {Key : "http.response.status_code" , Type : "int64" , Value : float64 (200 )},
1073
- jaeger.Tag {Key : "url.path" , Type : "string" , Value : "/api4" },
1074
- jaeger.Tag {Key : "server.port" , Type : "int64" , Value : float64 (7774 )},
1075
- jaeger.Tag {Key : "http.route" , Type : "string" , Value : "/api4" },
1076
- jaeger.Tag {Key : "span.kind" , Type : "string" , Value : "server" },
1077
- )
1078
- assert .Empty (t , sd , sd .String ())
1064
+ for _ , c := range children {
1065
+ children = trace .ChildrenOf (c .SpanID )
1066
+ if len (children ) > 0 {
1067
+ break
1068
+ }
1069
+ }
1070
+
1071
+ require .Len (t , children , 1 )
1072
+ child = children [0 ]
1073
+
1074
+ sd = child .Diff (
1075
+ jaeger.Tag {Key : "http.request.method" , Type : "string" , Value : "GET" },
1076
+ jaeger.Tag {Key : "http.response.status_code" , Type : "int64" , Value : float64 (200 )},
1077
+ jaeger.Tag {Key : "url.path" , Type : "string" , Value : "/api3" },
1078
+ jaeger.Tag {Key : "server.port" , Type : "int64" , Value : float64 (7773 )},
1079
+ jaeger.Tag {Key : "http.route" , Type : "string" , Value : "/api3" },
1080
+ jaeger.Tag {Key : "span.kind" , Type : "string" , Value : "server" },
1081
+ )
1082
+ assert .Empty (t , sd , sd .String ())
1083
+
1084
+ children = trace .ChildrenOf (child .SpanID )
1085
+ require .GreaterOrEqual (t , len (children ), 1 )
1086
+
1087
+ for _ , c := range children {
1088
+ children = trace .ChildrenOf (c .SpanID )
1089
+ if len (children ) > 0 {
1090
+ break
1091
+ }
1092
+ }
1093
+
1094
+ require .Len (t , children , 1 )
1095
+ child = children [0 ]
1096
+
1097
+ sd = child .Diff (
1098
+ jaeger.Tag {Key : "http.request.method" , Type : "string" , Value : "GET" },
1099
+ jaeger.Tag {Key : "http.response.status_code" , Type : "int64" , Value : float64 (200 )},
1100
+ jaeger.Tag {Key : "url.path" , Type : "string" , Value : "/api4" },
1101
+ jaeger.Tag {Key : "server.port" , Type : "int64" , Value : float64 (7774 )},
1102
+ jaeger.Tag {Key : "http.route" , Type : "string" , Value : "/api4" },
1103
+ jaeger.Tag {Key : "span.kind" , Type : "string" , Value : "server" },
1104
+ )
1105
+ assert .Empty (t , sd , sd .String ())
1106
+ }, test .Interval (100 * time .Millisecond ))
1079
1107
}
1080
1108
1081
1109
func testHTTPTracesNestedNodeJSDistCalls (t * testing.T ) {
@@ -1121,6 +1149,31 @@ func testHTTPTracesNestedNodeJSDistCalls(t *testing.T) {
1121
1149
assert .Empty (t , sd , sd .String ())
1122
1150
1123
1151
children := trace .ChildrenOf (parentID )
1152
+ require .GreaterOrEqual (t , len (children ), 2 )
1153
+
1154
+ res = trace .FindByOperationName ("processing" , "internal" )
1155
+
1156
+ var processing * jaeger.Span
1157
+
1158
+ if len (res ) > 0 {
1159
+ for i := range res {
1160
+ r := & res [i ]
1161
+ // Check parenthood
1162
+ p , ok := trace .ParentOf (r )
1163
+
1164
+ if ok {
1165
+ if p .TraceID == server .TraceID && p .SpanID == server .SpanID {
1166
+ processing = r
1167
+ break
1168
+ }
1169
+ }
1170
+ }
1171
+ }
1172
+
1173
+ if processing != nil {
1174
+ children = trace .ChildrenOf (processing .SpanID )
1175
+ }
1176
+
1124
1177
require .Len (t , children , 3 )
1125
1178
1126
1179
seenP := false
0 commit comments