Skip to content

Commit

Permalink
rely on TimeFlowEndMs for kafka delay (#428)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpinsonneau authored Apr 28, 2023
1 parent ab58d8a commit 95395fc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions pkg/pipeline/decode/decode_protobuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/netobserv/flowlogs-pipeline/pkg/config"
"github.com/netobserv/netobserv-ebpf-agent/pkg/pbflow"
log "github.com/sirupsen/logrus"
"google.golang.org/protobuf/proto"
)

Expand All @@ -17,6 +18,7 @@ type Protobuf struct {
}

func NewProtobuf() (*Protobuf, error) {
log.Debugf("entering NewProtobuf")
return &Protobuf{}, nil
}

Expand Down
1 change: 1 addition & 0 deletions pkg/pipeline/ingest/ingest_grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func instrumentGRPC(m *metrics) grpc2.UnaryServerInterceptor {

resp, err = handler(ctx, req)
if err != nil {
glog.Errorf("Reporting metric error: %v", err)
m.error(fmt.Sprint(status.Code(err)))
}

Expand Down
12 changes: 7 additions & 5 deletions pkg/pipeline/ingest/ingest_kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,19 @@ func (k *ingestKafka) isStopped() bool {
}

func (k *ingestKafka) processRecordDelay(record config.GenericMap) {
TimeFlowEndInterface, ok := record["TimeFlowEnd"]
TimeFlowEndInterface, ok := record["TimeFlowEndMs"]
if !ok {
k.metrics.error("TimeFlowEnd missing")
klog.Errorf("TimeFlowEndMs missing in record %v", record)
k.metrics.error("TimeFlowEndMs missing")
return
}
TimeFlowEnd, ok := TimeFlowEndInterface.(float64)
TimeFlowEnd, ok := TimeFlowEndInterface.(int64)
if !ok {
k.metrics.error("Cannot parse TimeFlowEnd")
klog.Errorf("Cannot parse TimeFlowEndMs of record %v", record)
k.metrics.error("Cannot parse TimeFlowEndMs")
return
}
delay := time.Since(time.Unix(int64(TimeFlowEnd), 0)).Seconds()
delay := time.Since(time.UnixMilli(TimeFlowEnd)).Seconds()
k.metrics.latency.Observe(delay)
}

Expand Down

0 comments on commit 95395fc

Please sign in to comment.