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

Add otel components command #6539

Merged
merged 6 commits into from
Jan 24, 2025

Conversation

ChrsMark
Copy link
Member

@ChrsMark ChrsMark commented Jan 17, 2025

What does this PR do?

This PR adds the components command for otel mode.

Implementation is replicated from https://github.com/open-telemetry/opentelemetry-collector/blob/main/otelcol/command_components.go.

Why is it important?

otel components command can be used to list the supported components the EDOT includes.

Checklist

  • I have read and understood the pull request guidelines of this project.
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool
  • I have added an integration test or an E2E test

Disruptive User Impact

How to test this PR locally

Build Elastic Agent and execute the command:

./build/elastic-agent otel components          
buildinfo:
    command: ./build/elastic-agent
    description: Elastic opentelemetry-collector distribution
    version: 9.0.0
receivers:
    - name: filebeatreceiver
      stability:
        logs: Alpha
        metrics: Undefined
        traces: Undefined
    - name: filelog
      stability:
        logs: Beta
        metrics: Undefined
        traces: Undefined
    - name: hostmetrics
      stability:
        logs: Development
        metrics: Beta
        traces: Undefined
    - name: httpcheck
      stability:
        logs: Undefined
        metrics: Alpha
        traces: Undefined
    - name: jaeger
      stability:
        logs: Undefined
        metrics: Undefined
        traces: Beta
    - name: k8s_cluster
      stability:
        logs: Beta
        metrics: Beta
        traces: Undefined
    - name: k8sobjects
      stability:
        logs: Beta
        metrics: Undefined
        traces: Undefined
    - name: kubeletstats
      stability:
        logs: Undefined
        metrics: Beta
        traces: Undefined
    - name: metricbeatreceiver
      stability:
        logs: Alpha
        metrics: Undefined
        traces: Undefined
    - name: otlp
      stability:
        logs: Beta
        metrics: Stable
        traces: Stable
    - name: prometheus
      stability:
        logs: Undefined
        metrics: Beta
        traces: Undefined
    - name: zipkin
      stability:
        logs: Undefined
        metrics: Undefined
        traces: Beta
processors:
    - name: attributes
      stability:
        logs: Beta
        metrics: Beta
        traces: Beta
    - name: batch
      stability:
        logs: Beta
        metrics: Beta
        traces: Beta
    - name: elasticinframetrics
      stability:
        logs: Undefined
        metrics: Alpha
        traces: Undefined
    - name: elastictrace
      stability:
        logs: Undefined
        metrics: Undefined
        traces: Alpha
    - name: filter
      stability:
        logs: Alpha
        metrics: Alpha
        traces: Alpha
    - name: k8sattributes
      stability:
        logs: Beta
        metrics: Beta
        traces: Beta
    - name: lsminterval
      stability:
        logs: Undefined
        metrics: Development
        traces: Undefined
    - name: memory_limiter
      stability:
        logs: Beta
        metrics: Beta
        traces: Beta
    - name: resource
      stability:
        logs: Beta
        metrics: Beta
        traces: Beta
    - name: resourcedetection
      stability:
        logs: Beta
        metrics: Beta
        traces: Beta
    - name: transform
      stability:
        logs: Alpha
        metrics: Alpha
        traces: Alpha
exporters:
    - name: debug
      stability:
        logs: Development
        metrics: Development
        traces: Development
    - name: elasticsearch
      stability:
        logs: Beta
        metrics: Development
        traces: Beta
    - name: file
      stability:
        logs: Alpha
        metrics: Alpha
        traces: Alpha
    - name: loadbalancing
      stability:
        logs: Beta
        metrics: Development
        traces: Beta
    - name: otlp
      stability:
        logs: Beta
        metrics: Stable
        traces: Stable
    - name: otlphttp
      stability:
        logs: Beta
        metrics: Stable
        traces: Stable
