MCPcopy Index your code
hub / github.com/coder/slog / metadataClient

Function metadataClient

sloggers/slogstackdriver/slogstackdriver_test.go:65–79  ·  view source on GitHub ↗
(t testing.TB)

Source from the content-addressed store, hash-verified

63}
64
65func metadataClient(t testing.TB) *metadata.Client {
66 // When not running in Google Cloud, the default metadata client will
67 // leak a goroutine.
68 //
69 // We use a very short timeout because the metadata server should be
70 // within the same datacenter as the cloud instance.
71 tp := http.DefaultTransport.(*http.Transport).Clone()
72 httpClient := &http.Client{
73 Timeout: time.Second * 3,
74 Transport: tp,
75 }
76 client := metadata.NewClient(httpClient)
77 t.Cleanup(httpClient.CloseIdleConnections)
78 return client
79}

Callers 1

TestStackdriverFunction · 0.85

Calls 1

CleanupMethod · 0.80

Tested by

no test coverage detected