Skip to content

Commit

Permalink
Fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
splunkericl committed Mar 1, 2022
1 parent a55203d commit c9a1402
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions service/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,19 @@ func testCollectorStartHelper(t *testing.T) {
}, time.Second*2, time.Millisecond*200)
}

// as telemetry instance is initialized only once, we need to reset it before each test so the metrics endpoint can
// have correct handler spawned
func resetCollectorTelemetry() {
collectorTelemetry = &colTelemetry{}
}

func TestCollector_Start(t *testing.T) {
resetCollectorTelemetry()
testCollectorStartHelper(t)
}

func TestCollector_StartWithOtelInternalMetrics(t *testing.T) {
resetCollectorTelemetry()
originalFlag := featuregate.IsEnabled(useOtelForInternalMetricsfeatureGateID)
defer func() {
featuregate.Apply(map[string]bool{
Expand Down

0 comments on commit c9a1402

Please sign in to comment.