Skip to content

Commit

Permalink
factor feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jpinsonneau committed Aug 17, 2023
1 parent 29bc5d5 commit 8a51781
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions pkg/loki/topology_query.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package loki

import (
"fmt"
"strings"

"github.com/netobserv/network-observability-console-plugin/pkg/utils"
Expand All @@ -24,7 +23,7 @@ type Topology struct {
skipNonDNS bool
skipEmptyDNSRCode bool
skipEmptyRTT bool
factor float64
factor string
}

type TopologyQueryBuilder struct {
Expand All @@ -42,7 +41,7 @@ func NewTopologyQuery(cfg *Config, start, end, limit, rateInterval, step string,

fields := getFields(aggregate, groups)
var f, t string
factor := 1.0
factor := ""
switch metricType {
case constants.MetricTypeCount, constants.MetricTypeCountDNS:
f = "count_over_time"
Expand All @@ -64,7 +63,7 @@ func NewTopologyQuery(cfg *Config, start, end, limit, rateInterval, step string,
case constants.MetricTypeFlowRTT:
f = "avg_over_time"
t = "TimeFlowRttNs"
factor = 0.000001 // nanoseconds to miliseconds
factor = "/1000000" // nanoseconds to miliseconds
}

var d bool
Expand Down Expand Up @@ -149,7 +148,7 @@ func (q *TopologyQueryBuilder) Build() string {
// <function>(
// {<label filters>}|<line filters>|json|<json filters>
// |unwrap Bytes|__error__=""[<interval>]
// )
// ) <factor>
// )
// )
// &<query params>&step=<step>
Expand Down Expand Up @@ -199,9 +198,8 @@ func (q *TopologyQueryBuilder) Build() string {
sb.WriteString(q.topology.rateInterval)
}
sb.WriteString("])")
if q.topology.factor != 1 {
sb.WriteRune('*')
sb.WriteString(strings.Replace(fmt.Sprintf("%f", q.topology.factor), ",", ".", 1))
if len(q.topology.factor) > 0 {
sb.WriteString(q.topology.factor)
}
sb.WriteString("))")
q.appendQueryParams(sb)
Expand Down

0 comments on commit 8a51781

Please sign in to comment.