Skip to content

Handle delta temporality and some code refactoring#4410

Merged
Anchit Jain (anchitj) merged 6 commits intodev_kip_714from
dev_kip_714_delta
Aug 29, 2023
Merged

Handle delta temporality and some code refactoring#4410
Anchit Jain (anchitj) merged 6 commits intodev_kip_714from
dev_kip_714_delta

Conversation

@anchitj
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Contributor

@milindl Milind L (milindl) left a 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

Comment thread src/rdkafka_int.h Outdated

typedef enum {
METRIC_CONNECTION_CREATION_TOTAL,
METRIC_CONNECTION_CREATION_RATE,
Copy link
Copy Markdown
Contributor

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_

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Comment thread src/rdkafka_int.h Outdated
METRIC_CONNECTION_CREATION_TOTAL,
METRIC_CONNECTION_CREATION_RATE,
// add more metrics here
METRIC_COUNT
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Comment thread src/rdkafka_telemetry_encode.h Outdated
#define _RDKAFKA_RDKAFKA_TELEMETRY_ENCODE_H

typedef enum {
METRIC_TYPE_SUM,
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Comment thread src/rdkafka_telemetry.c Outdated
}

static rd_kafka_telemetry_metric_name_t *
rd_kafka_match_requested_metrics(rd_kafka_t *rk) {
Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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.

Comment thread src/rdkafka_telemetry.c Outdated
rd_kafka_handle_PushTelemetry, NULL);
rd_free(metrics_payload);

rd_free((void *)metrics_payload);
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Comment thread src/rdkafka_telemetry_encode.c Outdated
switch (METRICS[metrics_to_encode[i]].type) {

case METRIC_TYPE_SUM: {
sum = rd_malloc(
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Comment thread src/rdkafka_telemetry_encode.c Outdated
break;
}
case METRIC_TYPE_GAUGE: {
gauge = rd_malloc(
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Comment thread 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;
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

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;
Copy link
Copy Markdown
Contributor

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>");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread 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);
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@anchitj Anchit Jain (anchitj) force-pushed the dev_kip_714_delta branch 2 times, most recently from 625b4e2 to 11874b2 Compare August 28, 2023 12:23
@anchitj Anchit Jain (anchitj) merged commit 5c943ba into dev_kip_714 Aug 29, 2023
@anchitj Anchit Jain (anchitj) deleted the dev_kip_714_delta branch August 29, 2023 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants