Skip to content

Commit 96a31e3

Browse files
committed
lib: cmetrics: upgrade to v1.0.6
Signed-off-by: Eduardo Silva <[email protected]>
1 parent 3683ce3 commit 96a31e3

File tree

7 files changed

+274
-25
lines changed

7 files changed

+274
-25
lines changed

lib/cmetrics/.github/workflows/build.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
os: [windows-latest, windows-2019]
18+
os: [windows-latest, windows-2022]
1919
permissions:
2020
contents: read
2121
steps:
22-
- uses: actions/checkout@v5
22+
- uses: actions/checkout@v6
2323
with:
2424
submodules: true
2525

@@ -90,6 +90,9 @@ jobs:
9090
steps:
9191
- name: Set up base image dependencies
9292
run: |
93+
# Update sources to use archive.debian.org (Buster reached end-of-life)
94+
sed -i 's/deb.debian.org/archive.debian.org/g' /etc/apt/sources.list
95+
sed -i 's/security.debian.org/archive.debian.org/g' /etc/apt/sources.list
9396
apt-get update
9497
apt-get install -y build-essential wget make gcc g++ git libcurl4-openssl-dev
9598
@@ -136,7 +139,7 @@ jobs:
136139
permissions:
137140
contents: read
138141
steps:
139-
- uses: actions/checkout@v5
142+
- uses: actions/checkout@v6
140143
with:
141144
submodules: true
142145

@@ -170,7 +173,7 @@ jobs:
170173
permissions:
171174
contents: read
172175
steps:
173-
- uses: actions/checkout@v5
176+
- uses: actions/checkout@v6
174177
with:
175178
submodules: true
176179

@@ -200,7 +203,7 @@ jobs:
200203
runs-on: ubuntu-latest
201204
steps:
202205
- name: Check out the repository
203-
uses: actions/checkout@v5
206+
uses: actions/checkout@v6
204207
with:
205208
submodules: true
206209

lib/cmetrics/.github/workflows/lint.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
permissions:
1111
contents: read
1212
steps:
13-
- uses: actions/checkout@v5
13+
- uses: actions/checkout@v6
1414
- uses: ludeeus/action-shellcheck@master
1515

1616
actionlint:
@@ -19,7 +19,7 @@ jobs:
1919
permissions:
2020
contents: read
2121
steps:
22-
- uses: actions/checkout@v5
22+
- uses: actions/checkout@v6
2323
- run: |
2424
echo "::add-matcher::.github/actionlint-matcher.json"
2525
bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)

lib/cmetrics/.github/workflows/packages.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
matrix:
1919
format: [ rpm, deb ]
2020
steps:
21-
- uses: actions/checkout@v5
21+
- uses: actions/checkout@v6
2222
with:
2323
submodules: true
2424

@@ -39,7 +39,7 @@ jobs:
3939
echo ${{ matrix.format }} | awk '{print toupper($0)}' | xargs -I{} cpack -G {}
4040
4141
- name: Store the master package artifacts
42-
uses: actions/upload-artifact@v4
42+
uses: actions/upload-artifact@v6
4343
with:
4444
name: ${{ matrix.format }}-arm64
4545
path: |
@@ -54,7 +54,7 @@ jobs:
5454

5555
runs-on: [ ubuntu-latest ]
5656
steps:
57-
- uses: actions/checkout@v5
57+
- uses: actions/checkout@v6
5858
with:
5959
submodules: true
6060

@@ -64,7 +64,7 @@ jobs:
6464
echo ${{ matrix.format }} | awk '{print toupper($0)}' | xargs -I{} cpack -G {}
6565
6666
- name: Store the master package artifacts
67-
uses: actions/upload-artifact@v4
67+
uses: actions/upload-artifact@v6
6868
with:
6969
name: ${{ matrix.format }}-amd64
7070
path: |
@@ -81,7 +81,7 @@ jobs:
8181
ext: pkg
8282
runs-on: macos-14
8383
steps:
84-
- uses: actions/checkout@v5
84+
- uses: actions/checkout@v6
8585
with:
8686
submodules: true
8787

@@ -91,7 +91,7 @@ jobs:
9191
echo ${{ matrix.config.format }} | xargs -I{} cpack -G {}
9292
9393
- name: Store the master package artifacts
94-
uses: actions/upload-artifact@v4
94+
uses: actions/upload-artifact@v6
9595
with:
9696
name: ${{ matrix.config.format }}-${{matrix.config.arch}}
9797
path: |
@@ -109,7 +109,7 @@ jobs:
109109
contents: write
110110
steps:
111111
- name: Download all artefacts
112-
uses: actions/download-artifact@v5
112+
uses: actions/download-artifact@v7
113113
with:
114114
path: artifacts/
115115

lib/cmetrics/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
66
# CMetrics Version
77
set(CMT_VERSION_MAJOR 1)
88
set(CMT_VERSION_MINOR 0)
9-
set(CMT_VERSION_PATCH 5)
9+
set(CMT_VERSION_PATCH 6)
1010
set(CMT_VERSION_STR "${CMT_VERSION_MAJOR}.${CMT_VERSION_MINOR}.${CMT_VERSION_PATCH}")
1111

1212
# Include helpers

lib/cmetrics/src/cmt_cat.c

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,38 @@ static int copy_label_values(struct cmt_metric *metric, char **out)
9696
return i;
9797
}
9898

99-
static inline int cat_histogram_values(struct cmt_metric *metric_dst, struct cmt_histogram *histogram,
100-
struct cmt_metric *metric_src)
99+
static inline int cat_histogram_values(struct cmt_metric *metric_dst, struct cmt_histogram *histogram_src,
100+
struct cmt_metric *metric_src, struct cmt_histogram *histogram_dst)
101101
{
102102
int i;
103+
size_t bucket_count_src;
104+
size_t bucket_count_dst;
103105

106+
/* Validate source histogram buckets exist */
107+
if (!metric_src->hist_buckets) {
108+
/* Source has no bucket data, nothing to concatenate */
109+
return 0;
110+
}
111+
112+
bucket_count_src = histogram_src->buckets->count;
113+
bucket_count_dst = histogram_dst->buckets->count;
114+
115+
/* Validate that source and destination have matching bucket structures */
116+
if (bucket_count_src != bucket_count_dst) {
117+
/* Histogram bucket structures don't match - cannot concatenate */
118+
return -1;
119+
}
120+
121+
/* Allocate destination buckets if needed */
104122
if (!metric_dst->hist_buckets) {
105-
metric_dst->hist_buckets = calloc(1, sizeof(uint64_t) * (histogram->buckets->count + 1));
123+
metric_dst->hist_buckets = calloc(1, sizeof(uint64_t) * (bucket_count_dst + 1));
106124
if (!metric_dst->hist_buckets) {
107125
return -1;
108126
}
109127
}
110128

111-
for (i = 0; i < histogram->buckets->count; i++) {
129+
/* Concatenate bucket values including +Inf bucket at index bucket_count_dst */
130+
for (i = 0; i <= bucket_count_dst; i++) {
112131
/* histogram buckets are always integers, no need to convert them */
113132
metric_dst->hist_buckets[i] += metric_src->hist_buckets[i];
114133
}
@@ -165,7 +184,8 @@ int cmt_cat_copy_map(struct cmt_opts *opts, struct cmt_map *dst, struct cmt_map
165184
struct cmt_metric *metric_dst;
166185
struct cmt_metric *metric_src;
167186
struct cmt_summary *summary;
168-
struct cmt_histogram *histogram;
187+
struct cmt_histogram *histogram_src;
188+
struct cmt_histogram *histogram_dst;
169189

170190
/* Handle static metric (no labels case) */
171191
if (src->metric_static_set) {
@@ -176,8 +196,9 @@ int cmt_cat_copy_map(struct cmt_opts *opts, struct cmt_map *dst, struct cmt_map
176196
metric_src = &src->metric;
177197

178198
if (src->type == CMT_HISTOGRAM) {
179-
histogram = (struct cmt_histogram *) src->parent;
180-
ret = cat_histogram_values(metric_dst, histogram, metric_src);
199+
histogram_src = (struct cmt_histogram *) src->parent;
200+
histogram_dst = (struct cmt_histogram *) dst->parent;
201+
ret = cat_histogram_values(metric_dst, histogram_src, metric_src, histogram_dst);
181202
if (ret == -1) {
182203
return -1;
183204
}
@@ -214,8 +235,9 @@ int cmt_cat_copy_map(struct cmt_opts *opts, struct cmt_map *dst, struct cmt_map
214235
}
215236

216237
if (src->type == CMT_HISTOGRAM) {
217-
histogram = (struct cmt_histogram *) src->parent;
218-
ret = cat_histogram_values(metric_dst, histogram, metric_src);
238+
histogram_src = (struct cmt_histogram *) src->parent;
239+
histogram_dst = (struct cmt_histogram *) dst->parent;
240+
ret = cat_histogram_values(metric_dst, histogram_src, metric_src, histogram_dst);
219241
if (ret == -1) {
220242
return -1;
221243
}

lib/cmetrics/src/cmt_histogram.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct cmt_histogram_buckets *cmt_histogram_buckets_create_size(double *bkts, si
3636
}
3737

3838
/* besides buckets set by the user, we add an implicit bucket for +inf */
39-
upper_bounds = calloc(1, sizeof(double) * count + 1);
39+
upper_bounds = calloc(1, sizeof(double) * (count + 1));
4040
if (!upper_bounds) {
4141
cmt_errno();
4242
return NULL;

0 commit comments

Comments
 (0)