Skip to content
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
be74352
feat: metrics refactor
Frando Apr 8, 2025
396a850
refactor: remove macros
Frando Apr 8, 2025
1c3262a
fix: fixup, add portmapper
Frando Apr 8, 2025
06b492f
chore: cleanup
Frando Apr 8, 2025
0ca77b4
fix: feature flags
Frando Apr 8, 2025
b17d26a
chore: fmt
Frando Apr 8, 2025
a2285a4
change: update to lastest iroh-metrics PR
Frando Apr 9, 2025
6e49c75
refactor: metrics tracking in iroh-dns-server and iroh-relay
Frando Apr 9, 2025
491391d
fix: update remaining things, update to latest iroh-metrics PR
Frando Apr 9, 2025
3b4fec0
refactor: put metrics in an Arc
Frando Apr 9, 2025
c8dd091
deps: update to latest iroh-metrics ref
Frando Apr 9, 2025
55d1667
chore: update portmapper branch ref
Frando Apr 9, 2025
67bc352
fixup
Frando Apr 9, 2025
73b1a5a
change: add docs, metrics test, adapt to iroh-metrics changes
Frando Apr 9, 2025
2feb684
docs: fix
Frando Apr 9, 2025
482cc9f
tests: don't test for exact datagram counts, they vary
Frando Apr 9, 2025
d431315
chore: use git dep for portmapper instead of patch to update downstre…
Frando Apr 9, 2025
b430ca6
fix: move metrics docs to Endpoint::metrics
Frando Apr 9, 2025
fd0fe40
docs: fix doclinks
Frando Apr 9, 2025
d4f0833
wip
Frando Apr 11, 2025
9526e10
refactor: use new iroh-metrics derive macros
Frando Apr 11, 2025
21f4581
fix: doctest
Frando Apr 11, 2025
e4634cb
update to latest iroh-metrics pr
Frando Apr 11, 2025
0425479
tests: add openmetrics encoding test
Frando Apr 11, 2025
c6d2e0b
tests: simplify metrics registry test
Frando Apr 14, 2025
33a183f
deps: bump iroh-metrics and portmapper refs
Frando Apr 14, 2025
d823b83
deps: update to iroh-metrics 0.33
Frando Apr 16, 2025
dc36b5b
deps: bump portmapper ref
Frando Apr 16, 2025
f859603
change: make metrics non-exhaustive
Frando Apr 16, 2025
70fc974
refactor: metrics in relay http server builder
Frando Apr 16, 2025
84e33bd
refactor: update to latest iroh-metrics branch
Frando Apr 28, 2025
e5fcb57
update iroh-metrics ref
Frando Apr 28, 2025
1c78769
tests: add serde test for metrics
Frando Apr 28, 2025
13f50a5
fix: docs
Frando Apr 29, 2025
3d22b7e
chore: fmt
Frando Apr 29, 2025
e44aa54
update to latest iroh-metrics main
Frando Apr 30, 2025
88f77d3
deps: update iroh-metrics to 0.34
Frando May 2, 2025
8c1d8d1
Merge remote-tracking branch 'origin/main' into Frando/metrics
Frando May 2, 2025
f7b8b43
cleanups
Frando May 5, 2025
6ff053b
switch to released deps
dignifiedquire May 5, 2025
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
114 changes: 55 additions & 59 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion iroh-dns-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ governor = "0.8"
hickory-server = { version = "0.25.1", features = ["https-ring"] }
http = "1.0.0"
humantime-serde = "1.1.1"
iroh-metrics = { version = "0.32.0", features = ["metrics", "service"] }
iroh-metrics = { version = "0.34", features = ["service"] }
lru = "0.12.3"
n0-future = "0.1.2"
pkarr = { version = "3.7", features = ["relays", "dht"], default-features = false }
Expand Down
13 changes: 10 additions & 3 deletions iroh-dns-server/benches/write.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
use std::sync::Arc;

use anyhow::Result;
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
use iroh::{discovery::pkarr::PkarrRelayClient, node_info::NodeInfo, SecretKey};
use iroh_dns_server::{config::Config, server::Server, ZoneStore};
use iroh_dns_server::{config::Config, metrics::Metrics, server::Server, ZoneStore};
use rand_chacha::rand_core::SeedableRng;
use tokio::runtime::Runtime;

const LOCALHOST_PKARR: &str = "http://localhost:8080/pkarr";

async fn start_dns_server(config: Config) -> Result<Server> {
let store = ZoneStore::persistent(Config::signed_packet_store_path()?, Default::default())?;
Server::spawn(config, store).await
let metrics = Arc::new(Metrics::default());
let store = ZoneStore::persistent(
Config::signed_packet_store_path()?,
Default::default(),
metrics.clone(),
)?;
Server::spawn(config, store, metrics).await
}

fn benchmark_dns_server(c: &mut Criterion) {
Expand Down
25 changes: 15 additions & 10 deletions iroh-dns-server/src/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use hickory_server::{
server::{Request, RequestHandler, ResponseHandler, ResponseInfo},
store::in_memory::InMemoryAuthority,
};
use iroh_metrics::inc;
use serde::{Deserialize, Serialize};
use tokio::{
net::{TcpListener, UdpSocket},
Expand Down Expand Up @@ -122,12 +121,13 @@ impl DnsServer {
pub struct DnsHandler {
#[debug("Catalog")]
catalog: Arc<Catalog>,
metrics: Arc<Metrics>,
}

impl DnsHandler {
/// Create a DNS server given some settings, a connection to the DB for DID-by-username lookups
/// and the server DID to serve under `_did.<origin>`.
pub fn new(zone_store: ZoneStore, config: &DnsConfig) -> Result<Self> {
pub fn new(zone_store: ZoneStore, config: &DnsConfig, metrics: Arc<Metrics>) -> Result<Self> {
let origins = config
.origins
.iter()
Expand All @@ -149,6 +149,7 @@ impl DnsHandler {

Ok(Self {
catalog: Arc::new(catalog),
metrics,
})
}

Expand All @@ -168,23 +169,27 @@ impl RequestHandler for DnsHandler {
request: &Request,
response_handle: R,
) -> ResponseInfo {
inc!(Metrics, dns_requests);
self.metrics.dns_requests.inc();
match request.protocol() {
Protocol::Udp => inc!(Metrics, dns_requests_udp),
Protocol::Https => inc!(Metrics, dns_requests_https),
Protocol::Udp => {
self.metrics.dns_requests_udp.inc();
}
Protocol::Https => {
self.metrics.dns_requests_https.inc();
}
_ => {}
}
debug!(protocol=%request.protocol(), queries=?request.queries(), "incoming DNS request");

let res = self.catalog.handle_request(request, response_handle).await;
match &res.response_code() {
ResponseCode::NoError => match res.answer_count() {
0 => inc!(Metrics, dns_lookup_notfound),
_ => inc!(Metrics, dns_lookup_success),
0 => self.metrics.dns_lookup_notfound.inc(),
_ => self.metrics.dns_lookup_success.inc(),
},
ResponseCode::NXDomain => inc!(Metrics, dns_lookup_notfound),
_ => inc!(Metrics, dns_lookup_error),
}
ResponseCode::NXDomain => self.metrics.dns_lookup_notfound.inc(),
_ => self.metrics.dns_lookup_error.inc(),
};
res
}
}
Expand Down
Loading