Skip to content

feat(observability): expose configured public URLs - #2124

Merged
josecelano merged 8 commits into
torrust:developfrom
josecelano:2023-expose-configured-public-urls
Sep 1, 2026
Merged

josecelano merged 8 commits into
torrust:developfrom
josecelano:2023-expose-configured-public-urls

Conversation

@josecelano

@josecelano josecelano commented Sep 1, 2026 •

Copy link
Copy Markdown
Member

Summary

Expose each configured v3 public_url as listener-specific runtime observability data without conflating it with the post-bind local ServiceBinding.

  • add nullable public_url to health-check service details;
  • add public_url metric labels only for configured services and metric families that already carry service-binding labels;
  • emit public_url in startup logs only when it is configured, retaining service_binding in every event;
  • retain validated url::Url values in RuntimeServiceMetadata and render strings only at JSON/log boundaries;
  • migrate issue Expose configured public URLs in runtime observability #2023 to folder-style documentation and record automated plus reproducible configured/absent local runtime evidence.

Runtime output

For an HTTP tracker configured with bind_address = "0.0.0.0:0" and:

public_url = "https://tracker.example.test/announce"

the OS chooses the local port while the configured external endpoint remains independent:

Started HTTP tracker service_binding=http://0.0.0.0:36535/ public_url=https://tracker.example.test/announce

The health-check response preserves both identities rather than replacing the local binding:

{
  "service_binding": "http://0.0.0.0:36535/",
  "binding": "0.0.0.0:36535",
  "service_type": "http_tracker",
  "public_url": "https://tracker.example.test/announce"
}

After an HTTP announce, the corresponding metric sample includes the configured public URL alongside its existing local-binding labels:

public_url="https://tracker.example.test/announce"
server_binding_ip="0.0.0.0"
server_binding_port="36535"
server_binding_protocol="http"

When public_url is omitted, the health-check response contains "public_url": null; startup logs omit the public_url field and metrics omit the public_url label. This avoids exposing Rust Option formatting such as Some(...) or None in operator-facing logs.

Complete configured and absent runtime captures, commands, and effective configurations are recorded in docs/issues/open/2023-1978-expose-configured-public-urls-in-runtime-observability/manual-verification.md.

Verification

  • cargo test --workspace
  • linter all
  • ./contrib/dev-tools/git/hooks/pre-commit.sh
  • configured and absent local v3 tracker runs, including health-check, HTTP announce, management metrics, and startup-log evidence

Closes #2023

Copilot AI lite review requested due to automatic review settings September 1, 2026 08:07
@josecelano josecelano self-assigned this Sep 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR exposes the configured v3 public_url for each listener as runtime observability data (health-check details, per-service metrics labels, and startup logs) while keeping it distinct from the post-bind ServiceBinding.

Changes:

  • Extend RuntimeServiceMetadata to carry an optional, validated url::Url public_url, and thread it into HTTP/UDP/rest-api listener startup paths.
  • Add nullable public_url to health-check service details and include public_url as an optional Prometheus label only when configured.
  • Add/refresh issue #2023 folder-style documentation plus automated/manual verification evidence.

Reviewed changes

Copilot reviewed 28 out of 29 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/app.rs Pass configured public_url into listener runtime metadata for UDP/HTTP/REST API startup.
packages/udp-server/src/server/states.rs Emit public_url in UDP startup logs only when configured.
packages/udp-server/src/handlers/scrape.rs Attach public_url to UDP scrape event connection context.
packages/udp-server/src/handlers/mod.rs Plumb optional public_url into UDP error handling path.
packages/udp-server/src/handlers/error.rs Include public_url in UDP error events/contexts.
packages/udp-server/src/handlers/connect.rs Attach public_url to UDP connect event connection context.
packages/udp-server/src/handlers/announce.rs Attach public_url to UDP announce event connection context.
packages/udp-core/src/services/scrape.rs Store/propagate public_url through UDP scrape service + metrics event context.
packages/udp-core/src/services/connect.rs Store/propagate public_url through UDP connect service + metrics event context.
packages/udp-core/src/services/announce.rs Store/propagate public_url through UDP announce service + metrics event context.
packages/udp-core/src/event.rs Add optional public_url to UDP connection context and metric label set.
packages/udp-core/src/container.rs Inject configured public_url into UDP core services.
packages/primitives/src/runtime_service_metadata.rs Add typed public_url: Option<Url> to runtime listener metadata.
packages/primitives/Cargo.toml Add url dependency needed by runtime metadata.
packages/http-core/src/services/scrape.rs Store/propagate public_url through HTTP scrape service + metrics event context.
packages/http-core/src/services/announce.rs Store/propagate public_url through HTTP announce service + metrics event context.
packages/http-core/src/event.rs Add optional public_url to HTTP connection context and metric label set.
packages/axum-rest-api-server/src/testing/environment.rs Provide public_url metadata in REST API test environment startup.
packages/axum-rest-api-server/src/server.rs Emit public_url in REST API startup logs only when configured.
packages/axum-http-server/src/server.rs Emit public_url in HTTP tracker startup logs only when configured.
packages/axum-health-check-api-server/tests/server/contract.rs Extend contract tests to assert public_url presence/absence and port-0 wildcard separation.
packages/axum-health-check-api-server/src/resources.rs Add nullable public_url to health-check CheckReport.
packages/axum-health-check-api-server/src/handlers.rs Populate health-check public_url from service runtime metadata.
docs/issues/open/2023-1978-expose-configured-public-urls-in-runtime-observability/manual-verification.md Add reproducible manual runtime evidence for configured/absent public_url.
docs/issues/open/2023-1978-expose-configured-public-urls-in-runtime-observability/ISSUE.md Migrate issue #2023 to folder-style spec and mark tasks/ACs as completed.
docs/issues/open/2023-1978-expose-configured-public-urls-in-runtime-observability/automated-verification.md Record automated verification command evidence.
docs/issues/open/1978-configuration-overhaul-epic/EPIC.md Update epic subissue link to the folder-style issue spec.
docs/issues/closed/1415-1978-use-service-binding-instead-of-socket-addr/ISSUE.md Update #1415 references to point to the new #2023 folder path.
Cargo.lock Lockfile update for the added url dependency.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/udp-core/src/event.rs Resolved
Comment thread packages/http-core/src/event.rs Resolved
@codecov

codecov Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.26776% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.04%. Comparing base (1e8a76b) to head (5cd1687).

Files with missing lines Patch % Lines
src/app.rs 50.00% 0 Missing and 3 partials ⚠️
packages/axum-http-server/src/server.rs 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2124      +/-   ##
===========================================
+ Coverage    83.99%   84.04%   +0.05%     
===========================================
  Files          349      349              
  Lines        27240    27376     +136     
  Branches     27240    27376     +136     
===========================================
+ Hits         22879    23008     +129     
- Misses        4018     4022       +4     
- Partials       343      346       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@josecelano
josecelano force-pushed the 2023-expose-configured-public-urls branch from ce03da3 to 5cd1687 Compare September 1, 2026 09:08
@josecelano

Copy link
Copy Markdown
Member Author

ACK 5cd1687

@josecelano
josecelano merged commit f454496 into torrust:develop Sep 1, 2026
18 checks passed
@josecelano
josecelano deleted the 2023-expose-configured-public-urls branch September 1, 2026 10:06

This branch was previously deployed

1 inactive deployment
coverage — 5cd1687f Deployed Sep 1, 2026 by josecelano via Generate Coverage Report #1872
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose configured public URLs in runtime observability

2 participants