Skip to content

Commit

Permalink
[chore][cmd/configschema/docsgen/docsgen] Enable goleak (open-telemet…
Browse files Browse the repository at this point in the history
…ry#30494)

**Description:** <Describe what has changed.>
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
Enables `goleak` on the `docsgen` package to catch potential leaking
goroutines.

**Link to tracking Issue:** <Issue number if applicable>
open-telemetry#30438

**Testing:** <Describe what testing was performed and which tests were
added.>
Test is passing other than referenced failure.

---------

Co-authored-by: Pablo Baeyens <[email protected]>
  • Loading branch information
crobert-1 and mx-psi committed Mar 8, 2024
1 parent 5b62b61 commit 38714e5
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions cmd/configschema/docsgen/docsgen/package_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package docsgen

import (
"testing"

"go.uber.org/goleak"
)

// The Ignore function calls prevent catching leaks generated by indirect dependencies.
// All of these are leaks that we can't fix from within the collector code base.
// Regarding the OpenCensus ignore: see https://github.com/census-instrumentation/opencensus-go/issues/1191
// Regarding the DataDog ignore: see https://github.com/DataDog/datadog-agent/issues/22030
// Regarding the database/sql ignore: see https://github.com/SAP/go-hdb/issues/130
// Regarding the SAP/go-hdb ignore: see https://github.com/SAP/go-hdb/issues/131
// Regarding the cihub/seelog ignore: see https://github.com/cihub/seelog/issues/182
// Regarding the godbus/dbus ignore: see https://github.com/99designs/keyring/issues/135
func TestMain(m *testing.M) {
goleak.VerifyTestMain(m,
goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"),
goleak.IgnoreTopFunction("github.com/DataDog/datadog-agent/pkg/trace/metrics/timing.(*Set).Autoreport.func1"),
// Unfortunately this ignore can't be anymore specific, even though it's caused by the SAP/go-hdb/driver
// package. There's no reference to this package in the goleak output. This has the potential of
// hiding future leaks, so we should remove as soon as the referenced issue is resolved.
goleak.IgnoreTopFunction("database/sql.(*DB).connectionOpener"),
goleak.IgnoreTopFunction("github.com/SAP/go-hdb/driver.(*metrics).collect"),
goleak.IgnoreAnyFunction("github.com/cihub/seelog.(*asyncLoopLogger).processQueue"),
goleak.IgnoreAnyFunction("github.com/godbus/dbus.(*Conn).inWorker"))
}

0 comments on commit 38714e5

Please sign in to comment.