Skip to content

Commit

Permalink
Change metricKind config from int to string to improve readability (#209
Browse files Browse the repository at this point in the history
)

Signed-off-by: Daxin Wang <daxinwang@harmonycloud.cn>
  • Loading branch information
dxsup authored May 6, 2022
1 parent 26fd823 commit 737c811
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 63 deletions.
25 changes: 14 additions & 11 deletions collector/application/testdata/kindling-collector-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions collector/consumer/exporter/otelexporter/agg_kind.go
Original file line number Diff line number Diff line change
@@ -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"
)
24 changes: 14 additions & 10 deletions collector/consumer/exporter/otelexporter/instrument_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
24 changes: 14 additions & 10 deletions collector/consumer/exporter/otelexporter/otelexporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
28 changes: 14 additions & 14 deletions collector/deploy/kindling-collector-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 14 additions & 14 deletions deploy/kindling-collector-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 737c811

Please sign in to comment.