opentelemetry-collector icon indicating copy to clipboard operation
opentelemetry-collector copied to clipboard

Provide examples on how to create components

Open hickeyma opened this issue 2 years ago • 15 comments

EDIT: I have kept all original text (with strikethrough) but have made modifications based on feedback

It would be very helpful and improve usability if an example~~s~~ ~~were~~ was provided for ~~the different~~ a component~~s like receivers, processor, exporters and extensions~~. This would simplify the process of creating a component for new users.

~~Examples could be added to the Go documentation for the component package. Refer to Testable Examples in Go for more details.~~

This request follows a discussion with @mx-psi.

Tasks

hickeyma avatar Jul 12 '22 11:07 hickeyma

Should we create an checklist for each kind of component (receiver, processor, exporter, extension...)? So that this can potentially be taken on by several people

mx-psi avatar Jul 12 '22 11:07 mx-psi

I agree, I think we can also learn from go-contrib new instrumentation library request template to define following steps/tasks to build a usable component.

Tasks

  • Code complete:
    • [ ] Comprehensive unit tests.
    • [ ] End-to-end integration tests.
    • [ ] Tests all passing.
    • [ ] Instrumentation functionality verified.
  • Documented
  • Examples
    • [ ] Dockerfile file to build example application.
    • [ ] docker-compose.yml to run example in a docker environment to demonstrate instrumentation.

fatsheep9146 avatar Jul 12 '22 12:07 fatsheep9146

Good ideas @mx-psi @fatsheep9146. I'll add to the description when I get a chance.

hickeyma avatar Jul 12 '22 13:07 hickeyma

Is this about adding documentation for people creating new components (ie, writing Go code that ends up in a distribution), or is it for end-users, configuring components available in a collector distribution?

jpkrohling avatar Jul 12 '22 14:07 jpkrohling

Is this about adding documentation for people creating new components (ie, writing Go code that ends up in a distribution), or is it for end-users, configuring components available in a collector distribution?

The former: writing Go code

mx-psi avatar Jul 12 '22 14:07 mx-psi

Good ideas @mx-psi @fatsheep9146. I'll add to the description when I get a chance.

@hickeyma Excellent :-), I’d love to help with review or contribute for this issue if you need.

fatsheep9146 avatar Jul 12 '22 15:07 fatsheep9146

There are a couple of pages/articles that can serve as the foundation for this:

https://medium.com/opentelemetry/extending-the-opentelemetry-collector-with-your-own-components-64c10cf675db https://opentelemetry.io/docs/collector/custom-auth/ https://opentelemetry.io/docs/collector/trace-receiver/

jpkrohling avatar Jul 12 '22 16:07 jpkrohling

Thanks for the links @jpkrohling

hickeyma avatar Jul 12 '22 16:07 hickeyma

Following the feedback from @jpkrohling in https://github.com/open-telemetry/opentelemetry-collector/issues/5675#issuecomment-1181985956, I investigated this further. Here is the feedback from my investigation:

  • The Building a Trace Receiver doc is an excellent reference for building a component and I think it trancends a trace receiver component. I therefore think that having examples per component type would be overhead.
  • Examples added to the Go documentation is very nice capability but I'm not sure the component models fits nicely with it because the Building a Trace Receiver doc shows how involved building a component is and not just short snappy end to end code. It also requires a lot of background explanation to make decisions.
  • By adding links in key existing documentation would direct a user to useful documentation like the Building a Trace Receiver doc.

I have updated the description to breakdown what I propose the tasks could be for this work.

@mx-psi @fatsheep9146 @jpkrohling Please let me know what you think.

hickeyma avatar Jul 14 '22 15:07 hickeyma

@hickeyma I think having a link to that doc is definitely better than not having anything! The benefit of having a testable example is that we ensure that the examples will always be kept up to date (since CI will fail otherwise), but it's true that they won't be end to end examples

mx-psi avatar Jul 15 '22 08:07 mx-psi

@mx-psi Ok, thanks for the feedback.

I think having a link to that doc is definitely better than not having anything!

I have pushed #5690 and https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/12490 to see provide context and references.

The benefit of having a testable example is that we ensure that the examples will always be kept up to date (since CI will fail otherwise), but it's true that they won't be end to end examples

I agree that this would be beneficial. Does this work when its not an end to end example for a user?

hickeyma avatar Jul 15 '22 13:07 hickeyma

I took a look at your PRs @hickeyma, they make sense to me :)

Does this work when its not an end to end example for a user?

I don't understand what you mean in this question, sorry

mx-psi avatar Jul 18 '22 11:07 mx-psi

I don't understand what you mean in this question, sorry

I am wondering if providing a testable example which is not end to end would make sense for the components?

hickeyma avatar Aug 02 '22 09:08 hickeyma

I’d love to help with review or contribute for this issue if you need.

@fatsheep9146 Let me know if you would like to tackle the open issue of sub menu to collector docs (refer to item in description).

hickeyma avatar Aug 05 '22 10:08 hickeyma

I am wondering if providing a testable example which is not end to end would make sense for the components?

Ah, okay, thanks for clarifying! I think there is some value (maybe not only for component developers but also for other users of the Go API) and we can have some dummy implementation (so e.g. a receiver that generates a gauge point every minute? or some sort of simple logging exporter?) that still showcases how to use the interface.

Do you agree?

mx-psi avatar Aug 05 '22 15:08 mx-psi

The third in the checklist should be modified in the opentelemetry.io repo right?

Chinwendu20 avatar Oct 13 '22 16:10 Chinwendu20

@Chinwendu20 It should be. Are you interested in pushing a PR?

hickeyma avatar Oct 14 '22 09:10 hickeyma

Hello @hickeyma , if it is still valid, I'd like to work on the third item in the checklist!

Enzujp avatar Mar 11 '24 10:03 Enzujp

@Enzujp Haven't looked at it in over a year. Maybe check the docs and see?

hickeyma avatar Mar 11 '24 11:03 hickeyma

Will do just that.

Enzujp avatar Mar 11 '24 11:03 Enzujp