Skip to content

Commit 2bfd40f

Browse files
hsanjuanlidel
andauthored
feat(metrics): add delegated routing client metrics to prometheus (#113)
* Add delegated routing client metrics to prometheus * docs: document metrics.md --------- Co-authored-by: Marcin Rataj <[email protected]>
1 parent be4baa9 commit 2bfd40f

File tree

5 files changed

+412
-1
lines changed

5 files changed

+412
-1
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ The following emojis are used to highlight certain changes:
1515

1616
### Added
1717

18+
- Added exporting of routing http client metrics: the endpoint will now include `someguy_routing_http_client_*` metrics when delegated routing clients are used:
19+
- Histogram: the latency of operations by the routing HTTP client:
20+
- `someguy_routing_http_client_latency_bucket{code,error,host,operation,le}`
21+
- `someguy_routing_http_client_latency_sum{code,error,host,operation}`
22+
- `someguy_routing_http_client_latency_count{code,error,host,operation}`
23+
- Histogram: the number of elements in a response collection
24+
- `someguy_routing_http_client_length_bucket{host,operation,le}`
25+
- `someguy_routing_http_client_length_sum{host,operation}`
26+
- `someguy_routing_http_client_length_count{host,operation}`
27+
- See [docs/metrics.md](https://github.com/ipfs/someguy/blob/main/docs/metrics.md) for more details.
28+
1829
### Changed
1930

2031
### Removed

docs/metrics.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## someguy metrics
2+
3+
By default, a prometheus endpoint is exposed by someguy at `http://127.0.0.1:8190/debug/metrics/prometheus`.
4+
5+
It includes default [Prometheus Glient metrics](https://prometheus.io/docs/guides/go-application/) + someguy-specific listed below.
6+
7+
### Delegated HTTP Routing (`/routing/v1`) server
8+
9+
Metric from `boxo/routing/http/server` (used for `/routing/v1` handler) are exposed with `delegated_routing_server_` prefix:
10+
11+
- `delegated_routing_server_http_request_duration_seconds_[bucket|sum|count]{code,handler,method}` - histogram: the latency of the HTTP requests
12+
- `delegated_routing_server_http_response_size_bytes_[bucket|sum|count]{code,handler,method}` - histogram: the size of the HTTP responses
13+
14+
### Delegated HTTP Routing (`/routing/v1`) client
15+
16+
If someguy is set up as an aggregating proxy for multiple other `/routing/v1` endpoints,
17+
metrics from `boxo/routing/http/client` are exposed with `someguy_` prefix:
18+
19+
- `someguy_routing_http_client_latency_[bucket|sum|count]{code,error,host,operation}` - Histogram: the latency of operations by the routing HTTP client:
20+
- `someguy_routing_http_client_length_[bucket|sum|count]{host,operation}` - Histogram: the number of elements in a response collection
21+
22+
### Someguy Caches
23+
24+
- `someguy_cached_addr_book_probe_duration_seconds_[bucket|sum|count]` - Histogram: duration of peer probing operations in seconds
25+
- `someguy_cached_router_peer_addr_lookups{cache,origin}` - Counter: number of peer addr info lookups per origin and cache state
26+
- `someguy_cached_addr_book_peer_state_size` - Gauge: number of peers object currently in the peer state
27+

go.mod

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module github.com/ipfs/someguy
33
go 1.23.0
44

55
require (
6+
contrib.go.opencensus.io/exporter/prometheus v0.4.2
67
github.com/CAFxX/httpcompression v0.0.9
78
github.com/coreos/go-systemd/v22 v22.5.0
89
github.com/dustin/go-humanize v1.0.1
@@ -22,6 +23,7 @@ require (
2223
github.com/rs/cors v1.11.0
2324
github.com/stretchr/testify v1.10.0
2425
github.com/urfave/cli/v2 v2.27.3
26+
go.opencensus.io v0.24.0
2527
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0
2628
go.opentelemetry.io/contrib/propagators/autoprop v0.57.0
2729
go.opentelemetry.io/otel v1.35.0
@@ -47,11 +49,14 @@ require (
4749
github.com/filecoin-project/go-clock v0.1.0 // indirect
4850
github.com/flynn/noise v1.1.0 // indirect
4951
github.com/francoispqt/gojay v1.2.13 // indirect
52+
github.com/go-kit/log v0.2.1 // indirect
53+
github.com/go-logfmt/logfmt v0.6.0 // indirect
5054
github.com/go-logr/logr v1.4.2 // indirect
5155
github.com/go-logr/stdr v1.2.2 // indirect
5256
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
5357
github.com/godbus/dbus/v5 v5.1.0 // indirect
5458
github.com/gogo/protobuf v1.3.2 // indirect
59+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
5560
github.com/google/gopacket v1.1.19 // indirect
5661
github.com/google/pprof v0.0.0-20250208200701-d0013a598941 // indirect
5762
github.com/google/uuid v1.6.0 // indirect
@@ -121,6 +126,7 @@ require (
121126
github.com/prometheus/client_model v0.6.2 // indirect
122127
github.com/prometheus/common v0.63.0 // indirect
123128
github.com/prometheus/procfs v0.16.1 // indirect
129+
github.com/prometheus/statsd_exporter v0.26.1 // indirect
124130
github.com/quic-go/qpack v0.5.1 // indirect
125131
github.com/quic-go/quic-go v0.50.1 // indirect
126132
github.com/quic-go/webtransport-go v0.8.1-0.20241018022711-4ac2c9250e66 // indirect
@@ -133,7 +139,6 @@ require (
133139
github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect
134140
github.com/wlynxg/anet v0.0.5 // indirect
135141
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
136-
go.opencensus.io v0.24.0 // indirect
137142
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
138143
go.opentelemetry.io/contrib/propagators/aws v1.32.0 // indirect
139144
go.opentelemetry.io/contrib/propagators/b3 v1.32.0 // indirect
@@ -163,6 +168,7 @@ require (
163168
google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect
164169
google.golang.org/grpc v1.67.1 // indirect
165170
google.golang.org/protobuf v1.36.6 // indirect
171+
gopkg.in/yaml.v2 v2.4.0 // indirect
166172
gopkg.in/yaml.v3 v3.0.1 // indirect
167173
lukechampine.com/blake3 v1.4.0 // indirect
168174
)

0 commit comments

Comments
 (0)