Skip to content

Expose configured public URLs in runtime observability #2023

Description

@josecelano

Goal

Use the v3 public_url configuration values introduced by #1417 in health-check responses, metrics, and runtime logs without conflating them with a service's configured bind address or its post-bind ServiceBinding.

Background

Each service has three distinct concepts:

Concept Source Meaning
Configured bind address bind_address configuration The requested local socket bind target. It may be wildcard (0.0.0.0 or [::]) and may use port 0.
Service binding ServiceBinding created after the socket binds The protocol plus the actual local socket address. An OS-assigned ephemeral port replaces configured port 0, but a wildcard address remains wildcard. It is an identity, not necessarily a reachable URL.
Public URL Optional v3 public_url configuration The operator-declared external endpoint. It may differ completely from the bind address and service binding because of reverse proxies, NAT, TLS termination, or DNS.

internal_service_url is a possible future concept. It is not implemented by this issue and cannot be inferred reliably from a wildcard service binding.

#1417 stores and validates typed v3 public_url values but deliberately does not consume them at runtime. #1980 migrates runtime consumers to explicit v3 configuration imports. This issue follows both changes.

Scope

In scope

  • Add an optional public-URL representation to health-check service details while preserving existing service_binding, binding, and service_type fields.
  • Add an optional public_url label to relevant per-service metrics when configured.
  • Add configured public_url, when present, to relevant service startup and request logs; retain service_binding as the local service identity.
  • Define and test absent-value behavior: services without public_url remain valid and do not claim a public endpoint.
  • Test that public_url, configured bind_address, and post-bind ServiceBinding remain distinguishable, including wildcard binding with an OS-assigned port.

Out of scope

  • Changing how Include public service URL in configuration #1417 validates or stores v3 public_url values.
  • Changing ServiceBinding or adding an internal_service_url type.
  • Choosing a concrete reachable interface for wildcard listeners.
  • Modifying the v2 configuration schema or supporting a v2 runtime fallback.
  • Changing BitTorrent protocol behavior or URL path routing.

Compatibility decisions

Surface Required behavior
Health check Add an optional public_url field. Retain service_binding, binding, and service_type unchanged.
Metrics Add public_url only when configured. Confirm and document the resulting Prometheus-series/cardinality effect.
Logs Emit service_binding as the local identity and optional public_url as the operator-declared endpoint. Neither replaces the other.

Acceptance criteria

  • A configured v3 public_url is exposed as an optional health-check field without replacing existing service-identity fields.
  • Relevant per-service metrics expose public_url only when configured.
  • Relevant startup and request logs identify the local service with service_binding and, independently, the configured public_url when present.
  • A wildcard bind address with configured port 0 demonstrates three separate values: configured bind address, post-bind service binding, and configured public URL.
  • Services without public_url preserve existing health-check, metric, and logging behavior.
  • No internal_service_url implementation or torrust-net-primitives change is made.
  • linter all and relevant tests pass.
  • Manual verification evidence records both configured and absent public_url cases.

Verification plan

  • Run linter all, focused tests for changed server, health-check, and metrics packages, and cargo test --workspace.
  • Start a local v3 tracker with bind_address = "0.0.0.0:0" and public_url = "https://tracker.example.test/announce"; verify health checks distinguish public URL from post-bind wildcard service binding.
  • Send an HTTP announce and query Prometheus metrics; verify configured public URL and existing server_binding_* labels are both present.
  • Repeat without public_url; verify existing fields remain and no public URL is claimed or labelled.

Risks and trade-offs

  • Public URLs can increase Prometheus time-series cardinality; restrict the label to configured per-service metric series and document the behavior.
  • Health-check additions must be optional and additive.
  • Logs and API fields must name service_binding and public_url explicitly so operators do not mistake either for an internal reachable URL.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions