Commit a480234
authored
More precise metrics & logging (#4943)
In some cases, responses are generated by interceptors: 404 rejections
using `RejectInterceptor`, CORS preflight requests, not-acceptable
interceptor, exception interceptor. In most of these cases, there are no
`Endpoint`s that are associated with the requests.
Whatever the source of the response (endpoint invocation, decode
failure, 404 rejection), such responses should be handled by
interceptors such as logging & metrics.
To properly log such interceptor-generated (or more precisely:
`RequestHandler`-generated, without invoking an `EndpointHandler`)
responses, the log interceptor must know if the response was generated
by an endpoint, or request handler. This is achieved by adding an
additional field to `RequestResult.Response`.
The logging interceptor is enhanced by calling a new
`ServerLog.requestHandledByInterceptor` method, which should log the
interceptor-generated response. Moreover, the exception & logging
interceptors are combined, so that upon an exception, first an exception
is logged, then the exception is turned into a 500 response, and then
that response is logged as well.
The metrics interceptor is enhanced so that when a request is received,
there's always some callback on the `EndpointMetric` (returned by the
`Metric`) that is called - including interceptor-generated responses.
Finally, active-requests gauge/up-down counter is changed so that it
counts all requests. This also means that there's no endpoint-template
(path) label associated with the metric.
The ordering of interceptors is changed. Now, the metrics &
logging+exception interceptors come first, followed by CORS, reject &
not-acceptable.1 parent dbaa5e1 commit a480234
File tree
78 files changed
+1564
-448
lines changed- doc/server
- integrations/zio/src/test/scala/sttp/tapir/ztapir
- metrics
- datadog-metrics/src
- main/scala/sttp/tapir/server/metrics/datadog
- test/scala/sttp/tapir/server/metrics/datadog
- opentelemetry-metrics/src
- main/scala/sttp/tapir/server/metrics/opentelemetry
- test/scala/sttp/tapir/server/metrics/opentelemetry
- otel4s-metrics/src
- main/scala/sttp/tapir/server/metrics/otel4s
- test/scala/sttp/tapir/server/metrics/otel4s
- prometheus-metrics/src
- main/scala/sttp/tapir/server/metrics/prometheus
- test/scala/sttp/tapir/server/metrics/prometheus
- prometheus-simpleclient-metrics/src
- main/scala/sttp/tapir/server/metrics/prometheus_simpleclient
- test/scala/sttp/tapir/server/metrics/prometheus_simpleclient
- zio-metrics/src
- main/scala/sttp/tapir/server/metrics/zio
- test/scala/sttp/tapir/server/metrics/zio
- serverless/aws
- lambda-cats-effect-tests/src/test/scala/sttp/tapir/serverless/aws/lambda/tests
- lambda-core/src/main/scala/sttp/tapir/serverless/aws/lambda
- lambda-zio-tests/src/test/scala/sttp/tapir/serverless/aws/ziolambda/tests
- server
- akka-http-server/src/main/scala/sttp/tapir/server/akkahttp
- armeria-server
- cats/src/test/scala/sttp/tapir/server/armeria/cats
- src
- main/scala/sttp/tapir/server/armeria
- test/scala/sttp/tapir/server/armeria
- zio/src/test/scala/sttp/tapir/server/armeria/zio
- core/src
- main/scala/sttp/tapir/server
- interceptor
- cors
- exception
- log
- metrics
- reject
- interpreter
- metrics
- test/scala/sttp/tapir/server
- interceptor
- interpreter
- finatra-server/src/main/scala/sttp/tapir/server/finatra
- http4s-server/src/main/scala/sttp/tapir/server/http4s
- jdkhttp-server/src
- main/scala/sttp/tapir/server/jdkhttp
- test/scala/sttp/tapir/server/jdkhttp
- netty-server
- cats/src/main/scala/sttp/tapir/server/netty/cats
- src/main/scala/sttp/tapir/server/netty
- internal
- sync/src/main/scala/sttp/tapir/server/netty/sync
- zio/src/main/scala/sttp/tapir/server/netty/zio
- nima-server/src/main/scala/sttp/tapir/server/nima
- pekko-http-server/src/main/scala/sttp/tapir/server/pekkohttp
- play-server/src
- main/scala/sttp/tapir/server/play
- test/scala/sttp/tapir/server/play
- play29-server/src
- main/scala/sttp/tapir/server/play
- test/scala/sttp/tapir/server/play
- sttp-stub-server/src/main/scala/sttp/tapir/server/stub
- sttp-stub4-server/src/main/scala/sttp/tapir/server/stub4
- tests/src/main/scala/sttp/tapir/server/tests
- vertx-server
- cats/src
- main/scala/sttp/tapir/server/vertx/cats
- test/scala/sttp/tapir/server/vertx/cats
- src
- main/scala/sttp/tapir/server/vertx
- test/scala/sttp/tapir/server/vertx
- zio/src
- main/scala/sttp/tapir/server/vertx/zio
- test/scala/sttp/tapir/server/vertx/zio
- zio-http-server/src
- main/scala/sttp/tapir/server/ziohttp
- test/scala/sttp/tapir/server/ziohttp
- tracing
- opentelemetry-tracing/src/main/scala/sttp/tapir/server/tracing/opentelemetry
- otel4s-tracing/src/main/scala/sttp/tapir/server/tracing/otel4s
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
78 files changed
+1564
-448
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
25 | 37 | | |
26 | 38 | | |
27 | 39 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
32 | 44 | | |
33 | 45 | | |
34 | 46 | | |
35 | 47 | | |
36 | | - | |
37 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
38 | 55 | | |
39 | 56 | | |
40 | 57 | | |
41 | 58 | | |
42 | 59 | | |
43 | 60 | | |
44 | | - | |
45 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
46 | 66 | | |
47 | 67 | | |
48 | 68 | | |
| |||
83 | 103 | | |
84 | 104 | | |
85 | 105 | | |
86 | | - | |
| 106 | + | |
87 | 107 | | |
88 | 108 | | |
89 | 109 | | |
| |||
280 | 300 | | |
281 | 301 | | |
282 | 302 | | |
283 | | - | |
| 303 | + | |
| 304 | + | |
284 | 305 | | |
285 | 306 | | |
286 | 307 | | |
| |||
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
71 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
72 | 78 | | |
73 | 79 | | |
74 | 80 | | |
| |||
Lines changed: 41 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
| 70 | + | |
70 | 71 | | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
80 | 76 | | |
81 | 77 | | |
82 | 78 | | |
| |||
93 | 89 | | |
94 | 90 | | |
95 | 91 | | |
96 | | - | |
97 | | - | |
| 92 | + | |
| 93 | + | |
98 | 94 | | |
99 | 95 | | |
100 | 96 | | |
101 | 97 | | |
102 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
103 | 109 | | |
104 | 110 | | |
105 | 111 | | |
106 | 112 | | |
107 | | - | |
| 113 | + | |
108 | 114 | | |
109 | 115 | | |
110 | 116 | | |
| |||
133 | 139 | | |
134 | 140 | | |
135 | 141 | | |
136 | | - | |
137 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
138 | 146 | | |
139 | 147 | | |
140 | 148 | | |
| |||
144 | 152 | | |
145 | 153 | | |
146 | 154 | | |
147 | | - | |
148 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
149 | 159 | | |
150 | 160 | | |
151 | 161 | | |
152 | 162 | | |
153 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
154 | 177 | | |
155 | 178 | | |
156 | 179 | | |
157 | 180 | | |
158 | 181 | | |
159 | | - | |
| 182 | + | |
160 | 183 | | |
161 | 184 | | |
162 | 185 | | |
| |||
Lines changed: 13 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
| 96 | + | |
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
135 | | - | |
| 134 | + | |
| 135 | + | |
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
| 181 | + | |
181 | 182 | | |
182 | | - | |
| 183 | + | |
183 | 184 | | |
184 | 185 | | |
185 | | - | |
| 186 | + | |
186 | 187 | | |
187 | 188 | | |
188 | | - | |
| 189 | + | |
189 | 190 | | |
190 | 191 | | |
191 | 192 | | |
192 | 193 | | |
193 | | - | |
| 194 | + | |
194 | 195 | | |
195 | 196 | | |
196 | | - | |
| 197 | + | |
197 | 198 | | |
198 | 199 | | |
199 | | - | |
| 200 | + | |
200 | 201 | | |
201 | 202 | | |
202 | 203 | | |
203 | 204 | | |
204 | 205 | | |
205 | 206 | | |
206 | | - | |
| 207 | + | |
207 | 208 | | |
208 | 209 | | |
209 | 210 | | |
| |||
253 | 254 | | |
254 | 255 | | |
255 | 256 | | |
256 | | - | |
| 257 | + | |
257 | 258 | | |
258 | 259 | | |
259 | 260 | | |
| |||
Lines changed: 37 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
52 | | - | |
53 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
54 | 56 | | |
55 | 57 | | |
56 | 58 | | |
| |||
114 | 116 | | |
115 | 117 | | |
116 | 118 | | |
117 | | - | |
| 119 | + | |
| 120 | + | |
118 | 121 | | |
119 | | - | |
120 | | - | |
121 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
122 | 126 | | |
123 | 127 | | |
124 | 128 | | |
| |||
148 | 152 | | |
149 | 153 | | |
150 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
151 | 162 | | |
152 | 163 | | |
153 | 164 | | |
| |||
191 | 202 | | |
192 | 203 | | |
193 | 204 | | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
194 | 215 | | |
195 | 216 | | |
196 | 217 | | |
197 | 218 | | |
198 | 219 | | |
199 | | - | |
200 | | - | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
201 | 229 | | |
202 | 230 | | |
203 | 231 | | |
| |||
0 commit comments