Skip to content

Commit

Permalink
fix time unit. sec -> millisec
Browse files Browse the repository at this point in the history
Signed-off-by: kane8n <[email protected]>
  • Loading branch information
kane8n committed Nov 28, 2024
1 parent 0b6d2b6 commit 476a870
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/metrics/providers/splunk.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func NewSplunkProvider(metricInterval string,
return nil, fmt.Errorf("error parsing metric interval: %w", err)
}

sp.fromDelta = int64(signalFxFromDeltaMultiplierOnMetricInterval * md.Seconds())
sp.fromDelta = int64(signalFxFromDeltaMultiplierOnMetricInterval * md.Milliseconds())
return &sp, nil
}

Expand All @@ -95,7 +95,7 @@ func (p *SplunkProvider) RunQuery(query string) (float64, error) {
}

req.Header.Set(signalFxTokenHeaderKey, p.token)
now := time.Now().Unix()
now := time.Now().UnixMilli()
q := req.URL.Query()
q.Add("query", query)
q.Add("startMS", strconv.FormatInt(now-p.fromDelta, 10))
Expand Down
4 changes: 2 additions & 2 deletions pkg/metrics/providers/splunk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestNewSplunkProvider(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, "https://api.us1.signalfx.com/v1/timeserieswindow", sp.metricsQueryEndpoint)
assert.Equal(t, "https://api.us1.signalfx.com/v2/metric?limit=1", sp.apiValidationEndpoint)
assert.Equal(t, int64(md.Seconds()*signalFxFromDeltaMultiplierOnMetricInterval), sp.fromDelta)
assert.Equal(t, int64(md.Milliseconds()*signalFxFromDeltaMultiplierOnMetricInterval), sp.fromDelta)
assert.Equal(t, token, sp.token)
}

Expand All @@ -54,7 +54,7 @@ func TestSplunkProvider_RunQuery(t *testing.T) {
t.Run("ok", func(t *testing.T) {
expected := 1.11111
eq := `sf_metric:service.request.count AND http_status_code:*`
now := time.Now().Unix()
now := time.Now().UnixMilli()
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
aq := r.URL.Query().Get("query")
assert.Equal(t, eq, aq)
Expand Down

0 comments on commit 476a870

Please sign in to comment.