-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: track cached response times #1232
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ import { | |
SUMMARY_METRICS_ID, | ||
HTTP_STATUS_SUCCESS, | ||
} from './constants.js' | ||
import { histogram } from './durable-objects/gateway-metrics.js' | ||
import { responseTimeHistogram } from './utils/histogram.js' | ||
import { contentLengthHistogram } from './durable-objects/summary-metrics.js' | ||
|
||
/** | ||
|
@@ -80,9 +80,26 @@ export async function metricsGet(request, env, ctx) { | |
}) | ||
|
||
const metrics = [ | ||
`# HELP nftgateway_summary_responses_total Total winner and cached responses returned.`, | ||
`# TYPE nftgateway_summary_responses_total counter`, | ||
`nftgateway_summary_responses_total{env="${env.ENV}"} ${ | ||
metricsCollected.summaryMetrics.totalWinnerSuccessfulRequests + | ||
metricsCollected.summaryMetrics.totalCachedResponses | ||
}`, | ||
`# HELP nftgateway_summary_response_time_seconds_total Accumulated summary response time of winner responses and cached responses.`, | ||
`# TYPE nftgateway_summary_response_time_seconds_total summary`, | ||
`nftgateway_summary_response_time_seconds_total{env="${env.ENV}"} ${msToS( | ||
metricsCollected.summaryMetrics.totalWinnerResponseTime + | ||
metricsCollected.summaryMetrics.totalCachedResponseTime | ||
)}`, | ||
`# HELP nftgateway_cache_hit_responses_total Total cached responses returned.`, | ||
`# TYPE nftgateway_cache_hit_responses_total counter`, | ||
`nftgateway_cache_hit_responses_total{env="${env.ENV}"} ${metricsCollected.summaryMetrics.totalCachedResponses}`, | ||
`# HELP nftgateway_cache_hit_response_time_seconds_total Accumulated cached response time.`, | ||
`# TYPE nftgateway_cache_hit_response_time_seconds_total summary`, | ||
`nftgateway_cache_hit_response_time_seconds_total{env="${env.ENV}"} ${msToS( | ||
metricsCollected.summaryMetrics.totalCachedResponseTime | ||
)}`, | ||
`# HELP nftgateway_winner_requests_total Total winner requests.`, | ||
`# TYPE nftgateway_winner_requests_total counter`, | ||
`nftgateway_winner_requests_total{env="${env.ENV}"} ${metricsCollected.summaryMetrics.totalWinnerSuccessfulRequests}`, | ||
|
@@ -91,6 +108,18 @@ export async function metricsGet(request, env, ctx) { | |
`nftgateway_winner_response_time_seconds_total{env="${env.ENV}"} ${msToS( | ||
metricsCollected.summaryMetrics.totalWinnerResponseTime | ||
)}`, | ||
`# HELP nftgateway_summary_responses_per_time_total total of responses per response time bucket`, | ||
`# TYPE nftgateway_summary_responses_per_time_total histogram`, | ||
...responseTimeHistogram.map( | ||
(t) => | ||
`nftgateway_summary_responses_per_time_total{le="${msToS(t)}",env="${ | ||
env.ENV | ||
}"} ${metricsCollected.summaryMetrics.responseTimeHistogram[t]}` | ||
), | ||
`nftgateway_summary_responses_per_time_total{le="+Inf",env="${env.ENV}"} ${ | ||
metricsCollected.summaryMetrics.totalWinnerSuccessfulRequests + | ||
metricsCollected.summaryMetrics.totalCachedResponses | ||
}`, | ||
`# HELP nftgateway_response_time_seconds_total Accumulated response time of each gateway.`, | ||
`# TYPE nftgateway_response_time_seconds_total summary`, | ||
...env.ipfsGateways.map( | ||
|
@@ -184,11 +213,15 @@ export async function metricsGet(request, env, ctx) { | |
), | ||
`# HELP nftgateway_requests_per_time_total total of requests per response time bucket`, | ||
`# TYPE nftgateway_requests_per_time_total histogram`, | ||
...histogram.map((t) => { | ||
...responseTimeHistogram.map((t) => { | ||
return env.ipfsGateways | ||
.map( | ||
(gw) => | ||
`nftgateway_requests_per_time_total{gateway="${gw}",le="${t}",env="${env.ENV}"} ${metricsCollected.ipfsGateways[gw].responseTimeHistogram[t]}` | ||
`nftgateway_requests_per_time_total{gateway="${gw}",le="${msToS( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also made the |
||
t | ||
)}",env="${env.ENV}"} ${ | ||
metricsCollected.ipfsGateways[gw].responseTimeHistogram[t] | ||
}` | ||
) | ||
.join('\n') | ||
}), | ||
|
@@ -208,7 +241,10 @@ export async function metricsGet(request, env, ctx) { | |
(t) => | ||
`nftgateway_responses_content_length_total{le="${t}",env="${env.ENV}"} ${metricsCollected.summaryMetrics.contentLengthHistogram[t]}` | ||
), | ||
`nftgateway_responses_content_length_total{le="+Inf",env="${env.ENV}"} ${metricsCollected.summaryMetrics.totalWinnerSuccessfulRequests}`, | ||
`nftgateway_responses_content_length_total{le="+Inf",env="${env.ENV}"} ${ | ||
metricsCollected.summaryMetrics.totalWinnerSuccessfulRequests + | ||
metricsCollected.summaryMetrics.totalCachedResponses | ||
}`, | ||
`# HELP nftgateway_responses_content_length_bytes_total Accumulated content length of delivered cached responses`, | ||
`# TYPE nftgateway_responses_content_length_bytes_total summary`, | ||
`nftgateway_responses_content_length_bytes_total{env="${env.ENV}"} ${metricsCollected.summaryMetrics.totalContentLengthBytes}`, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export const responseTimeHistogram = [ | ||
50, 100, 200, 300, 500, 750, 1000, 1500, 2000, 3000, 5000, 10000, 20000, | ||
] | ||
|
||
export function createResponseTimeHistogramObject() { | ||
const h = responseTimeHistogram.map((h) => [h, 0]) | ||
return Object.fromEntries(h) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😱 😱 😱 😱 😱 😱 😱 😱 😱 😱 😱 😱 😱 😱