Skip to content

Commit

Permalink
[chore][CONTRIBUTING.md] Add goleak to new component requirements (#3…
Browse files Browse the repository at this point in the history
…1689)

**Description:** 
The goal is for `goleak` to be required for every package, and also to
be [generated by
mdatagen](#30483).
Once this is generated by `mdatagen` we'll be able to remove this from
manual steps done by the user, but for now it would be good to state the
it's required in docs.

**Link to tracking Issue:** #30438
  • Loading branch information
crobert-1 committed Mar 12, 2024
1 parent ec82d6f commit eb03778
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Components refer to connectors, exporters, extensions, processors, and receivers
* Implement the [component.Component](https://pkg.go.dev/go.opentelemetry.io/collector/component#Component) interface
* Provide a configuration structure which defines the configuration of the component
* Provide the implementation which performs the component operation
* Have a `metadata.yaml` file and its generated code (using [mdatadgen](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/cmd/mdatagen/README.md)).
* Have a `metadata.yaml` file and its generated code (using [mdatadgen](https://github.com/open-telemetry/opentelemetry-collector/blob/main/cmd/mdatagen/README.md)).

Familiarize yourself with the interface of the component that you want to write, and use existing implementations as a reference.
[Building a Trace Receiver](https://opentelemetry.io/docs/collector/trace-receiver/) tutorial provides a detailed example of building a component.
Expand Down Expand Up @@ -152,7 +152,26 @@ and its contributors.
and in the respective testing harnesses. To align with the test goal of the project, components must be testable within the framework defined within
the folder. If a component can not be properly tested within the existing framework, it must increase the non testable
components number with a comment within the PR explaining as to why it can not be tested.
- Create a `metadata.yaml` file with at minimum the required fields defined in [metadata-schema.yaml](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/cmd/mdatagen/metadata-schema.yaml).
- Enable [goleak checks](https://github.com/uber-go/goleak) to help ensure your component does not leak goroutines. This
requires adding a file named `package_test.go` to every sub-directory containing tests. This file should have the following contents by default:
```
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package fooreceiver
import (
"testing"
"go.uber.org/goleak"
)
func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
}
```

- Create a `metadata.yaml` file with at minimum the required fields defined in [metadata-schema.yaml](https://github.com/open-telemetry/opentelemetry-collector/blob/main/cmd/mdatagen/metadata-schema.yaml).
Here is a minimal representation:
```
type: <name of your component, such as apache, http, haproxy, postgresql>
Expand Down Expand Up @@ -181,7 +200,7 @@ status:
// Package fooreceiver bars.
package fooreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/fooreceiver"
```
- Type `make update-codeowners`. This will trigger the regeneration of the `.github/CODEOWNERS` file and the [metadata generator](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/cmd/mdatagen/README.md#using-the-metadata-generator) to generate the associated code/documentation.
- Type `make update-codeowners`. This will trigger the regeneration of the `.github/CODEOWNERS` file and the [metadata generator](https://github.com/open-telemetry/opentelemetry-collector/blob/main/cmd/mdatagen/README.md#using-the-metadata-generator) to generate the associated code/documentation.

When submitting a component to the community, consider breaking it down into separate PRs as follows:

Expand Down

0 comments on commit eb03778

Please sign in to comment.