Skip to content

Commit

Permalink
addressed reviewer comments
Browse files Browse the repository at this point in the history
  • Loading branch information
KalmanMeth committed Mar 27, 2023
1 parent fae653a commit 2360488
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Following is the supported API format for prometheus encode:
labels: labels to be associated with the metric
buckets: histogram buckets
prefix: prefix added to each metric name
expiryTime: seconds of no-flow to wait before deleting prometheus data item
expiryTime: time duration of no-flow to wait before deleting prometheus data item
maxMetrics: maximum number of metrics to report (default: unlimited)
</pre>
## Kafka encode API
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/encode_prom.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type PromTLSConf struct {
type PromEncode struct {
Metrics PromMetricsItems `yaml:"metrics,omitempty" json:"metrics,omitempty" doc:"list of prometheus metric definitions, each includes:"`
Prefix string `yaml:"prefix,omitempty" json:"prefix,omitempty" doc:"prefix added to each metric name"`
ExpiryTime Duration `yaml:"expiryTime,omitempty" json:"expiryTime,omitempty" doc:"seconds of no-flow to wait before deleting prometheus data item"`
ExpiryTime Duration `yaml:"expiryTime,omitempty" json:"expiryTime,omitempty" doc:"time duration of no-flow to wait before deleting prometheus data item"`
MaxMetrics int `yaml:"maxMetrics,omitempty" json:"maxMetrics,omitempty" doc:"maximum number of metrics to report (default: unlimited)"`
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/config/pipeline_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ func TestKafkaPromPipeline(t *testing.T) {
GroupByKeys: api.AggregateBy{"srcAS"},
OperationType: "count",
}})
var expirtyTimeDuration api.Duration
expirtyTimeDuration.Duration = time.Duration(50 * time.Second)
var expiryTimeDuration api.Duration
expiryTimeDuration.Duration = time.Duration(50 * time.Second)
pl = pl.EncodePrometheus("prom", api.PromEncode{
Metrics: api.PromMetricsItems{{
Name: "connections_per_source_as",
Expand All @@ -133,7 +133,7 @@ func TestKafkaPromPipeline(t *testing.T) {
Buckets: []float64{},
}},
Prefix: "flp_",
ExpiryTime: expirtyTimeDuration,
ExpiryTime: expiryTimeDuration,
})
stages := pl.GetStages()
require.Len(t, stages, 5)
Expand Down
4 changes: 2 additions & 2 deletions pkg/pipeline/encode/encode_prom.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
log "github.com/sirupsen/logrus"
)

const defaultExpiryTime = time.Duration(2 * time.Second)
const defaultExpiryTime = time.Duration(2 * time.Minute)

type gaugeInfo struct {
gauge *prometheus.GaugeVec
Expand Down Expand Up @@ -268,7 +268,7 @@ func NewEncodeProm(opMetrics *operational.Metrics, params config.StageParam) (En
}

expiryTime := cfg.ExpiryTime
if expiryTime.Seconds() == 0 && expiryTime.Microseconds() == 0 {
if expiryTime.Duration == 0 {
expiryTime.Duration = defaultExpiryTime
}
log.Debugf("expiryTime = %v", expiryTime)
Expand Down
18 changes: 9 additions & 9 deletions pkg/pipeline/encode/encode_prom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ func Test_CustomMetric(t *testing.T) {
"packets": 2,
"latency": 0.2,
}}
var expirtyTimeDuration api.Duration
expirtyTimeDuration.Duration = time.Duration(60 * time.Second)
var expiryTimeDuration api.Duration
expiryTimeDuration.Duration = time.Duration(60 * time.Second)
params := api.PromEncode{
Prefix: "test_",
ExpiryTime: expirtyTimeDuration,
ExpiryTime: expiryTimeDuration,
Metrics: []api.PromMetricsItem{{
Name: "bytes_total",
Type: "counter",
Expand Down Expand Up @@ -230,11 +230,11 @@ func Test_MetricTTL(t *testing.T) {
"bytes": 12,
}}

var expirtyTimeDuration api.Duration
expirtyTimeDuration.Duration = time.Duration(1 * time.Second)
var expiryTimeDuration api.Duration
expiryTimeDuration.Duration = time.Duration(1 * time.Second)
params := api.PromEncode{
Prefix: "test_",
ExpiryTime: expirtyTimeDuration,
ExpiryTime: expiryTimeDuration,
Metrics: []api.PromMetricsItem{{
Name: "bytes_total",
Type: "counter",
Expand Down Expand Up @@ -284,11 +284,11 @@ func hundredFlows() []config.GenericMap {
}

func BenchmarkPromEncode(b *testing.B) {
var expirtyTimeDuration api.Duration
expirtyTimeDuration.Duration = time.Duration(60 * time.Second)
var expiryTimeDuration api.Duration
expiryTimeDuration.Duration = time.Duration(60 * time.Second)
params := api.PromEncode{
Prefix: "test_",
ExpiryTime: expirtyTimeDuration,
ExpiryTime: expiryTimeDuration,
Metrics: []api.PromMetricsItem{{
Name: "bytes_total",
Type: "counter",
Expand Down

0 comments on commit 2360488

Please sign in to comment.