You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8-18
Original file line number
Diff line number
Diff line change
@@ -102,20 +102,18 @@ summary.observe(4.7) // Observe the given value
102
102
```
103
103
104
104
## Labels
105
-
All metric types support adding labels, allowing for grouping of related metrics.
105
+
All metric types support adding labels, allowing for grouping of related metrics. Labels are passed when recording values to your metric as an instance of `DimensionLabels`, or as an array of `(String, String)`.
106
106
107
107
Example with a counter:
108
108
109
109
```swift
110
-
structRouteLabels: MetricLabels {
111
-
var route: String="*"
112
-
}
113
-
114
-
let counter = myProm.createCounter(forType: Int.self, named: "my_counter", helpText: "Just a counter", withLabelType: RouteLabels.self)
110
+
let counter = myProm.createCounter(forType: Int.self, named: "my_counter", helpText: "Just a counter")
115
111
116
-
let counter = prom.createCounter(forType: Int.self, named: "my_counter", helpText: "Just a counter", withLabelType: RouteLabels.self)
112
+
let counter = prom.createCounter(forType: Int.self, named: "my_counter", helpText: "Just a counter")
117
113
118
-
counter.inc(12, .init(route: "/"))
114
+
counter.inc(12, .init([("route", "/users")]))
115
+
// OR
116
+
counter.inc(12, [("route", "/users")])
119
117
```
120
118
121
119
# Exporting
@@ -125,16 +123,8 @@ Prometheus itself is designed to "pull" metrics from a destination. Following th
125
123
By default, this should be accessible on your main serving port, at the `/metrics` endpoint. An example in [Vapor](https://vapor.codes) 4 syntax looks like:
0 commit comments