From 737c811ae8cad0fa648a5ecac46ebf06ba266199 Mon Sep 17 00:00:00 2001 From: Daxin Wang <46807570+dxsup@users.noreply.github.com> Date: Fri, 6 May 2022 14:03:10 +0800 Subject: [PATCH] Change metricKind config from int to string to improve readability (#209) Signed-off-by: Daxin Wang --- .../testdata/kindling-collector-config.yaml | 25 +++++++++-------- .../exporter/otelexporter/agg_kind.go | 8 +++--- .../exporter/otelexporter/instrument_test.go | 24 +++++++++------- .../otelexporter/otelexporter_test.go | 24 +++++++++------- .../deploy/kindling-collector-config.yml | 28 +++++++++---------- deploy/kindling-collector-config.yml | 28 +++++++++---------- 6 files changed, 74 insertions(+), 63 deletions(-) diff --git a/collector/application/testdata/kindling-collector-config.yaml b/collector/application/testdata/kindling-collector-config.yaml index 134a1ca21..866b17262 100644 --- a/collector/application/testdata/kindling-collector-config.yaml +++ b/collector/application/testdata/kindling-collector-config.yaml @@ -68,17 +68,20 @@ processors: exporters: otelexporter: metric_aggregation_map: - kindling_entity_request_duration_nanoseconds: 2 - kindling_entity_request_send_bytes_total: 1 - kindling_entity_request_receive_bytes_total: 1 - kindling_topology_request_duration_nanoseconds: 2 - kindling_topology_request_request_bytes_total: 1 - kindling_topology_request_response_bytes_total: 1 - kindling_trace_request_duration_nanoseconds: 0 - kindling_tcp_srtt_microseconds: 0 - kindling_tcp_retransmit_total: 1 - kindling_tcp_packet_loss_total: 1 - kindling_node_transmit_bytes_total: 1 + kindling_entity_request_total: counter + kindling_entity_request_duration_nanoseconds_total: counter + kindling_entity_request_average_duration_nanoseconds: histogram + kindling_entity_request_send_bytes_total: counter + kindling_entity_request_receive_bytes_total: counter + kindling_topology_request_total: counter + kindling_topology_request_duration_nanoseconds_total: counter + kindling_topology_request_average_duration_nanoseconds: histogram + kindling_topology_request_request_bytes_total: counter + kindling_topology_request_response_bytes_total: counter + kindling_trace_request_duration_nanoseconds: gauge + kindling_tcp_srtt_microseconds: gauge + kindling_tcp_retransmit_total: counter + kindling_tcp_packet_loss_total: counter export_kind: prometheus custom_labels: job: test-hcmine diff --git a/collector/consumer/exporter/otelexporter/agg_kind.go b/collector/consumer/exporter/otelexporter/agg_kind.go index 143fad3a4..0d1a99af4 100644 --- a/collector/consumer/exporter/otelexporter/agg_kind.go +++ b/collector/consumer/exporter/otelexporter/agg_kind.go @@ -1,9 +1,9 @@ package otelexporter -type MetricAggregationKind int32 +type MetricAggregationKind string const ( - MAGaugeKind MetricAggregationKind = iota - MACounterKind - MAHistogramKind + MAGaugeKind MetricAggregationKind = "gauge" + MACounterKind MetricAggregationKind = "counter" + MAHistogramKind MetricAggregationKind = "histogram" ) diff --git a/collector/consumer/exporter/otelexporter/instrument_test.go b/collector/consumer/exporter/otelexporter/instrument_test.go index 23d4931de..deccddb3d 100644 --- a/collector/consumer/exporter/otelexporter/instrument_test.go +++ b/collector/consumer/exporter/otelexporter/instrument_test.go @@ -26,16 +26,20 @@ func Test_instrumentFactory_recordLastValue(t *testing.T) { StdoutCfg: &StdoutConfig{CollectPeriod: 10 * time.Second}, CustomLabels: nil, MetricAggregationMap: map[string]MetricAggregationKind{ - "kindling_entity_request_duration_nanoseconds": 2, - "kindling_entity_request_send_bytes_total": 1, - "kindling_entity_request_receive_bytes_total": 1, - "kindling_topology_request_duration_nanoseconds_total": 2, - "kindling_topology_request_request_bytes_total": 1, - "kindling_topology_request_response_bytes_total": 1, - "kindling_trace_request_duration_nanoseconds": 0, - "kindling_tcp_srtt_microseconds": 0, - "kindling_tcp_retransmit_total": 1, - "kindling_tcp_packet_loss_total": 1, + "kindling_entity_request_total": MACounterKind, + "kindling_entity_request_duration_nanoseconds_total": MACounterKind, + "kindling_entity_request_average_duration_nanoseconds": MAHistogramKind, + "kindling_entity_request_send_bytes_total": MACounterKind, + "kindling_entity_request_receive_bytes_total": MACounterKind, + "kindling_topology_request_total": MACounterKind, + "kindling_topology_request_duration_nanoseconds_total": MACounterKind, + "kindling_topology_request_average_duration_nanoseconds": MAHistogramKind, + "kindling_topology_request_request_bytes_total": MACounterKind, + "kindling_topology_request_response_bytes_total": MACounterKind, + "kindling_trace_request_duration_nanoseconds": MAGaugeKind, + "kindling_tcp_srtt_microseconds": MAGaugeKind, + "kindling_tcp_retransmit_total": MACounterKind, + "kindling_tcp_packet_loss_total": MACounterKind, }, AdapterConfig: &AdapterConfig{ NeedTraceAsResourceSpan: true, diff --git a/collector/consumer/exporter/otelexporter/otelexporter_test.go b/collector/consumer/exporter/otelexporter/otelexporter_test.go index 5ffd32a58..c5e45c049 100644 --- a/collector/consumer/exporter/otelexporter/otelexporter_test.go +++ b/collector/consumer/exporter/otelexporter/otelexporter_test.go @@ -171,16 +171,20 @@ func BenchmarkOtelExporter_Consume(b *testing.B) { StdoutCfg: &StdoutConfig{CollectPeriod: 30 * time.Second}, CustomLabels: nil, MetricAggregationMap: map[string]MetricAggregationKind{ - "kindling_entity_request_duration_nanoseconds": 2, - "kindling_entity_request_send_bytes_total": 1, - "kindling_entity_request_receive_bytes_total": 1, - "kindling_topology_request_duration_nanoseconds_total": 2, - "kindling_topology_request_request_bytes_total": 1, - "kindling_topology_request_response_bytes_total": 1, - "kindling_trace_request_duration_nanoseconds": 0, - "kindling_tcp_rtt_milliseconds": 0, - "kindling_tcp_retransmit_total": 1, - "kindling_tcp_packet_loss_total": 1, + "kindling_entity_request_total": MACounterKind, + "kindling_entity_request_duration_nanoseconds_total": MACounterKind, + "kindling_entity_request_average_duration_nanoseconds": MAHistogramKind, + "kindling_entity_request_send_bytes_total": MACounterKind, + "kindling_entity_request_receive_bytes_total": MACounterKind, + "kindling_topology_request_total": MACounterKind, + "kindling_topology_request_duration_nanoseconds_total": MACounterKind, + "kindling_topology_request_average_duration_nanoseconds": MAHistogramKind, + "kindling_topology_request_request_bytes_total": MACounterKind, + "kindling_topology_request_response_bytes_total": MACounterKind, + "kindling_trace_request_duration_nanoseconds": MAGaugeKind, + "kindling_tcp_srtt_microseconds": MAGaugeKind, + "kindling_tcp_retransmit_total": MACounterKind, + "kindling_tcp_packet_loss_total": MACounterKind, }, AdapterConfig: &AdapterConfig{ NeedTraceAsResourceSpan: true, diff --git a/collector/deploy/kindling-collector-config.yml b/collector/deploy/kindling-collector-config.yml index b80d32f15..a26d5a936 100644 --- a/collector/deploy/kindling-collector-config.yml +++ b/collector/deploy/kindling-collector-config.yml @@ -107,20 +107,20 @@ exporters: # send trace data in the format of ResourceSpan need_trace_as_span: false metric_aggregation_map: - kindling_entity_request_total: 1 - kindling_entity_request_duration_nanoseconds_total: 1 - kindling_entity_request_average_duration_nanoseconds: 2 - kindling_entity_request_send_bytes_total: 1 - kindling_entity_request_receive_bytes_total: 1 - kindling_topology_request_total: 1 - kindling_topology_request_duration_nanoseconds_total: 1 - kindling_topology_request_average_duration_nanoseconds: 2 - kindling_topology_request_request_bytes_total: 1 - kindling_topology_request_response_bytes_total: 1 - kindling_trace_request_duration_nanoseconds: 0 - kindling_tcp_srtt_microseconds: 0 - kindling_tcp_retransmit_total: 1 - kindling_tcp_packet_loss_total: 1 + kindling_entity_request_total: counter + kindling_entity_request_duration_nanoseconds_total: counter + kindling_entity_request_average_duration_nanoseconds: histogram + kindling_entity_request_send_bytes_total: counter + kindling_entity_request_receive_bytes_total: counter + kindling_topology_request_total: counter + kindling_topology_request_duration_nanoseconds_total: counter + kindling_topology_request_average_duration_nanoseconds: histogram + kindling_topology_request_request_bytes_total: counter + kindling_topology_request_response_bytes_total: counter + kindling_trace_request_duration_nanoseconds: gauge + kindling_tcp_srtt_microseconds: gauge + kindling_tcp_retransmit_total: counter + kindling_tcp_packet_loss_total: counter # Export data in the following ways: ["prometheus", "otlp", "stdout"] # Note: configure the corresponding section to make everything ok export_kind: prometheus diff --git a/deploy/kindling-collector-config.yml b/deploy/kindling-collector-config.yml index 58612bccb..c4c81902f 100644 --- a/deploy/kindling-collector-config.yml +++ b/deploy/kindling-collector-config.yml @@ -107,20 +107,20 @@ exporters: # send trace data in the format of ResourceSpan need_trace_as_span: false metric_aggregation_map: - kindling_entity_request_total: 1 - kindling_entity_request_duration_nanoseconds_total: 1 - kindling_entity_request_average_duration_nanoseconds: 2 - kindling_entity_request_send_bytes_total: 1 - kindling_entity_request_receive_bytes_total: 1 - kindling_topology_request_total: 1 - kindling_topology_request_duration_nanoseconds_total: 1 - kindling_topology_request_average_duration_nanoseconds: 2 - kindling_topology_request_request_bytes_total: 1 - kindling_topology_request_response_bytes_total: 1 - kindling_trace_request_duration_nanoseconds: 0 - kindling_tcp_srtt_microseconds: 0 - kindling_tcp_retransmit_total: 1 - kindling_tcp_packet_loss_total: 1 + kindling_entity_request_total: counter + kindling_entity_request_duration_nanoseconds_total: counter + kindling_entity_request_average_duration_nanoseconds: histogram + kindling_entity_request_send_bytes_total: counter + kindling_entity_request_receive_bytes_total: counter + kindling_topology_request_total: counter + kindling_topology_request_duration_nanoseconds_total: counter + kindling_topology_request_average_duration_nanoseconds: histogram + kindling_topology_request_request_bytes_total: counter + kindling_topology_request_response_bytes_total: counter + kindling_trace_request_duration_nanoseconds: gauge + kindling_tcp_srtt_microseconds: gauge + kindling_tcp_retransmit_total: counter + kindling_tcp_packet_loss_total: counter # Export data in the following ways: ["prometheus", "otlp", "stdout"] # Note: configure the corresponding section to make everything ok export_kind: prometheus