Software / code / prosody
Comparison
core/moduleapi.lua @ 13513:2fb79fe54390 0.12
core.moduleapi: Default labels to empty list to fix error if omitted
In a host-scoped module in the `if is_scoped` clause the resulting
`array:append(nil)` call throws.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 18 Aug 2024 16:58:30 +0200 |
| parent | 12479:4d36fbcdd210 |
| child | 13514:a1bc6533bbba |
comparison
equal
deleted
inserted
replaced
| 13505:a97c11584042 | 13513:2fb79fe54390 |
|---|---|
| 556 end | 556 end |
| 557 | 557 |
| 558 function api:metric(type_, name, unit, description, label_keys, conf) | 558 function api:metric(type_, name, unit, description, label_keys, conf) |
| 559 local metric = require "core.statsmanager".metric; | 559 local metric = require "core.statsmanager".metric; |
| 560 local is_scoped = self.host ~= "*" | 560 local is_scoped = self.host ~= "*" |
| 561 label_keys = label_keys or {}; | |
| 561 if is_scoped then | 562 if is_scoped then |
| 562 -- prepend `host` label to label keys if this is not a global module | 563 -- prepend `host` label to label keys if this is not a global module |
| 563 local orig_labels = label_keys | 564 local orig_labels = label_keys |
| 564 label_keys = array { "host" } | 565 label_keys = array { "host" } |
| 565 label_keys:append(orig_labels) | 566 label_keys:append(orig_labels) |