connectors:
    - name: routing
      stability:
        logs-to-logs: Alpha
        logs-to-metrics: Undefined
        logs-to-traces: Undefined
        metrics-to-logs: Undefined
        metrics-to-metrics: Alpha
        metrics-to-traces: Undefined
        traces-to-logs: Undefined
        traces-to-metrics: Undefined
        traces-to-traces: Alpha
    - name: signaltometrics
      stability:
        logs-to-logs: Undefined
        logs-to-metrics: Alpha
        logs-to-traces: Undefined
        metrics-to-logs: Undefined
        metrics-to-metrics: Alpha
        metrics-to-traces: Undefined
        traces-to-logs: Undefined
        traces-to-metrics: Alpha
        traces-to-traces: Undefined
    - name: spanmetrics
      stability:
        logs-to-logs: Undefined
        logs-to-metrics: Undefined
        logs-to-traces: Undefined
        metrics-to-logs: Undefined
        metrics-to-metrics: Undefined
        metrics-to-traces: Undefined
        traces-to-logs: Undefined
        traces-to-metrics: Alpha
        traces-to-traces: Undefined
extensions:
    - name: file_storage
      stability:
        extension: Beta
    - name: health_check
      stability:
        extension: Beta
    - name: memory_limiter
      stability:
        extension: Development
    - name: pprof
      stability:
        extension: Beta

Related issues

Questions to ask yourself

  • How are we going to support this in production?
  • How are we going to measure its adoption?
  • How are we going to debug this?
  • What are the metrics I should take care of?
  • ...

@ChrsMark ChrsMark requested a review from a team as a code owner January 17, 2025 09:39
Copy link
Contributor

mergify bot commented Jan 17, 2025

This pull request does not have a backport label. Could you fix it @ChrsMark? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-./d./d is the label to automatically backport to the 8./d branch. /d is the digit

Copy link
Contributor

mergify bot commented Jan 17, 2025

backport-v8.x has been added to help with the transition to the new branch 8.x.
If you don't need it please use backport-skip label and remove the backport-8.x label.

@mergify mergify bot added the backport-8.x Automated backport to the 8.x branch with mergify label Jan 17, 2025
@ChrsMark ChrsMark force-pushed the add_otel_components_cmd branch from 5c51c6d to a8d4dfb Compare January 17, 2025 09:42
@ChrsMark ChrsMark added enhancement New feature or request opentelemetry Related to the Elastic Distribution of the OpenTelemetry Collector labels Jan 17, 2025
Copy link
Contributor

@swiatekm swiatekm left a comment

Choose a reason for hiding this comment

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

Could you add a simple integration test to verify that this actually works?

Also, could we use upstream's implementantion here instead of copying it?

@ChrsMark
Copy link
Member Author

Also, could we use upstream's implementantion here instead of copying it?

I didn't find an obvious way to use it directly from go.opentelemetry.io/collector/otelcol since it's not exported: https://github.com/open-telemetry/opentelemetry-collector/blob/c14d4f96d69e0053544d5a68863998b2b69a267b/otelcol/command_components.go#L37

I see our validate implementation is also copied/re-implemented. Let me know if I miss anything here.

Could you add a simple integration test to verify that this actually works?

Shall we test against the real EDOT's output? This would mean that every time we include a new component we will need to update that test too.

@swiatekm
Copy link
Contributor

Also, could we use upstream's implementantion here instead of copying it?

I didn't find an obvious way to use it directly from go.opentelemetry.io/collector/otelcol since it's not exported: https://github.com/open-telemetry/opentelemetry-collector/blob/c14d4f96d69e0053544d5a68863998b2b69a267b/otelcol/command_components.go#L37

Allright, let's leave it as is then.

I see our validate implementation is also copied/re-implemented. Let me know if I miss anything here.

Could you add a simple integration test to verify that this actually works?

Shall we test against the real EDOT's output? This would mean that every time we include a new component we will need to update that test too.

I was just thinking about checking if the output looks reasonable, without enumerating the components, but maybe that's a good idea? I'm not sure if we have an integration test that verifies which components are present right now.

@swiatekm swiatekm added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label Jan 17, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

@ChrsMark
Copy link
Member Author

Another thing I see that is missing here is the module (see the sample output in the PR description) information. The reason is that we don't populate the modules when we instantiate the collector factories at

func components(extensionFactories ...extension.Factory) func() (otelcol.Factories, error) {
like it's done in the otel builder.

Is this something that we should fix or we can just skip it from the output for now? Any thoughts?

@swiatekm
Copy link
Contributor

Another thing I see that is missing here is the module (see the sample output in the PR description) information. The reason is that we don't populate the modules when we instantiate the collector factories at

func components(extensionFactories ...extension.Factory) func() (otelcol.Factories, error) {

like it's done in the otel builder.

Is this something that we should fix or we can just skip it from the output for now? Any thoughts?

I'd skip it for now and open an issue to include it. We should be as close to builder output as possible.

@ChrsMark
Copy link
Member Author

All right, I have removed the module information for now (filed #6541 for the generic fix) and added a test that checks that all expected components are found. The test can be further enhanced to check components' stability, buildinfo or whatever else we would like to include. For now I started with the bear minimum.

Feel free to take a look when you get the time.

@ChrsMark ChrsMark requested a review from swiatekm January 21, 2025 09:05
@ChrsMark
Copy link
Member Author

I wonder if the coverage failure is legit: #6539 (comment).

It complains that the new Components function is not covered, however it should be since it's called by the added test 🤔 .

@jlind23
Copy link
Contributor

jlind23 commented Jan 21, 2025

@ChrsMark we had similar problem in the past hence the reason why it became a non required check. Feel free to ignore it.

@ChrsMark ChrsMark enabled auto-merge (squash) January 22, 2025 10:33
@andrzej-stencel
Copy link
Contributor

Can we mention the command in the OTel README? I think it would help users make sure the command is supported. A single sentence with an example, similar to the one with validate command, would be fine, something like:

Use the components command to get the list of components included in the binary:

./elastic-agent otel components

@ChrsMark ChrsMark force-pushed the add_otel_components_cmd branch from 3d1f3b3 to 63ba927 Compare January 22, 2025 13:34
@ChrsMark
Copy link
Member Author

Can we mention the command in the OTel README? I think it would help users make sure the command is supported. A single sentence with an example, similar to the one with validate command, would be fine, something like:

Use the components command to get the list of components included in the binary:
./elastic-agent otel components

Done!

@ChrsMark
Copy link
Member Author

@andrzej-stencel @michalpristas @swiatekm I have enabled auto-merge but I guess that's not going to work without SonarQube test going green, right?

@swiatekm
Copy link
Contributor

@ChrsMark it will merge without SonarQube, you have a different failure coming from make check-ci. Whitespaces in documentation from what I've seen.

Signed-off-by: ChrsMark <chrismarkou92@gmail.com>
Signed-off-by: ChrsMark <chrismarkou92@gmail.com>
Signed-off-by: ChrsMark <chrismarkou92@gmail.com>
Signed-off-by: ChrsMark <chrismarkou92@gmail.com>
@ChrsMark ChrsMark force-pushed the add_otel_components_cmd branch from ec8a220 to 4cbb711 Compare January 23, 2025 11:19
Copy link

Quality Gate failed Quality Gate failed

Failed conditions
13.1% Coverage on New Code (required ≥ 40%)

See analysis details on SonarQube

@andrzej-stencel andrzej-stencel merged commit be4ee59 into elastic:main Jan 24, 2025
13 of 14 checks passed
mergify bot pushed a commit that referenced this pull request Jan 24, 2025
* Add otel components command

Signed-off-by: ChrsMark <chrismarkou92@gmail.com>

* fixes and test addition

Signed-off-by: ChrsMark <chrismarkou92@gmail.com>

* add note about components command in README

Signed-off-by: ChrsMark <chrismarkou92@gmail.com>

* fix fmt

Signed-off-by: ChrsMark <chrismarkou92@gmail.com>

---------

Signed-off-by: ChrsMark <chrismarkou92@gmail.com>
Co-authored-by: Andrzej Stencel <andrzej.stencel@elastic.co>
(cherry picked from commit be4ee59)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-8.x Automated backport to the 8.x branch with mergify enhancement New feature or request opentelemetry Related to the Elastic Distribution of the OpenTelemetry Collector Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants