Skip to content

Commit a04fa91

Browse files
committed
lib: cmetrics: upgrade from v0.3.5 to v0.3.6
Signed-off-by: Eduardo Silva <[email protected]>
1 parent 6e8695f commit a04fa91

28 files changed

+916
-205
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "actionlint",
5+
"pattern": [
6+
{
7+
"regexp": "^(?:\\x1b\\[\\d+m)?(.+?)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*: (?:\\x1b\\[\\d+m)*(.+?)(?:\\x1b\\[\\d+m)* \\[(.+?)\\]$",
8+
"file": 1,
9+
"line": 2,
10+
"column": 3,
11+
"message": 4,
12+
"code": 5
13+
}
14+
]
15+
}
16+
]
17+
}

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

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
name: Build PR(s) and master branch.
22
on:
3+
workflow_dispatch:
34
push:
45
branches:
56
- master
@@ -15,6 +16,8 @@ jobs:
1516
fail-fast: false
1617
matrix:
1718
os: [windows-latest, windows-2019]
19+
permissions:
20+
contents: read
1821
steps:
1922
- uses: actions/checkout@v3
2023
- name: Build on ${{ matrix.os }} with vs-2019
@@ -28,14 +31,13 @@ jobs:
2831
name: CentOS 7 build to confirm no issues once used downstream
2932
runs-on: ubuntu-latest
3033
container: centos:7
34+
permissions:
35+
contents: read
3136
steps:
3237
- name: Set up base image dependencies
3338
run: |
3439
yum -y update && \
35-
yum install -y rpm-build curl ca-certificates gcc gcc-c++ cmake make bash \
36-
wget unzip systemd-devel wget flex bison \
37-
cyrus-sasl-lib cyrus-sasl-devel openssl openss-libs openssl-devel \
38-
postgresql-libs postgresql-devel postgresql-server postgresql && \
40+
yum install -y rpm-build curl ca-certificates gcc gcc-c++ cmake make wget && \
3941
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && \
4042
rpm -ivh epel-release-latest-7.noarch.rpm && \
4143
yum install -y cmake3
@@ -55,6 +57,8 @@ jobs:
5557
matrix:
5658
os: [ubuntu-latest]
5759
compiler: [ gcc, clang ]
60+
permissions:
61+
contents: read
5862
steps:
5963
- uses: actions/checkout@v3
6064
- name: Build on ${{ matrix.os }} with ${{ matrix.compiler }}
@@ -75,6 +79,7 @@ jobs:
7579
CTEST_OUTPUT_ON_FAILURE=1 make test
7680
env:
7781
CC: ${{ matrix.compiler }}
82+
7883
build-unix-amd64:
7984
name: Build sources on amd64 for ${{ matrix.os }} - ${{ matrix.compiler }}
8085
runs-on: ${{ matrix.os }}
@@ -83,6 +88,8 @@ jobs:
8388
matrix:
8489
os: [ubuntu-latest, macos-latest]
8590
compiler: [ gcc, clang ]
91+
permissions:
92+
contents: read
8693
steps:
8794
- uses: actions/checkout@v3
8895
- name: Build on ${{ matrix.os }} with ${{ matrix.compiler }}
@@ -93,3 +100,27 @@ jobs:
93100
CTEST_OUTPUT_ON_FAILURE=1 make test
94101
env:
95102
CC: ${{ matrix.compiler }}
103+
104+
build-analysis-tests:
105+
name: Build with various code analysis tools
106+
strategy:
107+
fail-fast: false
108+
matrix:
109+
preset:
110+
- clang-sanitize-address
111+
- clang-sanitize-memory
112+
- clang-sanitize-undefined
113+
- clang-sanitize-dataflow
114+
- clang-sanitize-safe-stack
115+
- valgrind
116+
permissions:
117+
contents: read
118+
runs-on: ubuntu-latest
119+
steps:
120+
- uses: actions/checkout@v3
121+
- uses: docker://lpenz/ghaction-cmake:0.19
122+
with:
123+
preset: ${{ matrix.preset }}
124+
# dependencies_debian: ''
125+
cmakeflags: '-DCMT_TESTS=On -DCMT_DEV=on .'
126+
build_command: make all
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Lint PRs
2+
on:
3+
pull_request:
4+
workflow_dispatch:
5+
6+
jobs:
7+
shellcheck:
8+
runs-on: ubuntu-latest
9+
name: Shellcheck
10+
permissions:
11+
contents: read
12+
steps:
13+
- uses: actions/checkout@v3
14+
- uses: ludeeus/action-shellcheck@master
15+
16+
actionlint:
17+
runs-on: ubuntu-latest
18+
name: Actionlint
19+
permissions:
20+
contents: read
21+
steps:
22+
- uses: actions/checkout@v3
23+
- run: |
24+
echo "::add-matcher::.github/actionlint-matcher.json"
25+
bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
26+
./actionlint -color -shellcheck=
27+
shell: bash
28+

lib/cmetrics/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
build/*
33
include/cmetrics/cmt_info.h
44
include/cmetrics/cmt_version.h
5+
LICENSE.txt
6+
README.html
7+
welcome.txt

lib/cmetrics/.mdlrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
style "#{File.dirname(__FILE__)}/markdownlint.rb"

lib/cmetrics/CMakeLists.txt

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,15 @@ endif()
3131
# CMetrics Version
3232
set(CMT_VERSION_MAJOR 0)
3333
set(CMT_VERSION_MINOR 3)
34-
set(CMT_VERSION_PATCH 5)
34+
set(CMT_VERSION_PATCH 6)
3535
set(CMT_VERSION_STR "${CMT_VERSION_MAJOR}.${CMT_VERSION_MINOR}.${CMT_VERSION_PATCH}")
3636

37-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__FILENAME__=__FILE__")
37+
# Define __FILENAME__ consistently across Operating Systems
38+
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows")
39+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'")
40+
else()
41+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__FILENAME__=__FILE__")
42+
endif()
3843

3944
# Configuration options
4045
option(CMT_DEV "Enable development mode" No)
@@ -295,19 +300,19 @@ if(CMT_SYSTEM_MACOS)
295300

296301
if (CPACK_GENERATOR MATCHES "productbuild")
297302
set(CPACK_SET_DESTDIR "ON")
298-
configure_file(cpack/macos/welcome.txt.cmakein ${CMAKE_CURRENT_BINARY_DIR}/welcome.txt)
299-
configure_file(LICENSE ${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt)
303+
configure_file(cpack/macos/welcome.txt.cmakein ${CMAKE_CURRENT_SOURCE_DIR}/welcome.txt)
304+
configure_file(LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt)
300305
find_program(CONVERTER textutil)
301306
if (NOT CONVERTER)
302307
message(FATAL_ERROR "textutil not found.")
303308
endif()
304309
if (CONVERTER)
305-
execute_process(COMMAND ${CONVERTER} -convert html "${CMAKE_SOURCE_DIR}/README.md" -output "${CMAKE_BINARY_DIR}/README.html")
310+
execute_process(COMMAND ${CONVERTER} -convert html "${CMAKE_CURRENT_SOURCE_DIR}/README.md" -output "${CMAKE_CURRENT_SOURCE_DIR}/README.html")
306311
endif()
307312
set(CPACK_PACKAGE_FILE_NAME "${CMETRICS_PKG}")
308-
set(CPACK_RESOURCE_FILE_WELCOME ${CMAKE_CURRENT_BINARY_DIR}/welcome.txt)
309-
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt)
310-
set(CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_BINARY_DIR}/README.html)
313+
set(CPACK_RESOURCE_FILE_WELCOME ${CMAKE_CURRENT_SOURCE_DIR}/welcome.txt)
314+
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt)
315+
set(CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_SOURCE_DIR}/README.html)
311316
set(CPACK_PRODUCTBUILD_IDENTIFIER "com.calyptia.${CPACK_PACKAGE_NAME}")
312317
endif()
313318
endif()

lib/cmetrics/include/cmetrics/cmt_decode_prometheus.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
#include <stdbool.h>
2424

25-
#include "monkey/mk_core/mk_list.h"
2625
#include <cmetrics/cmetrics.h>
2726
#include <stdint.h>
2827

@@ -35,6 +34,8 @@
3534
#define CMT_DECODE_PROMETHEUS_PARSE_VALUE_FAILED 60
3635
#define CMT_DECODE_PROMETHEUS_PARSE_TIMESTAMP_FAILED 70
3736

37+
#define CMT_DECODE_PROMETHEUS_DUPLICATE_SUM_COUNT 10000
38+
3839
#define CMT_DECODE_PROMETHEUS_MAX_LABEL_COUNT 128
3940

4041
enum cmt_decode_prometheus_context_sample_type {
@@ -74,6 +75,10 @@ struct cmt_decode_prometheus_parse_opts {
7475
};
7576

7677
struct cmt_decode_prometheus_context {
78+
union {
79+
struct cmt_summary *summary;
80+
struct cmt_histogram *histogram;
81+
} current;
7782
struct cmt *cmt;
7883
struct cmt_decode_prometheus_parse_opts opts;
7984
int errcode;

lib/cmetrics/markdownlint.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/ruby
2+
3+
# Enable all rules by default
4+
all
5+
6+
# Extend line length, since each sentence should be on a separate line.
7+
rule 'MD013', :line_length => 99999, :ignore_code_blocks => true
8+
9+
# Allow in-line HTML
10+
exclude_rule 'MD033'
11+
12+
# Nested lists should be indented with two spaces.
13+
rule 'MD007', :indent => 2
14+
15+
# Bash defaulting confuses this and now way to ignore code blocks
16+
exclude_rule 'MD029'

lib/cmetrics/src/cmt_decode_opentelemetry.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static struct cmt_variant *clone_variant(Opentelemetry__Proto__Common__V1__AnyVa
4949
{
5050
struct cmt_kvlist *new_child_kvlist;
5151
struct cmt_array *new_child_array;
52-
struct cmt_variant *result_instance;
52+
struct cmt_variant *result_instance = NULL;
5353
int result;
5454

5555
if (source->value_case == OPENTELEMETRY__PROTO__COMMON__V1__ANY_VALUE__VALUE_STRING_VALUE) {
@@ -111,7 +111,7 @@ static struct cmt_variant *clone_variant(Opentelemetry__Proto__Common__V1__AnyVa
111111
}
112112
}
113113
else if (source->value_case == OPENTELEMETRY__PROTO__COMMON__V1__ANY_VALUE__VALUE_BYTES_VALUE) {
114-
result_instance = cmt_variant_create_from_bytes(source->bytes_value.data, source->bytes_value.len);
114+
result_instance = cmt_variant_create_from_bytes((char *) source->bytes_value.data, source->bytes_value.len);
115115
}
116116

117117
return result_instance;
@@ -449,7 +449,7 @@ static int decode_data_point_labels(struct cmt *cmt,
449449
}
450450
else if (attribute->value->value_case == OPENTELEMETRY__PROTO__COMMON__V1__ANY_VALUE__VALUE_BYTES_VALUE) {
451451
result = append_new_metric_label_value(metric,
452-
attribute->value->bytes_value.data,
452+
(char *) attribute->value->bytes_value.data,
453453
attribute->value->bytes_value.len);
454454
}
455455
else if (attribute->value->value_case == OPENTELEMETRY__PROTO__COMMON__V1__ANY_VALUE__VALUE_BOOL_VALUE) {
@@ -458,7 +458,7 @@ static int decode_data_point_labels(struct cmt *cmt,
458458
result = append_new_metric_label_value(metric, dummy_label_value, 0);
459459
}
460460
else if (attribute->value->value_case == OPENTELEMETRY__PROTO__COMMON__V1__ANY_VALUE__VALUE_INT_VALUE) {
461-
snprintf(dummy_label_value, sizeof(dummy_label_value) - 1, PRIi64, attribute->value->int_value);
461+
snprintf(dummy_label_value, sizeof(dummy_label_value) - 1, "%" PRIi64, attribute->value->int_value);
462462

463463
result = append_new_metric_label_value(metric, dummy_label_value, 0);
464464
}
@@ -542,7 +542,7 @@ static int decode_numerical_data_point(struct cmt *cmt,
542542
value = data_point->as_double;
543543
}
544544

545-
cmt_metric_set(sample, data_point->time_unix_nano, data_point->as_double);
545+
cmt_metric_set(sample, data_point->time_unix_nano, value);
546546
}
547547

548548
return result;
@@ -1099,7 +1099,8 @@ int cmt_decode_opentelemetry_create(struct cmt **out_cmt, char *in_buf, size_t i
10991099
return result;
11001100
}
11011101

1102-
service_request = opentelemetry__proto__collector__metrics__v1__export_metrics_service_request__unpack(NULL, in_size - *offset, &in_buf[*offset]);
1102+
service_request = opentelemetry__proto__collector__metrics__v1__export_metrics_service_request__unpack(NULL, in_size - *offset,
1103+
(unsigned char *) &in_buf[*offset]);
11031104

11041105
if (service_request != NULL) {
11051106
result = decode_service_request(cmt, service_request);

0 commit comments

Comments
 (0)