Skip to content
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

[docs/collector/building] add more context for what you can build #4343

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions content/en/docs/collector/building/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,70 @@
title: Building custom components
description: Instructions on how to build your own collector components
weight: 90
cSpell:ignore: mdatagen ottl
---

The OpenTelemetry Collector can not only be extended by existing components, but
also by custom components, that you develop and build on your own. Here you will
find instructions on how to build some of those components. For additional
details take a look into the documents contained within the
[opentelemetry-collector-contrib repository](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/README.md).

There are several
[classes](https://github.com/open-telemetry/opentelemetry-collector/blob/67d37183e6ac9b7180fefc6dc3a55f2a75c12fba/cmd/mdatagen/main.go#L192)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would link to our documentation, I don't think a link to mdatagen's internals is the right approach here

Suggested change
[classes](https://github.com/open-telemetry/opentelemetry-collector/blob/67d37183e6ac9b7180fefc6dc3a55f2a75c12fba/cmd/mdatagen/main.go#L192)
[classes](/docs/collector/configuration/#basics)

Copy link
Author

@hughesjj hughesjj May 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree linking to the internal code is suboptimal. I don't think linking to configuration is the right idea either though.

Should I add a blurb to the mdatagen readme to talk about what a "class" is? Or should I instead link to the metadata-schema.yaml file?

I think so long as we link to somewhere that enumerates all the classes, a reader could follow the breadcrumbs to more detailed documentation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should link at mdatagen at all. The fact that we use mdatagen is an implementation detail: we do not require for you to use mdatagen to create a new component: you just need a go.mod and a properly-typed NewFactory function and the builder can take it.

of OpenTelemetry Collector components, such as

- `receivers`: Scrapers and Listeners which
[ingest data](https://github.com/open-telemetry/opentelemetry-collector/tree/main/receiver#readme),
typically used to convert data from an external source to OTLP
- `exporters`: Ways to
[export data](https://github.com/open-telemetry/opentelemetry-collector/tree/main/exporter#readme)
to non-OTLP formats, vendor-specific backends, or other Observability tools
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not only non-OTLP: we do have OTLP exporters

Copy link
Author

@hughesjj hughesjj May 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, this was changed in a previous review to specifically mention non-otlp formats. I was presuming that was because only collector-core hosts the otlp exporter, but you're right in that even non-otlp exporters can export in the OTLP format, so will change. This also goes to your audience question. I think the goal is to be generic enough to cover all cases, but building your own collector via OCB and adding new components to -contrib are in scope for the audience AFAIK.

- `processors`: Ways to
[process data](https://github.com/open-telemetry/opentelemetry-collector/tree/main/processor#readme)
in a pipeline
- `connectors`:
[Connects](https://github.com/open-telemetry/opentelemetry-collector/tree/main/connector#readme)
the output (exporter) of one pipeline to the input (receiver) of another in a
single component
- `extensions`: Ways to
[augment the collector runtime](https://github.com/open-telemetry/opentelemetry-collector/blob/main/extension/README.md),
such as providing
Comment on lines +18 to +33
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intent is significantly different. Configuration is intended/written for aspiring users of the collector, while this guide is for aspiring contributors (or at least, developers). The introduction to the idea of different "classes" of components will be inherently similar though, yes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, it's still unclear to me what the audience and intent of this doc is. Is it for people building their custom components? Is it a "how to add your component to contrib"? Is it "how to contribute to the opentelemetry-collector and/or opentelemetry-collector-contrib repositories"?

[health checks](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/extension/healthcheckextension/README.md)
- `cmd`: Commands for building and/or maintain the collector
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be removed, it's not relevant for people extending the collector.

Copy link
Author

@hughesjj hughesjj May 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you say "this", do you mean "remove information regarding extensions", or the health check specifically?

IMO it's relevant for people extending the collector, and if not, we should change the documentation which I read as indicating such

Extensions provide capabilities on top of the primary functionality of the collector
...
The contributors repository may have more extensions that can be added to custom builds of the Collector.

Also, we already have an article showing how to write an extension, so I think it would be a bit weird if we didn't mention extensions on the index of "building custom components"

Copy link
Member

@jpkrohling jpkrohling May 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean specifically this item on the line I commented, cmd.

- `pkg`:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, I don't think this should be included in this page.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would appreciate a bit more elaboration on why you feel this way. I do think the cmd is a bit more esoteric, but I don't think that's a reason we should ignore its existence.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have support for adding pkg in ocb at this point.

[Packages](https://github.com/search?q=org%3Aopen-telemetry+%22class%3A+pkg%22&type=code)
for adding functionality to the collector, such as support for
[golden tests](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/pkg/golden#readme)
or
[OTTL functions](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/pkg/ottl#readme)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add an OTTL function by just adding a new package? It looks like it should be possible (cc @TylerHelmuth). However, we don't have an easy way to add a pkg to the a distribution right now. It would be a cool feature to have for the builder though.

Comment on lines +37 to +41
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am against promoting the usage of the pkg folder outside of contrib in our public documentation. I don't think we have figured out our strategy here yet

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's totally fair. Would you be okay with an aside saying something to the effect of

"While there may exist other component classes, at this time they are not in scope for this guide"
?


Most components are registered using
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only relevant if people are adding components to contrib. Perhaps this doc needs to be clearer on what's the target audience? Am I reading this because I'm developing a proprietary component to be used with my own distribution, used internally at my company? Or is this about developing an open-source component that is meant to be distributed as part of contrib? I would say that this doc is for the first case, and would expect people to check the contribution guidelines in contrib if they are looking for the second case.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, good call, I'll work on making the audience more explicit.

We had a discussion and the current consensus as far as I understand it is

  1. should not be -contrib specific, but should definitely cover some aspects of contributing or building off of -contrib. This would mostly be in the form of linking to contrib documentation (similar to how we've linked to core documentation for receivers etc). Critically, we want to indicate that there's a high bar for ongoing maintenance to any -contrib contributions, to dissuade developers from "dumping" a new component in -contrib and then abandoning it, and to inform them of alternative ways to experiment with new components. That said, I do expect some SMEs who will eventually maintain constructive, useful components to come across this guide, and I don't want to completely scare them away either.
  2. OCB should be covered
  3. Forking -contrib should be covered (this wasn't explicitly called out, but I think it's an obvious place to start for most aspiring contributors)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They might end up in the contrib repository, but I argue that there are many use cases were folks want to have their "own" thing that might not even be OSS.

I'll let @svrnm confirm, but I believe the focus should be those many use cases where folks want to have their "own" thing. We can keep contrib off this doc, as it would make it a lot simpler, while still pointing people to the contrib-specific guidelines at that repo.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about this, and sorry if this is different to what we have discussed before, but I lean towards "making it a lot simpler", so keeping things out of the docs that are contrib-specific. If we think that they would add additional value, we can still add them in later as well.

[`mdatagen`](https://github.com/open-telemetry/opentelemetry-collector/tree/main/cmd/mdatagen#readme),
a tool which automatically generates code that specifies the adoption status
(stability) of your component along with documentation and component specific
information. Most significantly, `mdatagen` configuration is used to describe
out-of-the-box metrics for scraping receivers, and which
[signals](/docs/concepts/signals/) or
[attributes](/docs/specs/otel/common/#attribute) are enabled by default for
collection. The names of these signals and attributes try to follow their
respective [specification](/docs/specs/semconv/general/attribute-naming/), and
any [semantic conventions](/docs/specs/semconv/) which may exist.

The core
[`opentelemetry-collector`](https://github.com/open-telemetry/opentelemetry-collector/blob/main/README.md)
is the basis for all OpenTelemetry components and Collector development. For
specific, non-universal integrations, contributors look to the
[`-contrib`](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/README.md)
repository for all but the most generic integrations, and vendors often base
their distributions off of the `-contrib` repository.

Note that
[adding a component](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#adding-new-components)
to the `-contrib` distribution incurs a high bar of support, and while
contributions of new components are encouraged, adoption is a process that
requires ongoing support and commitment to the OpenTelemetry project.

If you wish to build your own [distribution](../distributions/) of the
collector, you may use the
[`OpenTelemetry Collector builder`](../custom-collector).
20 changes: 20 additions & 0 deletions static/refcache.json
Original file line number Diff line number Diff line change
Expand Up @@ -4291,6 +4291,10 @@
"StatusCode": 200,
"LastSeen": "2024-01-30T05:18:29.09204-05:00"
},
"https://github.com/search": {
"StatusCode": 206,
"LastSeen": "2024-04-24T11:30:02.572957676-07:00"
},
"https://github.com/serverless/serverless": {
"StatusCode": 200,
"LastSeen": "2024-01-18T19:37:21.697812-05:00"
Expand Down Expand Up @@ -5855,10 +5859,26 @@
"StatusCode": 206,
"LastSeen": "2024-02-23T22:55:04.014798-05:00"
},
"https://opentelemetry.io/docs/concepts/signals/": {
"StatusCode": 206,
"LastSeen": "2024-05-03T17:33:57.182830555-07:00"
},
"https://opentelemetry.io/docs/specs/otel/common/#attribute": {
"StatusCode": 206,
"LastSeen": "2024-05-03T17:33:59.605193068-07:00"
},
"https://opentelemetry.io/docs/specs/otel/protocol": {
"StatusCode": 206,
"LastSeen": "2024-02-24T14:33:05.630341-08:00"
},
"https://opentelemetry.io/docs/specs/semconv/": {
"StatusCode": 206,
"LastSeen": "2024-05-03T17:34:00.547767217-07:00"
},
"https://opentelemetry.io/docs/specs/semconv/general/attribute-naming/": {
"StatusCode": 206,
"LastSeen": "2024-05-03T17:34:00.292106157-07:00"
},
"https://opentelemetry.io/ecosystem/integrations/": {
"StatusCode": 206,
"LastSeen": "2024-03-19T10:16:49.992495889Z"
Expand Down