Skip to content
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

chore: change log level and add metrics for all requests #30

Merged
merged 4 commits into from
Jun 24, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export async function createSubgraphComponent(
const queryId = randomUUID()
const logData = { queryId, currentAttempt, attempts, timeoutWait, url }

logger.info("Querying:", logData)
logger.debug("Querying:", logData)

try {
const { data, errors } = await withTimeout(
Expand All @@ -58,7 +58,9 @@ export async function createSubgraphComponent(
)
}

logger.info("Success:", logData)
logger.debug("Success:", logData)

metrics.increment("subgraph_ok_total", { url })

return data
} catch (error) {
Expand Down Expand Up @@ -117,8 +119,13 @@ export namespace createSubgraphComponent {
* @public
*/
export const metricDeclarations: IMetricsComponent.MetricsRecordDefinition<string> = {
subgraph_ok_total: {
help: "Subgraph request counter",
type: IMetricsComponent.CounterType,
labelNames: ["url"],
},
subgraph_errors_total: {
help: "Subgrpah error counter",
help: "Subgraph error counter",
type: IMetricsComponent.CounterType,
labelNames: ["url", "errorMessage"],
},
Expand Down