Skip to content

Commit

Permalink
Add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
hmanukyanVMw committed Oct 4, 2023
1 parent e2bb88e commit a71b44f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/internal/acceptance/metric-store/metric_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,10 +501,6 @@ scrape_configs:
value2, _, err := tc.localEgressClient.LabelValues(context.Background(), model.MetricNameLabel,
result, minTime, maxTime)

fmt.Println("mintime: ", minTime)
fmt.Println("maxtime: ", maxTime)

fmt.Println("new value is a: ")
fmt.Println(value2)

return err
Expand All @@ -520,6 +516,16 @@ scrape_configs:
}, 1).Should(Equal(model.LabelValues{
"metric_name_new",
}))

time.Sleep(time.Second * 10)

content, err := ioutil.ReadFile("/tmp/testlogfile")

if err != nil {
log.Fatal(err)
}

fmt.Println(string(content))
})
})
//1696259961000000000
Expand Down
15 changes: 15 additions & 0 deletions src/pkg/persistence/influx_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package persistence
import (
"context"
"fmt"
"log"
"os"
"regexp"
"sort"
"sync"
Expand Down Expand Up @@ -218,13 +220,26 @@ func (t *InfluxAdapter) DeleteOldest() error {
}

func (t *InfluxAdapter) DeleteOlderThan(cutoff int64) (uint64, error) {

adjustedCutoff := time.Unix(0, cutoff).Add(-time.Minute).Truncate(24 * time.Hour).UnixNano()

f, e := os.OpenFile("/tmp/testlogfile", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if e != nil {
log.Fatalf("error opening file: %v", e)
}
defer f.Close()

var deleted uint64
for _, shardID := range t.ShardIDsOldestSort() {

log.Println("BREAKED shardID: ", shardID)
if int64(shardID) > adjustedCutoff {
break
}
log.SetOutput(f)
log.Println("adjustedCutoff: ", adjustedCutoff)
log.Println("PRUNED shardID: ", shardID)

err := t.Delete(shardID)
if err != nil {
return deleted, err
Expand Down

0 comments on commit a71b44f

Please sign in to comment.