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

WIP: otelcol: use ocb to autogenerate source files #5382

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions internal/pkg/otel/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.PHONY: all
Copy link
Contributor

Choose a reason for hiding this comment

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

Make sure you include this in mage update target at root.
It would be nice if mage update could regenerate sources. Update go mod versions and then update readme file as it does today.


all:
go run go.opentelemetry.io/collector/cmd/[email protected] --skip-compilation --skip-get-modules --config builder-config.yaml
@rm main.go main_others.go main_windows.go go.mod
Copy link
Member Author

@mauri870 mauri870 Aug 29, 2024

Choose a reason for hiding this comment

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

This is a bit hacky since ocb expects to build a final binary. Having an otel collector embedded into another binary seems to be quite useful, I wonder if the folks at OpenTelemetry would be willing to support a ocb mode to build a library instead of a final binary.

sed -i 's/package main/\/\/go:build \!windows\npackage otel/g' components.go
mauri870 marked this conversation as resolved.
Show resolved Hide resolved
43 changes: 43 additions & 0 deletions internal/pkg/otel/builder-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
dist:
name: otelcol
description: Elastic Distribution of OpenTelemetry Collector
module: otel
output_path: .

extensions:
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension v0.107.0
Copy link
Member Author

@mauri870 mauri870 Aug 29, 2024

Choose a reason for hiding this comment

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

Unfortunately, we can't manage versions in this file and sync them with a go.mod file, since the dependencies are defined in the elastic-agent go.mod located at the root of the repository. We could consider using Go workspaces and moving this code to ${REPO_ROOT}/otel, for example, so it can be its own module with its own go.mod file. This approach would also clean up the otelcol dependencies in the root go.mod file.

Copy link
Contributor

Choose a reason for hiding this comment

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

We have dependabot currently bumping up the OTel dependency versions in go.mod: https://github.com/elastic/elastic-agent/blob/main/.github/dependabot.yml. Perhaps we can add a new step or job to https://github.com/elastic/elastic-agent/blob/main/.github/workflows/post-dependabot.yml to do some parsing of the go.mod file and sync the versions in this file with the parsed results?

- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/storage/filestorage v0.107.0
- gomod: go.opentelemetry.io/collector/extension/memorylimiterextension v0.107.0

exporters:
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/elasticsearchexporter v0.107.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/fileexporter v0.107.0
- gomod: go.opentelemetry.io/collector/exporter/debugexporter v0.107.0
- gomod: go.opentelemetry.io/collector/exporter/otlpexporter v0.107.0
- gomod: go.opentelemetry.io/collector/exporter/otlphttpexporter v0.107.0

processors:
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/attributesprocessor v0.107.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor v0.107.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/k8sattributesprocessor v0.107.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor v0.107.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourceprocessor v0.107.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor v0.107.0
- gomod: go.opentelemetry.io/collector/processor/batchprocessor v0.107.0
- gomod: go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.107.0
- gomod: github.com/elastic/opentelemetry-collector-components/processor/elasticinframetricsprocessor v0.9.0

receivers:
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/filelogreceiver v0.107.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver v0.107.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/httpcheckreceiver v0.107.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jaegerreceiver v0.107.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/k8sclusterreceiver v0.107.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/k8sobjectsreceiver v0.107.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/kubeletstatsreceiver v0.107.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.107.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zipkinreceiver v0.107.0
- gomod: go.opentelemetry.io/collector/receiver/otlpreceiver v0.107.0

connectors:
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector v0.107.0
149 changes: 83 additions & 66 deletions internal/pkg/otel/components.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.