#### Pre-Submission Checklist
- [x] Commit message has the format required by CONTRIBUTING guide
- [x] Commits are split per component (core, individual modules, libs, utils, 
...)
- [x] Each component has a single commit (if not, squash them into one commit)
- [x] Code is formatted with `clang-format` using the config file 
`.clang-format`
  from source code folder
- [x] No commits to README files for modules (changes must be done to docbook 
files
  in `doc/` subfolder, the README file is autogenerated)

#### Type Of Change
- [ ] Small bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds new functionality)
- [ ] Breaking change (fix or feature that would change existing functionality)

#### Checklist:
- [x] PR should be backported to stable branches
- [x] Tested changes locally
- [ ] Related to issue #XXXX (replace XXXX with an open issue number)

#### Description

This PR adds sampled core route latency telemetry and exposes it via existing
internal statistics, scrapeable through `xhttp_prom`.

### Commit split

1. `core: add sampled route latency telemetry and cfg knob`
   - adds route latency event payload and event IDs in core stats path
   - emits sampled request/reply route latency observations in receive path
   - derives reply method from CSeq and classifies reply status (1xx..6xx/other)
   - adds core config parameter `latency_sample_n` (default 1, min 1)
   - wires parameter through `cfg_core.{c,h}`, `cfg.y`, `cfg.lex`
   - documents core settings in `doc/tutorials/cfg_list/docbook/cfg_core.xml`

2. `kex: register and update route latency histogram stats`
   - registers bounded latency counters in `core` stats group as histogram-style
     bucket/sum/count series
   - request dimensions: `method`
   - reply dimensions: `method`, `status_class`

3. `xhttp_prom: export core route latency stats as labeled histogram series`
   - maps new core latency counters to Prometheus output with labels
   - exports `_bucket`, `_sum`, `_count` families
   - maps internal `inf` token to Prometheus `+Inf`
   - documents metric families and aggregation guidance in
     `src/modules/xhttp_prom/doc/xhttp_prom_admin.xml`

4. `devcontainer: add libxml2-utils for xmllint availability`
   - adds `libxml2-utils` for XML validation tooling in the Debian devcontainer

### Runtime behavior and compatibility

- No route-script instrumentation is required.
- No additional hot-path network sends are introduced.
- Latency telemetry generation is tied to `core.latency_cfg_log` printable 
level.
- `core.latency_sample_n` affects metric sampling only; it does not change
  existing latency log messages or thresholds.
- Global request/reply latency views are available by aggregating labeled series
  in PromQL; detailed method/status breakdowns remain available.

### Validation performed

- Formatted with repository `.clang-format`.
- Built successfully in Debian devcontainer:
  - `make -C src -j4`

### Backport plan

This change is intended for backport to `6.1` and `5.8` after master merge,
using `git cherry-pick -x` per CONTRIBUTING guide.

### AI Disclosure

Parts of this contribution were developed with assistance from an AI coding
assistant. The assistant was used for implementation and documentation 
drafting.

All generated content was reviewed, edited, and validated by me before
submission, including:
- code and commit structure review
- formatting checks (`clang-format`)
- local build validation (`make -C src -j4` in Debian devcontainer)

You can view, comment on, or merge this pull request online at:

  https://github.com/kamailio/kamailio/pull/4747

-- Commit Summary --

  * core: add sampled route latency telemetry and cfg knob
  * kex: register and update route latency histogram stats
  * xhttp_prom: export core route latency stats as labeled histogram series
  * devcontainer: add libxml2-utils for xmllint availability

-- File Changes --

    M .devcontainer/Dockerfile (3)
    M doc/tutorials/cfg_list/docbook/cfg_core.xml (25)
    M src/core/cfg.lex (2)
    M src/core/cfg.y (3)
    M src/core/cfg_core.c (3)
    M src/core/cfg_core.h (3)
    M src/core/core_stats.h (65)
    M src/core/receive.c (39)
    M src/modules/kex/core_stats.c (245)
    M src/modules/xhttp_prom/doc/xhttp_prom_admin.xml (32)
    M src/modules/xhttp_prom/prom.c (150)

-- Patch Links --

https://github.com/kamailio/kamailio/pull/4747.patchhttps://github.com/kamailio/kamailio/pull/4747.diff
-- 
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/4747
You are receiving this because you are subscribed to this thread.

Message ID: <kamailio/kamailio/pull/[email protected]>
_______________________________________________
Kamailio - Development Mailing List -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to