Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/cmetrics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# CMetrics Version
set(CMT_VERSION_MAJOR 0)
set(CMT_VERSION_MINOR 6)
set(CMT_VERSION_PATCH 6)
set(CMT_VERSION_MINOR 7)
set(CMT_VERSION_PATCH 0)
set(CMT_VERSION_STR "${CMT_VERSION_MAJOR}.${CMT_VERSION_MINOR}.${CMT_VERSION_PATCH}")

# Include helpers
Expand Down
11 changes: 11 additions & 0 deletions lib/cmetrics/include/cmetrics/cmt_cat.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@

#include <cmetrics/cmetrics.h>

struct cmt_counter;
struct cmt_gauge;
struct cmt_untyped;
struct cmt_histogram;
struct cmt_summary;

int cmt_cat_counter(struct cmt *cmt, struct cmt_counter *counter);
int cmt_cat_gauge(struct cmt *cmt, struct cmt_gauge *gauge);
int cmt_cat_untyped(struct cmt *cmt, struct cmt_untyped *untyped);
int cmt_cat_histogram(struct cmt *cmt, struct cmt_histogram *histogram);
int cmt_cat_summary(struct cmt *cmt, struct cmt_summary *summary);
int cmt_cat(struct cmt *dst, struct cmt *src);

#endif
43 changes: 43 additions & 0 deletions lib/cmetrics/include/cmetrics/cmt_encode_cloudwatch_emf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/* CMetrics
* ========
* Copyright 2024 The CMetrics Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/


#ifndef CMT_ENCODE_CLOUDWATCH_EMF_H
#define CMT_ENCODE_CLOUDWATCH_EMF_H

#include <time.h>
#include <cfl/cfl.h>
#include <cmetrics/cmetrics.h>

#define CMT_ENCODE_CLOUDWATCH_EMF_SUCCESS 0
#define CMT_ENCODE_CLOUDWATCH_EMF_INVALID_ARGUMENT_ERROR -1
#define CMT_ENCODE_CLOUDWATCH_EMF_CREATION_FAILED -2
#define CMT_ENCODE_CLOUDWATCH_EMF_INVALID_DATA_ERROR -4

/* Metric Unit */
#define CMT_EMF_UNIT_PERCENT "Percent"
#define CMT_EMF_UNIT_BYTES "Bytes"
#define CMT_EMF_UNIT_COUNTER "Counter"

int cmt_encode_cloudwatch_emf_create(struct cmt *cmt,
char **out_buf, size_t *out_size,
int wrap_array);
void cmt_encode_cloudwatch_emf_destroy(char *out_buf);

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@
#include <prometheus_remote_write/remote.pb-c.h>

#define CMT_ENCODE_PROMETHEUS_REMOTE_WRITE_ADD_METADATA CMT_FALSE
#define CMT_ENCODE_PROMETHEUS_REMOTE_WRITE_CUTOFF_THRESHOLD 60L*60L*1000000000L

#define CMT_ENCODE_PROMETHEUS_REMOTE_WRITE_SUCCESS 0
#define CMT_ENCODE_PROMETHEUS_REMOTE_WRITE_ALLOCATION_ERROR 1
#define CMT_ENCODE_PROMETHEUS_REMOTE_WRITE_UNEXPECTED_ERROR 2
#define CMT_ENCODE_PROMETHEUS_REMOTE_WRITE_INVALID_ARGUMENT_ERROR 3
#define CMT_ENCODE_PROMETHEUS_REMOTE_WRITE_UNEXPECTED_METRIC_TYPE 4
#define CMT_ENCODE_PROMETHEUS_REMOTE_WRITE_CUTOFF_ERROR 5

struct cmt_prometheus_metric_metadata {
Prometheus__MetricMetadata data;
Expand Down
41 changes: 41 additions & 0 deletions lib/cmetrics/include/cmetrics/cmt_filter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/* CMetrics
* ========
* Copyright 2021-2024 The CMetrics Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef CMT_FILTER_H
#define CMT_FILTER_H

#include <cmetrics/cmetrics.h>
#include <cmetrics/cmt_cat.h>

#define CMT_FILTER_EXCLUDE (1 << 1)
#define CMT_FILTER_PREFIX (1 << 2)
#define CMT_FILTER_SUBSTRING (1 << 3)
#define CMT_FILTER_REGEX_SEARCH_LABELS (1 << 4)

#define CMT_FILTER_SUCCESS 0
#define CMT_FILTER_INVALID_ARGUMENT -1
#define CMT_FILTER_INVALID_FLAGS -2
#define CMT_FILTER_FAILED_OPERATION -3

int cmt_filter(struct cmt *dst, struct cmt *src,
const char *fqname, const char *label_key,
void *compare_ctx, int (*compare)(void *compare_ctx, const char *str, size_t slen),
int flags);

#endif
2 changes: 2 additions & 0 deletions lib/cmetrics/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ set(src
cmt_time.c
cmt_label.c
cmt_cat.c
cmt_filter.c
cmetrics.c
cmt_encode_opentelemetry.c
cmt_decode_opentelemetry.c
cmt_encode_prometheus.c
cmt_encode_prometheus_remote_write.c
cmt_encode_splunk_hec.c
cmt_encode_cloudwatch_emf.c
cmt_encode_text.c
cmt_encode_influx.c
cmt_encode_msgpack.c
Expand Down
20 changes: 10 additions & 10 deletions lib/cmetrics/src/cmt_cat.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static int copy_map(struct cmt_opts *opts, struct cmt_map *dst, struct cmt_map *

}

static int copy_counter(struct cmt *cmt, struct cmt_counter *counter)
int cmt_cat_counter(struct cmt *cmt, struct cmt_counter *counter)
{
int ret;
char **labels = NULL;
Expand Down Expand Up @@ -213,7 +213,7 @@ static int copy_counter(struct cmt *cmt, struct cmt_counter *counter)
return 0;
}

static int copy_gauge(struct cmt *cmt, struct cmt_gauge *gauge)
int cmt_cat_gauge(struct cmt *cmt, struct cmt_gauge *gauge)
{
int ret;
char **labels = NULL;
Expand Down Expand Up @@ -247,7 +247,7 @@ static int copy_gauge(struct cmt *cmt, struct cmt_gauge *gauge)
return 0;
}

static int copy_untyped(struct cmt *cmt, struct cmt_untyped *untyped)
int cmt_cat_untyped(struct cmt *cmt, struct cmt_untyped *untyped)
{
int ret;
char **labels = NULL;
Expand Down Expand Up @@ -281,7 +281,7 @@ static int copy_untyped(struct cmt *cmt, struct cmt_untyped *untyped)
return 0;
}

static int copy_histogram(struct cmt *cmt, struct cmt_histogram *histogram)
int cmt_cat_histogram(struct cmt *cmt, struct cmt_histogram *histogram)
{
int i;
double val;
Expand Down Expand Up @@ -331,7 +331,7 @@ static int copy_histogram(struct cmt *cmt, struct cmt_histogram *histogram)
return 0;
}

static int copy_summary(struct cmt *cmt, struct cmt_summary *summary)
int cmt_cat_summary(struct cmt *cmt, struct cmt_summary *summary)
{
int i;
int ret;
Expand Down Expand Up @@ -395,7 +395,7 @@ static int append_context(struct cmt *dst, struct cmt *src)
/* Counters */
cfl_list_foreach(head, &src->counters) {
counter = cfl_list_entry(head, struct cmt_counter, _head);
ret = copy_counter(dst, counter);
ret = cmt_cat_counter(dst, counter);
if (ret == -1) {
return -1;
}
Expand All @@ -404,7 +404,7 @@ static int append_context(struct cmt *dst, struct cmt *src)
/* Gauges */
cfl_list_foreach(head, &src->gauges) {
gauge = cfl_list_entry(head, struct cmt_gauge, _head);
ret = copy_gauge(dst, gauge);
ret = cmt_cat_gauge(dst, gauge);
if (ret == -1) {
return -1;
}
Expand All @@ -413,7 +413,7 @@ static int append_context(struct cmt *dst, struct cmt *src)
/* Untyped */
cfl_list_foreach(head, &src->untypeds) {
untyped = cfl_list_entry(head, struct cmt_untyped, _head);
ret = copy_untyped(dst, untyped);
ret = cmt_cat_untyped(dst, untyped);
if (ret == -1) {
return -1;
}
Expand All @@ -422,7 +422,7 @@ static int append_context(struct cmt *dst, struct cmt *src)
/* Histogram */
cfl_list_foreach(head, &src->histograms) {
histogram = cfl_list_entry(head, struct cmt_histogram, _head);
ret = copy_histogram(dst, histogram);
ret = cmt_cat_histogram(dst, histogram);
if (ret == -1) {
return -1;
}
Expand All @@ -431,7 +431,7 @@ static int append_context(struct cmt *dst, struct cmt *src)
/* Summary */
cfl_list_foreach(head, &src->summaries) {
summary = cfl_list_entry(head, struct cmt_summary, _head);
ret = copy_summary(dst, summary);
ret = cmt_cat_summary(dst, summary);
if (ret == -1) {
return -1;
}
Expand Down
Loading