2.1.0 • Published 8 months ago
@well-known-components/metrics v2.1.0
metrics
npm i @well-known-components/metrics
Define your metrics in a static file
// src/metrics.ts
import { IMetricsComponent } from "@well-known-components/interfaces"
import { validateMetricsDeclaration } from "@well-known-components/metrics"
export const metricDeclarations = {
// IMetricsComponent.SummaryType
// IMetricsComponent.HistogramType
// IMetricsComponent.GaugeType
// IMetricsComponent.CounterType
user_counter: {
type: IMetricsComponent.CounterType,
help: "Count calls to /user/:userId",
labelNames: ["userId"],
}
}
// type assertions
validateMetricsDeclaration(metricDeclarations)
Define the component
// src/components.ts
import { metricDeclarations } from "./metrics"
export async function initComponents(): Promise<AppComponents> {
...
// const config
// const server
const metrics = await createMetricsComponent(metricDeclarations, { server, config })
return { ...components, metrics }
}
Register metrics
export async function userIdHandler(context: {
components: Pick<AppComponents, "metrics">
}) {
const { components: { metrics } } = context
metrics.increment("user_counter", { userId: Math.random() })
// metrics.decrement("user_counter", { userId: Math.random() })
// metrics.observe("user_counter", { userId: Math.random() }, 1)
// metrics.reset("user_counter")
return {}
}
2.0.2-20240318115652.commit-cd054ed
8 months ago
2.1.0
8 months ago
2.1.1-20240318121622.commit-357a93e
8 months ago
2.0.2-20240315125952.commit-847498c
8 months ago
2.0.2-20240314121817.commit-2a29945
8 months ago
2.0.2-20240314121618.commit-1db6590
8 months ago
2.0.2-20240314122215.commit-df469cb
8 months ago
2.0.2-20230725173418.commit-aadf3a9
1 year ago
2.0.2-20230904165714.commit-81901e5
1 year ago
2.0.2-20230725173544.commit-f6bb53e
1 year ago
2.0.2-20230725173301.commit-8395597
1 year ago
2.0.2-20230815175338.commit-046dbb0
1 year ago
2.0.2-20230627202742.commit-68365c1
1 year ago
2.0.2-20230627203645.commit-2169ef4
1 year ago
2.0.2-20230627202323.commit-a662b3a
1 year ago
2.0.2-20230627202921.commit-781b271
1 year ago
2.0.2-20230627203059.commit-96826b5
1 year ago
2.0.2-20230628120739.commit-19527df
1 year ago
2.0.2-20230628130145.commit-c9f072d
1 year ago
2.0.2-20230627203522.commit-bb949de
1 year ago
2.0.2-20230627202527.commit-ff4acc5
1 year ago
2.0.2-20230628121034.commit-ef205a4
1 year ago
2.0.0-20220908193547.commit-f7dc123
2 years ago
2.0.1-20220909150423.commit-8f7e5bc
2 years ago
2.0.1-20220909015002.commit-9fbc64b
2 years ago
2.0.1-20220909024632.commit-1847728
2 years ago
2.0.1
2 years ago
2.0.0
2 years ago
2.0.1-20221008233321.commit-5eac505
2 years ago
1.1.4-20220804221225.commit-122d5db
2 years ago
2.0.1-20221008232912.commit-fce33b0
2 years ago
2.0.0-20220908230022.commit-4f39abe
2 years ago
1.1.3
3 years ago
1.1.3-20220204130209.commit-b430b6b
3 years ago
1.1.3-20210914233650.commit-e676325
3 years ago
1.1.3-20210914233801.commit-6e6e7ce
3 years ago
1.1.3-20210914233531.commit-e0dcd08
3 years ago
1.1.2
3 years ago
1.1.2-20210818141008.commit-e8f6fbb
3 years ago
1.1.2-20210701112206.commit-6ce846d
3 years ago
1.1.2-20210701112300.commit-287d5a9
3 years ago
1.1.2-20210701112241.commit-469ca1f
3 years ago
1.1.2-20210701112222.commit-7c04706
3 years ago
1.1.1
4 years ago
1.1.1-20210426161819.commit-71e410b
4 years ago
1.1.0
4 years ago
1.0.1-20210419183631.commit-4d21ff4
4 years ago
1.0.0-20210207171234.commit-4228a39
4 years ago
1.0.0
4 years ago
1.0.0-20210207163609.commit-68f3df4
4 years ago
1.0.0-20210207162501.commit-0131dec
4 years ago
1.0.0-20210207171610.commit-5c58301
4 years ago
1.0.0-20210207171701.commit-b7c19e4
4 years ago
1.0.0-20210207144556.commit-29f54fd
4 years ago
1.0.0-20210207144449.commit-7f69e96
4 years ago