-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle delta temporality and some code refactoring #4410
Conversation
7e49045
to
1e799ae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments, but no big changes
src/rdkafka_int.h
Outdated
@@ -267,6 +267,13 @@ static RD_UNUSED const char *rd_kafka_type2str(rd_kafka_type_t type) { | |||
return types[type]; | |||
} | |||
|
|||
typedef enum { | |||
METRIC_CONNECTION_CREATION_TOTAL, | |||
METRIC_CONNECTION_CREATION_RATE, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefix enum names with RD_KAFKA_TELEMETRY_
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
src/rdkafka_int.h
Outdated
METRIC_CONNECTION_CREATION_TOTAL, | ||
METRIC_CONNECTION_CREATION_RATE, | ||
// add more metrics here | ||
METRIC_COUNT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: in most places, the last element is named something like __CNT, would make sense to do that here too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
src/rdkafka_telemetry_encode.h
Outdated
@@ -29,6 +29,11 @@ | |||
#ifndef _RDKAFKA_RDKAFKA_TELEMETRY_ENCODE_H | |||
#define _RDKAFKA_RDKAFKA_TELEMETRY_ENCODE_H | |||
|
|||
typedef enum { | |||
METRIC_TYPE_SUM, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as earlier, prefix with RD_KAFKA_TELEMETRY
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
src/rdkafka_telemetry.c
Outdated
@@ -112,6 +115,27 @@ static void rd_kafka_telemetry_set_terminated(rd_kafka_t *rk) { | |||
mtx_unlock(&rk->rk_telemetry.lock); | |||
} | |||
|
|||
static rd_kafka_telemetry_metric_name_t * | |||
rd_kafka_match_requested_metrics(rd_kafka_t *rk) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are returning rd_kafka_telemetry_metric_name_t*, we should return the size as well (by populating a size_t pointer) and take the requested metrics as a pointer (ie make this a 'pure' function), or else we should modify rk->rk_telemetry.matched_metrics inside the function itself and return void - currently we do things half-way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Updated to return void and modify matched_metrics inside the function itself.
src/rdkafka_telemetry.c
Outdated
@@ -209,8 +232,7 @@ static void rd_kafka_send_push_telemetry(rd_kafka_t *rk, | |||
metrics_payload, metrics_payload_size, | |||
NULL, 0, RD_KAFKA_REPLYQ(rk->rk_ops, 0), | |||
rd_kafka_handle_PushTelemetry, NULL); | |||
rd_free(metrics_payload); | |||
|
|||
rd_free((void *)metrics_payload); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove const from const void *metrics_payload
instead of making this cast here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
src/rdkafka_telemetry_encode.c
Outdated
switch (METRICS[metrics_to_encode[i]].type) { | ||
|
||
case METRIC_TYPE_SUM: { | ||
sum = rd_malloc( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use rd_calloc rather than memset
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
src/rdkafka_telemetry_encode.c
Outdated
break; | ||
} | ||
case METRIC_TYPE_GAUGE: { | ||
gauge = rd_malloc( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use rd_calloc rather than memset
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
src/rdkafka_telemetry_encode.c
Outdated
sum->is_monotonic = true; | ||
metrics[i]->which_data = | ||
opentelemetry_proto_metrics_v1_Metric_sum_tag; | ||
metrics[i]->data.sum = *sum; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we allocate a new sum
rather than changing this directly?
Like metrics[i]->data.sum.data_points.funcs.encode = ...
and so on?
Same for gauge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Updated for both
break; | ||
} | ||
default: | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rd_assert(!*"<some error message saying this should be impossible>");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/rdkafka_telemetry_encode.c
Outdated
metric_name_len = strlen(metric_type_str) + | ||
strlen(METRICS[metrics_to_encode[i]].name) + | ||
2; | ||
metric_names[i] = rd_malloc(metric_name_len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rd_calloc rather than malloc and memset
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
625b4e2
to
11874b2
Compare
11874b2
to
27dd974
Compare
No description provided.