-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add initial info on how to write a component #88
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,8 +1,55 @@ | ||||||
# OpenTelemetry Collector Contrib | ||||||
This is a repository for OpenTelemetry Collector contributions that are not part of the | ||||||
core repository and core distribution of the Collector. | ||||||
[core repository](https://github.com/open-telemetry/opentelemetry-collector) and | ||||||
core distribution of the Collector. Typically, these contributions are vendor | ||||||
specific receivers/exporters and/or components that are either legacy or are only | ||||||
useful to relatively small number of users. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to a |
||||||
|
||||||
## Contributing | ||||||
|
||||||
If you would like to contribute please read [contributing guidelines](https://github.com/open-telemetry/opentelemetry-collector/blob/master/CONTRIBUTING.md) | ||||||
before you begin your work. | ||||||
|
||||||
## Adding New Components | ||||||
Before you start please read the [contributing guidelines](https://github.com/open-telemetry/opentelemetry-collector/blob/master/CONTRIBUTING.md). | ||||||
|
||||||
Any component (receiver, processor, exporter, or extension) needs to implement | ||||||
the interfaces defined on the [core repository](https://github.com/open-telemetry/opentelemetry-collector). | ||||||
Familiarize yourself with the interface of the component that you want to write, | ||||||
and use existing implementations as reference. | ||||||
|
||||||
- Create your component under the proper folder and use | ||||||
Go standard package naming recommendations. | ||||||
- Use a boiler-plate Makefile that just references the one at top level, | ||||||
ie.: `include ../../Makefile.Common` - this allows you to build your component | ||||||
with required build configurations for the contrib repo while avoiding building | ||||||
the full repo during development. | ||||||
- Each component has its own go.mod file. This allows custom builds of the | ||||||
collector to take a limited sets of dependencies - so run `go mod` commands as | ||||||
appropriate for your component. | ||||||
- Implement the needed interface on your component by importing the appropriate | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add a note here saying that while Collector is in Alpha stage the interfaces may undergo breaking changes and they must be ready to fix their component when such changes happen otherwise the component will be excluded from the default builds. |
||||||
component from the core repo. Follow the pattern of existing components regarding | ||||||
config and factory soruce files and tests. | ||||||
- Implement your component as appropriate. Provide end-to-end tests (or mock | ||||||
backend/client as appropriate). Target is to get 80% of code coverage. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I'd prefer to remove the reference to specific percentage once we will implement ratcheting based on coverage percentage (to fail the build if coverage goes down). |
||||||
- Add a README.md on the root of your component describing its configuration | ||||||
and usage, likely referencing some of the yaml files used in the component tests. | ||||||
We also suggest that the yaml files used in tests have comments for all available | ||||||
configuration settings so users can copy and modify them as needed. | ||||||
- Add a `replace` directive at the root `go.mod` file so your component is included | ||||||
in the build of the contrib executable. | ||||||
|
||||||
### General Recommendations | ||||||
Below are some recommendations that apply to typical components. These are not rigid | ||||||
rules and there are exceptions to them, but, take care considering when you are | ||||||
not following them. | ||||||
|
||||||
- Avoid introducing asynchronicity on receivers and exporters. Typically, these | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may be worth explaining what "asynchronicity" means in this context. |
||||||
are general cases that can be better handled via processors (that also can be | ||||||
reused by other receivers and exporters). | ||||||
- When implementing exporters try to leverage the exporter helpers from the core | ||||||
repo, see [exporterhelper package](https://github.com/open-telemetry/opentelemetry-collector/tree/master/exporter/exporterhelper) | ||||||
on core repo. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add a rationale as to why this is a good thing to do? |
||||||
|
||||||
### Questions? | ||||||
Reach the Collector community on [gitter](https://gitter.im/open-telemetry/opentelemetry-service) | ||||||
if you have further questions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: do we need to specifically mention "legacy" here? I think this sentence reads fine and serves the purpose without that reference.