Skip to content

Commit

Permalink
Add lastinstance
Browse files Browse the repository at this point in the history
  • Loading branch information
berejant committed Oct 15, 2023
1 parent d9a1f59 commit 81b1d0d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions init.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ const defaultHost = "victoria-metrics:8428"

var defaultTimeInterval = 10 * time.Second

var LastInstance string

func InitMetrics(instance string) {
LastInstance = instance
host := os.Getenv("VICTORIA_METRICS_HOST")
if host == "" {
host = defaultHost
Expand Down
2 changes: 2 additions & 0 deletions init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ func TestInitMetrics(t *testing.T) {
runtime.Gosched()
time.Sleep(defaultTimeInterval + time.Millisecond*500)
assert.True(t, gock.IsDone())

assert.Equal(t, "testInstance", LastInstance)
})

t.Run("errors", func(t *testing.T) {
Expand Down

0 comments on commit 81b1d0d

Please sign in to comment.