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

Components subcommand - Add module@version for each component #10570

Closed
djaglowski opened this issue Jul 9, 2024 · 0 comments · Fixed by #10599
Closed

Components subcommand - Add module@version for each component #10570

djaglowski opened this issue Jul 9, 2024 · 0 comments · Fixed by #10599

Comments

@djaglowski
Copy link
Member

djaglowski commented Jul 9, 2024

Is your feature request related to a problem? Please describe.
The components subcommand is useful for understanding which types are available, but it would be helpful in some cases to know the exact module and version which defines each component.

Describe the solution you'd like
Enhance the components subcommand to include the go module and version.

Current Output:

receivers:
    - name: otlp
      stability:
        logs: Beta
        metrics: Stable
        traces: Stable

Proposed Output:

receivers:
    - name: otlp
      module: go.opentelemetry.io/collector/receiver/[email protected]
      stability:
        logs: Beta
        metrics: Stable
        traces: Stable

The best solution I have found involves using runtime.Caller. Basically, within each <kind>.NewFactory function we can call runtime.Caller to get the module (including version), then save the result onto the corresponding <kind>.factory struct and return it via a new method on the corresponding <kind>.Factory interface, e.g. GoModule() string. Here is a working prototype.

Describe alternatives you've considered

I explored whether reflection could be used on the factories directly but could not identify a mechanism to get the corresponding module. The only way I can find to get any information about modules is using runtime.debug.ReadBuildInfo, but this provides an comprehensive list of module dependencies for the collector binary, without any reliable way to match them to the factories.

I also explored the possibility of using the OCB manifest in some way, but I have not identified a straightforward way to match modules with corresponding component types. e.g. How do we know for certain that go.opentelemetry.io/collector/receiver/otlpreceiver contains a component type called otlp? Presumably we could enhance the FactoryMap structs to pair the module string with the factory, but this seems overly complicated and won't apply to collectors built outside of OCB.

Additional context

This same information would be extremely useful for OpAMP, since a server would be able to confidently understand the exact components available in a collector, including the precise corresponding configuration. Adding it to the components subcommand seems like a natural first step. Later, we should be able to make the information available to the opampextension in some way.

@djaglowski djaglowski changed the title Components subcommand - option to describe module@version for each component Components subcommand - Add module@version for each component Jul 9, 2024
mx-psi pushed a commit that referenced this issue Jul 16, 2024
Resolves #10570

Alternative to #10598

This implementation is more reliable that #10598 because it gets
information directly from the builder manifest. It relies on additional
structure in the `component.go` file, ultimately encoded in
`otelcol.Factories`.

An alternative would be to push the enhancements deeper, into the
`<kind>.Factories` implementations, so that the module information is
available directly alongside the Factory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant