Skip to content

Restructure repository for OTel version update#286

Merged
braydonk merged 9 commits into
masterfrom
restructure-modules
Apr 25, 2025
Merged

Restructure repository for OTel version update#286
braydonk merged 9 commits into
masterfrom
restructure-modules

Conversation

@braydonk
Copy link
Copy Markdown
Contributor

@braydonk braydonk commented Apr 23, 2025

The structure for components in this repo had a fundamental issue. Once we introduced components that were specific to Google-Built OpenTelemetry Collector, we had the issue of otelopscol components targeting an older version of OpenTelemetry. We don't want to force all components to be on the same OTel version; when targeting different distributions, the components need to be at whichever version that distribution is on.

This PR restructures the component directories to separate them into two separate directories, one for each distribution the component could be targeting. The Makefile structure is adjusted around this fact. The new process for upating OTel components for a distribution is to go into the Makefile for that distribution's components folder and update the version variables update the distrogen spec with the new intended OTel versions and then in the main directory call the associated target to update those components.

This PR also does the OTel version updates for Google-Built OpenTelemetry Collector to prove that the restructure worked effectively.

Updates were needed to the client auth extension based on: open-telemetry/opentelemetry-collector-contrib#38451 open-telemetry/opentelemetry-collector-contrib#38601

The structure for components in this repo had a fundamental issue. Once
we introduced components that were specific to Google-Built
OpenTelemetry Collector, we had the issue of otelopscol components
targeting an older version of OpenTelemetry. We don't want to force all
components to be on the same OTel version; when targeting different
distributions, the components need to be at whichever version that
distribution is on.

This PR restructures the component directories to separate them into two
separate directories, one for each distribution the component could be
targeting. The Makefile structure is adjusted around this fact. The new
process for upating OTel components for a distribution is to go into the
Makefile for that distribution's components folder and update the
version variables, then in the main directory call the associated target
to update those components.

This PR also does the OTel version updates for Google-Built
OpenTelemetry Collector to prove that the restructure worked
effectively.

Updates were needed to the client auth extension based on:
open-telemetry/opentelemetry-collector-contrib#38451
open-telemetry/opentelemetry-collector-contrib#38601
Adding distrogen spec querying allows for us to control our component
updates based on the otel versions in the spec file as a single source
of truth.
Copy link
Copy Markdown
Contributor

@jinghan-ma jinghan-ma left a comment

Choose a reason for hiding this comment

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

It would also be nice to add a short section in the readme to document the process for changing the target version (e.g. change version in .yaml spec, run update-google-otel-components, etc.)

Comment thread Makefile Outdated
Comment on lines +29 to +41
GOOGLE_OTEL_SPEC_QUERY = go run ./cmd/distrogen -spec specs/google-built-opentelemetry-collector.yaml -query
.PHONY: update-google-otel-components
update-google-otel-components: export OTEL_VERSION := v$(shell $(GOOGLE_OTEL_SPEC_QUERY) opentelemetry_version)
update-google-otel-components: export OTEL_CONTRIB_VERSION := v$(shell $(GOOGLE_OTEL_SPEC_QUERY) opentelemetry_contrib_version)
update-google-otel-components: install-tools
cd components/google-built-opentelemetry-collector && PATH="$(TOOLS_DIR):${PATH}" $(MAKE) update-components

OTELOPSCOL_SPEC_QUERY = go run ./cmd/distrogen -spec specs/otelopscol.yaml -query
.PHONY: update-otelopscol-components
update-otelopscol-components: export OTEL_VERSION := v$(shell $(OTELOPSCOL_SPEC_QUERY) opentelemetry_version)
update-otelopscol-components: export OTEL_CONTRIB_VERSION := v$(shell $(OTELOPSCOL_SPEC_QUERY) opentelemetry_contrib_version)
update-otelopscol-components: install-tools
cd components/otelopscol && PATH="$(TOOLS_DIR):${PATH}" $(MAKE) update-components
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Very nit picky, but it takes a bit of reading to realize that these two do the exact same thing, just on different directories. If we expect this to remain true in the future, maybe combining the definitions would make it our intentions more clear?

Something like:

.PHONY: update-google-otel-components update-otelopscol-components


update-google-otel-components: SPEC_FILE := specs/google-built-opentelemetry-collector.yaml
update-google-otel-components: COMPONENT_DIR := components/google-built-opentelemetry-collector

update-otelopscol-components: SPEC_FILE := specs/otelopscol.yaml
update-otelopscol-components: COMPONENT_DIR := components/otelopscol

update-google-otel-components update-otelopscol-components: DISTROGEN_QUERY := go run ./cmd/distrogen -spec $(SPEC_FILE) -query
update-google-otel-components update-otelopscol-components: export OTEL_VERSION := v$(shell $(DISTROGEN_QUERY) opentelemetry_version)
update-google-otel-components update-otelopscol-components: export OTEL_CONTRIB_VERSION := v$(shell $(DISTROGEN_QUERY) opentelemetry_contrib_version)
update-google-otel-components update-otelopscol-components: install-tools
    cd $(COMPONENT_DIR) && PATH="$(TOOLS_DIR):${PATH}" $(MAKE) update-components

I don't have strong opinions either way.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Applied suggestion in 29ed4cf

Comment thread cmd/distrogen/distribution.go Outdated
}

// Don't include .tools directory in comparison.
if strings.Contains(path, ".tools") {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Another super nitpick.

Since we already exclude all directories in the previous if statement. I think checking for /.tools/ in the path should still exclude contents in the .tools directory while excluding false positives like files/directories that contains the .tools substring like google.otel.tools (although it's super unlikely)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Excluding all directories just excludes the individual entry for that directory; filepath.WalkDir will still recursively walk the subdirectory even if we ignore the specific directory entry it presented us. So the check is still necessary.

Applied suggestion to make the check stricter in 8dc4905

Comment thread make/component_dir.mk
Comment on lines +4 to +7
.PHONY: update-otel-components
update-components: export OTEL_VERSION := $(OTEL_VERSION)
update-components: export OTEL_CONTRIB_VERSION := $(OTEL_CONTRIB_VERSION)
update-components: update-deps tidy-components update-mdatagen generate-components
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are these intended to be update-components or update-otel-components?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Named it update-components here because calling them otel components was redundant (all components in a component dir are otel)

@braydonk braydonk force-pushed the restructure-modules branch from 1889a70 to 8dc4905 Compare April 25, 2025 12:55
@braydonk braydonk requested a review from jinghan-ma April 25, 2025 12:57
@braydonk
Copy link
Copy Markdown
Contributor Author

It would also be nice to add a short section in the readme to document the process for changing the target version (e.g. change version in .yaml spec, run update-google-otel-components, etc.)

Added instructions in 397bae8

Copy link
Copy Markdown
Contributor

@LujieDuan LujieDuan left a comment

Choose a reason for hiding this comment

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

LGTM!

@braydonk braydonk merged commit 6b73289 into master Apr 25, 2025
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants