@@ -257,7 +257,7 @@ static void destroy_opentelemetry_context(
257
257
struct cmt_opentelemetry_context * context );
258
258
259
259
static struct cmt_opentelemetry_context * initialize_opentelemetry_context (
260
- struct cmt * cmt );
260
+ struct cmt * cmt , struct cmt_opentelemetry_context_cutoff_opts * opts );
261
261
262
262
static inline Opentelemetry__Proto__Common__V1__AnyValue * cfl_variant_to_otlp_any_value (struct cfl_variant * value );
263
263
static inline Opentelemetry__Proto__Common__V1__KeyValue * cfl_variant_kvpair_to_otlp_kvpair (struct cfl_kvpair * input_pair );
@@ -2138,7 +2138,7 @@ static Opentelemetry__Proto__Resource__V1__Resource *
2138
2138
}
2139
2139
2140
2140
static struct cmt_opentelemetry_context * initialize_opentelemetry_context (
2141
- struct cmt * cmt )
2141
+ struct cmt * cmt , struct cmt_opentelemetry_context_cutoff_opts * opts )
2142
2142
{
2143
2143
struct cfl_kvlist * resource_metrics_root ;
2144
2144
struct cfl_kvlist * scope_metrics_root ;
@@ -2166,6 +2166,8 @@ static struct cmt_opentelemetry_context *initialize_opentelemetry_context(
2166
2166
memset (context , 0 , sizeof (struct cmt_opentelemetry_context ));
2167
2167
2168
2168
context -> cmt = cmt ;
2169
+ context -> use_cutoff = opts -> use_cutoff ;
2170
+ context -> cutoff_threshold = opts -> cutoff_threshold ;
2169
2171
2170
2172
resource = initialize_resource (resource_root , & result );
2171
2173
@@ -2447,8 +2449,9 @@ int pack_basic_type(struct cmt_opentelemetry_context *context,
2447
2449
& map -> metric ,
2448
2450
sample_index ++ );
2449
2451
2450
- if (check_staled_timestamp (& map -> metric , now ,
2451
- CMT_ENCODE_OPENTELEMETRY_CUTOFF_THRESHOLD )) {
2452
+ if (context -> use_cutoff == CMT_TRUE &&
2453
+ check_staled_timestamp (& map -> metric , now ,
2454
+ context -> cutoff_threshold )) {
2452
2455
destroy_metric (metric );
2453
2456
2454
2457
/* Skip processing metrics which are staled over the threshold */
@@ -2465,8 +2468,9 @@ int pack_basic_type(struct cmt_opentelemetry_context *context,
2465
2468
cfl_list_foreach (head , & map -> metrics ) {
2466
2469
sample = cfl_list_entry (head , struct cmt_metric , _head );
2467
2470
2468
- if (check_staled_timestamp (& map -> metric , now ,
2469
- CMT_ENCODE_OPENTELEMETRY_CUTOFF_THRESHOLD )) {
2471
+ if (context -> use_cutoff == CMT_TRUE &&
2472
+ check_staled_timestamp (& map -> metric , now ,
2473
+ context -> cutoff_threshold )) {
2470
2474
destroy_metric (metric );
2471
2475
2472
2476
/* Skip processing metrics which are staled over the threshold */
@@ -2527,7 +2531,8 @@ static cfl_sds_t render_opentelemetry_context_to_sds(
2527
2531
return result_buffer ;
2528
2532
}
2529
2533
2530
- cfl_sds_t cmt_encode_opentelemetry_create (struct cmt * cmt )
2534
+ cfl_sds_t cmt_encode_opentelemetry_create_with_cutoff_opts (struct cmt * cmt ,
2535
+ struct cmt_opentelemetry_context_cutoff_opts * opts )
2531
2536
{
2532
2537
size_t metric_index ;
2533
2538
struct cmt_opentelemetry_context * context ;
@@ -2543,7 +2548,7 @@ cfl_sds_t cmt_encode_opentelemetry_create(struct cmt *cmt)
2543
2548
buf = NULL ;
2544
2549
result = 0 ;
2545
2550
2546
- context = initialize_opentelemetry_context (cmt );
2551
+ context = initialize_opentelemetry_context (cmt , opts );
2547
2552
2548
2553
if (context == NULL ) {
2549
2554
return NULL ;
@@ -2638,6 +2643,24 @@ cfl_sds_t cmt_encode_opentelemetry_create(struct cmt *cmt)
2638
2643
return buf ;
2639
2644
}
2640
2645
2646
+ cfl_sds_t cmt_encode_opentelemetry_create_with_cutoff (struct cmt * cmt , int use_cutoff )
2647
+ {
2648
+ struct cmt_opentelemetry_context_cutoff_opts opts ;
2649
+ opts .use_cutoff = use_cutoff ;
2650
+ opts .cutoff_threshold = CMT_ENCODE_OPENTELEMETRY_CUTOFF_THRESHOLD ;
2651
+
2652
+ return cmt_encode_opentelemetry_create_with_cutoff_opts (cmt , & opts );
2653
+ }
2654
+
2655
+ cfl_sds_t cmt_encode_opentelemetry_create (struct cmt * cmt )
2656
+ {
2657
+ struct cmt_opentelemetry_context_cutoff_opts opts ;
2658
+ opts .use_cutoff = CMT_FALSE ;
2659
+ opts .cutoff_threshold = CMT_ENCODE_OPENTELEMETRY_CUTOFF_DISABLED ;
2660
+
2661
+ return cmt_encode_opentelemetry_create_with_cutoff_opts (cmt , & opts );
2662
+ }
2663
+
2641
2664
void cmt_encode_opentelemetry_destroy (cfl_sds_t text )
2642
2665
{
2643
2666
cfl_sds_destroy (text );
0 commit comments