@@ -47,114 +47,97 @@ class ArmeriaHttpServerTracingSpec extends WordSpec
47
47
48
48
val webClient = newWebClient(protocol,port)
49
49
50
- s " The Armeria $protocol server " should {
51
-
52
- " create a server Span when receiving requests" in {
53
- val target = s " $protocol:// $interface: $port/ $usersEndpoint"
54
- val expected = " /users"
55
-
56
- val request = HttpRequest .of(RequestHeaders .of(HttpMethod .GET , usersEndpoint))
57
- webClient.execute(request)
58
-
59
- eventually(timeout(3 seconds)) {
60
- val span = testSpanReporter().nextSpan().value
61
- span.operationName shouldBe expected
62
- span.tags.get(plain(" http.url" )) shouldBe target
63
- span.metricTags.get(plain(" component" )) shouldBe " armeria.http.server"
64
- span.metricTags.get(plain(" http.method" )) shouldBe " GET"
65
- span.metricTags.get(plainLong(" http.status_code" )) shouldBe 200L
66
- }
67
- }
50
+ s " The Armeria $protocol server " when {
68
51
69
- " set operation name with unhandled" when {
70
- " request path doesn't exists" in {
71
- val target = s " $protocol:// $interface: $port/ $pathNotFoundEndpoint"
72
- val expected = " unhandled"
52
+ " Non blocking route" should {
73
53
74
- val request = HttpRequest .of(RequestHeaders .of(HttpMethod .GET , pathNotFoundEndpoint))
75
- webClient.execute(request)
54
+ " create a server Span when receiving requests" in {
55
+ val target = s " $protocol:// $interface: $port/ $usersEndpoint"
56
+ val expected = " /users"
57
+
58
+ val request = HttpRequest .of(RequestHeaders .of(HttpMethod .GET , usersEndpoint))
59
+ webClient.execute(request)
76
60
77
61
eventually(timeout(3 seconds)) {
78
62
val span = testSpanReporter().nextSpan().value
79
63
span.operationName shouldBe expected
80
64
span.tags.get(plain(" http.url" )) shouldBe target
81
65
span.metricTags.get(plain(" component" )) shouldBe " armeria.http.server"
82
66
span.metricTags.get(plain(" http.method" )) shouldBe " GET"
83
- span.metricTags.get(plainBoolean(" error" )) shouldBe false
84
- span.metricTags.get(plainLong(" http.status_code" )) shouldBe 404
67
+ span.metricTags.get(plainLong(" http.status_code" )) shouldBe 200L
85
68
}
86
69
}
87
- }
88
70
89
- " set operation name with path + http method" when {
90
- " resource doesn't exist" in {
91
- val target = s " $protocol:// $interface: $port/ $usersEndpoint/not-found "
92
- val expected = " /users/{}"
71
+ " set operation name with unhandled" when {
72
+ " request path doesn't exists" in {
73
+ val target = s " $protocol:// $interface: $port/ $pathNotFoundEndpoint"
74
+ val expected = " unhandled"
75
+
76
+ val request = HttpRequest .of(RequestHeaders .of(HttpMethod .GET , pathNotFoundEndpoint))
77
+ webClient.execute(request)
78
+
79
+ eventually(timeout(3 seconds)) {
80
+ val span = testSpanReporter().nextSpan().value
81
+ span.operationName shouldBe expected
82
+ span.tags.get(plain(" http.url" )) shouldBe target
83
+ span.metricTags.get(plain(" component" )) shouldBe " armeria.http.server"
84
+ span.metricTags.get(plain(" http.method" )) shouldBe " GET"
85
+ span.metricTags.get(plainBoolean(" error" )) shouldBe false
86
+ span.metricTags.get(plainLong(" http.status_code" )) shouldBe 404
87
+ }
88
+ }
89
+ }
93
90
94
- val request = HttpRequest .of(RequestHeaders .of(HttpMethod .GET , s " $usersEndpoint/not-found " ))
95
- webClient.execute(request)
91
+ " set operation name with path + http method" when {
92
+ " resource doesn't exist" in {
93
+ val target = s " $protocol:// $interface: $port/ $usersEndpoint/not-found "
94
+ val expected = " /users/{}"
95
+
96
+ val request = HttpRequest .of(RequestHeaders .of(HttpMethod .GET , s " $usersEndpoint/not-found " ))
97
+ webClient.execute(request)
98
+
99
+ eventually(timeout(3 seconds)) {
100
+ val span = testSpanReporter().nextSpan().value
101
+ span.operationName shouldBe expected
102
+ span.tags.get(plain(" http.url" )) shouldBe target
103
+ span.metricTags.get(plain(" component" )) shouldBe " armeria.http.server"
104
+ span.metricTags.get(plain(" http.method" )) shouldBe " GET"
105
+ span.metricTags.get(plainBoolean(" error" )) shouldBe false
106
+ span.metricTags.get(plainLong(" http.status_code" )) shouldBe 404
107
+ }
108
+ }
109
+ }
110
+
111
+ " not include path variables names" in {
112
+ val expected = " /users/{}/accounts/{}"
113
+
114
+ val request = HttpRequest .of(RequestHeaders .of(HttpMethod .GET , userAccountEndpoint))
115
+ webClient.execute(request)
96
116
97
117
eventually(timeout(3 seconds)) {
98
118
val span = testSpanReporter().nextSpan().value
99
119
span.operationName shouldBe expected
100
- span.tags.get(plain(" http.url" )) shouldBe target
101
- span.metricTags.get(plain(" component" )) shouldBe " armeria.http.server"
102
- span.metricTags.get(plain(" http.method" )) shouldBe " GET"
103
- span.metricTags.get(plainBoolean(" error" )) shouldBe false
104
- span.metricTags.get(plainLong(" http.status_code" )) shouldBe 404
105
120
}
106
121
}
107
- }
108
-
109
- " not include path variables names" in {
110
- val expected = " /users/{}/accounts/{}"
111
-
112
- val request = HttpRequest .of(RequestHeaders .of(HttpMethod .GET , userAccountEndpoint))
113
- webClient.execute(request)
114
122
115
- eventually(timeout(3 seconds)) {
116
- val span = testSpanReporter().nextSpan().value
117
- span.operationName shouldBe expected
118
- }
119
- }
123
+ " not fail when request url contains special regexp chars" in {
124
+ val expected = " /users/{}/accounts/{}"
120
125
121
- " not fail when request url contains special regexp chars " in {
122
- val expected = " /users/{}/accounts/{} "
126
+ val request = HttpRequest .of( RequestHeaders .of( HttpMethod . GET , s " $userAccountEndpoint ** " ))
127
+ val response = webClient.execute(request).aggregate().get()
123
128
124
- val request = HttpRequest .of(RequestHeaders .of(HttpMethod .GET , s " $userAccountEndpoint** " ))
125
- val response = webClient.execute(request).aggregate().get()
126
-
127
- eventually(timeout(3 seconds)) {
128
- val span = testSpanReporter().nextSpan().value
129
- span.operationName shouldBe expected
130
- response.status().code() shouldBe 200
131
- }
132
- }
133
-
134
- " mark spans as failed when request fails" in {
135
- val target = s " $protocol:// $interface: $port/ $usersEndpoint/error "
136
- val expected = " /users/{}"
137
-
138
- val request = HttpRequest .of(RequestHeaders .of(HttpMethod .GET , s " $usersEndpoint/error " ))
139
- webClient.execute(request)
140
-
141
- eventually(timeout(3 seconds)) {
142
- val span = testSpanReporter().nextSpan().value
143
- span.operationName shouldBe expected
144
- span.tags.get(plain(" http.url" )) shouldBe target
145
- span.metricTags.get(plain(" component" )) shouldBe " armeria.http.server"
146
- span.metricTags.get(plain(" http.method" )) shouldBe " GET"
147
- span.metricTags.get(plainBoolean(" error" )) shouldBe true
148
- span.metricTags.get(plainLong(" http.status_code" )) shouldBe 500
129
+ eventually(timeout(3 seconds)) {
130
+ val span = testSpanReporter().nextSpan().value
131
+ span.operationName shouldBe expected
132
+ response.status().code() shouldBe 200
133
+ }
149
134
}
150
- }
151
135
152
- " return a redirect status code" when {
153
- " a request to /docs is redirected to /docs/" in {
154
- val target = s " $protocol:// $interface: $port/ $docsEndpoint"
155
- val expected = s " /docs "
136
+ " mark spans as failed when request fails" in {
137
+ val target = s " $protocol:// $interface: $port/ $usersEndpoint/error "
138
+ val expected = " /users/{}"
156
139
157
- val request = HttpRequest .of(RequestHeaders .of(HttpMethod .GET , docsEndpoint ))
140
+ val request = HttpRequest .of(RequestHeaders .of(HttpMethod .GET , s " $usersEndpoint /error " ))
158
141
webClient.execute(request)
159
142
160
143
eventually(timeout(3 seconds)) {
@@ -163,17 +146,57 @@ class ArmeriaHttpServerTracingSpec extends WordSpec
163
146
span.tags.get(plain(" http.url" )) shouldBe target
164
147
span.metricTags.get(plain(" component" )) shouldBe " armeria.http.server"
165
148
span.metricTags.get(plain(" http.method" )) shouldBe " GET"
166
- span.metricTags.get(plainLong(" http.status_code" )) shouldBe 307L
149
+ span.metricTags.get(plainBoolean(" error" )) shouldBe true
150
+ span.metricTags.get(plainLong(" http.status_code" )) shouldBe 500
151
+ }
152
+ }
153
+
154
+ " return a redirect status code" when {
155
+ " a request to /docs is redirected to /docs/" in {
156
+ val target = s " $protocol:// $interface: $port/ $docsEndpoint"
157
+ val expected = s " /docs "
158
+
159
+ val request = HttpRequest .of(RequestHeaders .of(HttpMethod .GET , docsEndpoint))
160
+ webClient.execute(request)
161
+
162
+ eventually(timeout(3 seconds)) {
163
+ val span = testSpanReporter().nextSpan().value
164
+ span.operationName shouldBe expected
165
+ span.tags.get(plain(" http.url" )) shouldBe target
166
+ span.metricTags.get(plain(" component" )) shouldBe " armeria.http.server"
167
+ span.metricTags.get(plain(" http.method" )) shouldBe " GET"
168
+ span.metricTags.get(plainLong(" http.status_code" )) shouldBe 307L
169
+ }
170
+ }
171
+ }
172
+
173
+ " return a ok status code " when {
174
+ " a request to /docs/ is done" in {
175
+ val target = s " $protocol:// $interface: $port/ $docsEndpoint/ "
176
+ val expected = s " /docs "
177
+
178
+ val request = HttpRequest .of(RequestHeaders .of(HttpMethod .GET , s " $docsEndpoint/ " ))
179
+ webClient.execute(request)
180
+
181
+ eventually(timeout(3 seconds)) {
182
+ val span = testSpanReporter().nextSpan().value
183
+ span.operationName shouldBe expected
184
+ span.tags.get(plain(" http.url" )) shouldBe target
185
+ span.metricTags.get(plain(" component" )) shouldBe " armeria.http.server"
186
+ span.metricTags.get(plain(" http.method" )) shouldBe " GET"
187
+ span.metricTags.get(plainLong(" http.status_code" )) shouldBe 200L
188
+ }
167
189
}
168
190
}
169
191
}
170
192
171
- " return a ok status code " when {
172
- " a request to /docs/ is done" in {
173
- val target = s " $protocol:// $interface: $port/ $docsEndpoint/ "
174
- val expected = s " /docs "
193
+ " Blocking route" should {
194
+
195
+ " create a server Span when receiving requests" in {
196
+ val target = s " $protocol:// $interface: $port/ $usersBlockingEndpoint"
197
+ val expected = " /users-blocking"
175
198
176
- val request = HttpRequest .of(RequestHeaders .of(HttpMethod .GET , s " $docsEndpoint / " ))
199
+ val request = HttpRequest .of(RequestHeaders .of(HttpMethod .GET , usersBlockingEndpoint ))
177
200
webClient.execute(request)
178
201
179
202
eventually(timeout(3 seconds)) {
0 commit comments