mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
observe failed digest-score api call lantency in prometheus too
This commit is contained in:
parent
550cef241c
commit
ad88cbaea8
2 changed files with 6 additions and 6 deletions
|
|
@ -248,7 +248,7 @@ const rankCandidates = async (
|
|||
const scores = await scoreClient.getScores(data)
|
||||
// update scores for candidates
|
||||
candidates.forEach((item) => {
|
||||
item.score = scores[item.id]['score'] || 0
|
||||
item.score = scores[item.id].score || 0
|
||||
})
|
||||
|
||||
// rank candidates by score in descending order
|
||||
|
|
|
|||
|
|
@ -75,9 +75,9 @@ class ScoreClientImpl implements ScoreClient {
|
|||
}
|
||||
|
||||
async getScores(data: ScoreApiRequestBody): Promise<ScoreApiResponse> {
|
||||
try {
|
||||
const start = Date.now()
|
||||
const start = Date.now()
|
||||
|
||||
try {
|
||||
const response = await axios.post<ScoreApiResponse>(this.apiUrl, data, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
|
@ -85,9 +85,6 @@ class ScoreClientImpl implements ScoreClient {
|
|||
timeout: 5000,
|
||||
})
|
||||
|
||||
const duration = (Date.now() - start) / 1000 // in seconds
|
||||
latency.observe(duration)
|
||||
|
||||
return response.data
|
||||
} catch (error) {
|
||||
logError(error)
|
||||
|
|
@ -96,6 +93,9 @@ class ScoreClientImpl implements ScoreClient {
|
|||
return {
|
||||
[Object.keys(data.items)[0]]: { score: 0 },
|
||||
}
|
||||
} finally {
|
||||
const duration = (Date.now() - start) / 1000 // in seconds
|
||||
latency.observe(duration)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue