diff --git a/exporter/prometheusremotewriteexporter/exporter_test.go b/exporter/prometheusremotewriteexporter/exporter_test.go index bed5888c0656d..c948056150367 100644 --- a/exporter/prometheusremotewriteexporter/exporter_test.go +++ b/exporter/prometheusremotewriteexporter/exporter_test.go @@ -11,6 +11,8 @@ import ( "net/http" "net/http/httptest" "net/url" + "os" + "runtime" "strconv" "strings" "sync" @@ -757,8 +759,18 @@ func Test_PushMetrics(t *testing.T) { } if useWAL { + var dir string + if runtime.GOOS == "windows" { + // On Windows, use os.MkdirTemp to create directory since t.TempDir results in an error during cleanup in scoped-tests. + // See https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/42639 + var err error + dir, err = os.MkdirTemp("", tt.name) //nolint:usetesting + require.NoError(t, err) + } else { + dir = t.TempDir() + } cfg.WAL = configoptional.Some(WALConfig{ - Directory: t.TempDir(), + Directory: dir, }) }