2020-07-02 21:24:12 +00:00
|
|
|
/*
|
|
|
|
Mangadex@Home
|
|
|
|
Copyright (c) 2020, MangaDex Network
|
|
|
|
This file is part of MangaDex@Home.
|
|
|
|
|
|
|
|
MangaDex@Home is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
MangaDex@Home is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this MangaDex@Home. If not, see <http://www.gnu.org/licenses/>.
|
2021-01-25 02:25:49 +00:00
|
|
|
*/
|
2021-01-24 04:55:11 +00:00
|
|
|
package mdnet.metrics
|
2020-07-02 21:24:12 +00:00
|
|
|
|
2021-01-24 04:55:11 +00:00
|
|
|
import org.http4k.core.HttpTransaction
|
|
|
|
import org.http4k.filter.HttpTransactionLabeler
|
2020-07-02 21:24:12 +00:00
|
|
|
|
2021-01-24 04:55:11 +00:00
|
|
|
class PostTransactionLabeler : HttpTransactionLabeler {
|
|
|
|
override fun invoke(transaction: HttpTransaction): HttpTransaction {
|
|
|
|
return transaction.copy(
|
|
|
|
labels = mapOf(
|
|
|
|
"method" to transaction.request.method.toString(),
|
|
|
|
"status" to transaction.response.status.code.toString(),
|
|
|
|
"path" to transaction.routingGroup,
|
2021-07-06 17:12:37 +00:00
|
|
|
"cache" to (transaction.response.header("X-Cache") ?: "MISS").uppercase()
|
2021-01-24 04:55:11 +00:00
|
|
|
)
|
|
|
|
)
|
2020-08-11 16:47:04 +00:00
|
|
|
}
|
|
|
|
}
|