Commit 1d07dd1e authored by Ankit Nayan's avatar Ankit Nayan
Browse files

chore: changed ttl get response to number of hours in int

No related merge requests found
Showing with 12 additions and 5 deletions
+12 -5
......@@ -856,7 +856,7 @@ func (r *ClickHouseReader) SetTTL(ctx context.Context, ttlParams *model.TTLParam
func (r *ClickHouseReader) GetTTL(ctx context.Context, ttlParams *model.GetTTLParams) (*model.GetTTLResponseItem, *model.ApiError) {
parseTTL := func(queryResp string) string {
parseTTL := func(queryResp string) int {
values := strings.Split(queryResp, " ")
N := len(values)
ttlIdx := -1
......@@ -868,12 +868,17 @@ func (r *ClickHouseReader) GetTTL(ctx context.Context, ttlParams *model.GetTTLPa
}
}
if ttlIdx == -1 {
return ""
return ttlIdx
}
output := strings.SplitN(values[ttlIdx], "(", 2)
timePart := strings.Trim(output[1], ")")
return timePart
seconds_int, err := strconv.Atoi(timePart)
if err != nil {
return -1
}
ttl_hrs := seconds_int / 3600
return ttl_hrs
}
getMetricsTTL := func() (*model.DBResponseTTL, *model.ApiError) {
......
......@@ -53,6 +53,8 @@ github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/SigNoz/prometheus v1.9.4 h1:HqMPTM/QXgsjzuG5whSS+9l0mVePuya/uZmrAt2H9HQ=
github.com/SigNoz/prometheus v1.9.4/go.mod h1:39/E+7N2hh5Q6NunhoRz9EHCRAyRGj63YK1hE4SiHdk=
github.com/SigNoz/prometheus v1.9.5 h1:ITuK/71BFY3Hxv50/Upsvo6KJUdOxT7o6lCXmVxyLF0=
github.com/SigNoz/prometheus v1.9.5/go.mod h1:BHEawFYBYkVr9BjPXsz9Ye6QVVQ+2a99m6r/S8hO/lA=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
......
......@@ -205,6 +205,6 @@ type DBResponseTTL struct {
}
type GetTTLResponseItem struct {
MetricsTime string `json:"metrics_ttl_duration"`
TracesTime string `json:"traces_ttl_duration"`
MetricsTime int `json:"metrics_ttl_duration_hrs"`
TracesTime int `json:"traces_ttl_duration_hrs"`
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment