Skip to content

Remove path parts from component label suffixes #38622

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

Merged
merged 1 commit into from
Mar 18, 2025

Conversation

gabgg71
Copy link
Contributor

@gabgg71 gabgg71 commented Mar 13, 2025

Description

To generate labels for all components, including those with paths longer than 50 characters:
In the root Makefile, a phony target is created to generate the .github/component_labels file, which contains the component paths and their corresponding labels (shortened paths for those exceeding 50 characters by removing repeated patterns in the string). The file is space-delimited.
In the build-and-test workflow, under the checks job, a step is added to verify that the .github/component_labels file exists.
The scripts used in the workflows are adjusted to use the .github/component_labels file as a reference for mappings between component paths and their labels.

Link to tracking issue

Fixes #38527

@gabgg71 gabgg71 requested a review from a team as a code owner March 13, 2025 20:43
@gabgg71 gabgg71 requested a review from mx-psi March 13, 2025 20:43
Copy link

linux-foundation-easycla bot commented Mar 13, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: gabgg71 / name: Gabriela Galindo (946aaf7)

@gabgg71 gabgg71 changed the title Remove path parts from component label suffixes (#38527) Remove path parts from component label suffixes Mar 13, 2025
@mx-psi
Copy link
Member

mx-psi commented Mar 14, 2025

Hi there! You need to sign the CLA in order for us to be able to accept your contribution. Could you take a look at this? Thanks!

@gabgg71 gabgg71 force-pushed the shorten-labels branch 5 times, most recently from 4d35745 to 69e855a Compare March 17, 2025 22:17
@mx-psi
Copy link
Member

mx-psi commented Mar 18, 2025

Seems like you need to run make genlabels

@atoulme atoulme added the ready to merge Code review completed; ready to merge by maintainers label Mar 18, 2025
@atoulme atoulme merged commit 47ce02a into open-telemetry:main Mar 18, 2025
180 checks passed
@github-actions github-actions bot added this to the next release milestone Mar 18, 2025
atoulme pushed a commit that referenced this pull request Mar 20, 2025
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
Lately some `Ping code owners on a new issue` action runs have [been
failing](https://github.com/open-telemetry/opentelemetry-collector-contrib/actions/runs/13972340605/job/39117145364)
with the following error:
```
./.github/workflows/scripts/ping-codeowners-on-new-issue.sh: line 36: COMPONENT: unbound variable
```

This was because recently a variable reference was changed to the wrong
variable name, view the diff of the related PR to see the context.

Related:
#38622
atoulme pushed a commit that referenced this pull request Mar 20, 2025
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
The current `awk` expression will return all matches, so if a component
label is a substring of another component label, the resulting label
will be all matching labels appended to each other.

Example:
#38780
The label wasn't originally added because the [found label was too long
to
add](https://github.com/open-telemetry/opentelemetry-collector-contrib/actions/runs/13938538170/job/39010977164).
However, code owners were properly pinged. When I added the proper
label, the [incorrect label name was
detected](#38780 (comment)).

When searching the `.github/component_labels.txt` file, the label we
want to add is the first match that we find. This is the **minimally
matching label**, since the file is in alphabetical order. There may be
a better `awk` way to implement this logic, but `head -n 1` returns the
first matching line, if any are found in the given text.

<!-- Issue number (e.g. #1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Related
#38622

<!--Describe what testing was performed and which tests were added.-->
#### Testing
**Before:**
```
crobert$ ~/dev/contrib/first $ COMPONENT="receiver/hostmetrics"
crobert$ ~/dev/contrib/first $ awk -v path="${COMPONENT}" 'index($1, path) > 0 || index($2, path) > 0 {print $1}' .github/component_labels.txt
receiver/hostmetricsreceiver
receiver/hostmetricsreceiver/internal/scraper/cpuscraper
receiver/hostmetricsreceiver/internal/scraper/diskscraper
receiver/hostmetricsreceiver/internal/scraper/filesystemscraper
receiver/hostmetricsreceiver/internal/scraper/loadscraper
receiver/hostmetricsreceiver/internal/scraper/memoryscraper
receiver/hostmetricsreceiver/internal/scraper/networkscraper
receiver/hostmetricsreceiver/internal/scraper/pagingscraper
receiver/hostmetricsreceiver/internal/scraper/processesscraper
receiver/hostmetricsreceiver/internal/scraper/processscraper
receiver/hostmetricsreceiver/internal/scraper/systemscraper
crobert$ ~/dev/contrib/first $ COMPONENT="extension/encoding"
crobert$ ~/dev/contrib/first $ awk -v path="${COMPONENT}" 'index($1, path) > 0 || index($2, path) > 0 {print $1}' .github/component_labels.txt
extension/encoding
extension/encoding/avrologencodingextension
extension/encoding/awscloudwatchmetricstreamsencodingextension
extension/encoding/awslogsencodingextension
extension/encoding/googlecloudlogentryencodingextension
extension/encoding/jaegerencodingextension
extension/encoding/jsonlogencodingextension
extension/encoding/otlpencodingextension
extension/encoding/skywalkingencodingextension
extension/encoding/textencodingextension
extension/encoding/zipkinencodingextension
```
**After:**
```
crobert$ ~/dev/contrib/first $ COMPONENT="receiver/hostmetrics"
crobert$ ~/dev/contrib/first $ awk -v path="${COMPONENT}" 'index($1, path) > 0 || index($2, path) > 0 {print $1}' .github/component_labels.txt | head -n 1
receiver/hostmetricsreceiver
crobert$ ~/dev/contrib/first $ COMPONENT="extension/encoding"
crobert$ ~/dev/contrib/first $ awk -v path="${COMPONENT}" 'index($1, path) > 0 || index($2, path) > 0 {print $1}' .github/component_labels.txt | head -n 1
extension/encoding
atoulme pushed a commit that referenced this pull request Mar 21, 2025
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
After checking the component labels file, `COMPONENT` may be empty if
the label added is not for a component. This is a valid and acceptable
state. If the label does not correspond to a component, code owners
don't need to be pinged.

This is to fix the following [example
failure](https://github.com/open-telemetry/opentelemetry-collector-contrib/actions/runs/13994662160/job/39186701459).

<!-- Issue number (e.g. #1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Related to
#38622

Before the related PR the passed in component was checked to make sure
it wasn't empty and passed directly to the `get-codeowners.sh` script,
which fails if `COMPONENT` is empty, and returns an empty string
successfully if the given label is not a component. After the change,
`COMPONENT` is modified to potentially be empty, then passed to
`get-codeowners.sh`. This is what caused the `1` return code.

<!--Describe what testing was performed and which tests were added.-->
#### Testing
Tested locally with the label `os:windows`. The script passes with the
change, failed before.
Fiery-Fenix pushed a commit to Fiery-Fenix/opentelemetry-collector-contrib that referenced this pull request Apr 24, 2025
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
To generate labels for all components, including those with paths longer
than 50 characters:
In the root Makefile, a phony target is created to generate the
.github/component_labels file, which contains the component paths and
their corresponding labels (shortened paths for those exceeding 50
characters by removing repeated patterns in the string). The file is
space-delimited.
In the build-and-test workflow, under the checks job, a step is added to
verify that the .github/component_labels file exists.
The scripts used in the workflows are adjusted to use the
.github/component_labels file as a reference for mappings between
component paths and their labels.

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes open-telemetry#38527
Fiery-Fenix pushed a commit to Fiery-Fenix/opentelemetry-collector-contrib that referenced this pull request Apr 24, 2025
…elemetry#38840)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
Lately some `Ping code owners on a new issue` action runs have [been
failing](https://github.com/open-telemetry/opentelemetry-collector-contrib/actions/runs/13972340605/job/39117145364)
with the following error:
```
./.github/workflows/scripts/ping-codeowners-on-new-issue.sh: line 36: COMPONENT: unbound variable
```

This was because recently a variable reference was changed to the wrong
variable name, view the diff of the related PR to see the context.

Related:
open-telemetry#38622
Fiery-Fenix pushed a commit to Fiery-Fenix/opentelemetry-collector-contrib that referenced this pull request Apr 24, 2025
…metry#38844)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
The current `awk` expression will return all matches, so if a component
label is a substring of another component label, the resulting label
will be all matching labels appended to each other.

Example:
open-telemetry#38780
The label wasn't originally added because the [found label was too long
to
add](https://github.com/open-telemetry/opentelemetry-collector-contrib/actions/runs/13938538170/job/39010977164).
However, code owners were properly pinged. When I added the proper
label, the [incorrect label name was
detected](open-telemetry#38780 (comment)).

When searching the `.github/component_labels.txt` file, the label we
want to add is the first match that we find. This is the **minimally
matching label**, since the file is in alphabetical order. There may be
a better `awk` way to implement this logic, but `head -n 1` returns the
first matching line, if any are found in the given text.

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Related
open-telemetry#38622

<!--Describe what testing was performed and which tests were added.-->
#### Testing
**Before:**
```
crobert$ ~/dev/contrib/first $ COMPONENT="receiver/hostmetrics"
crobert$ ~/dev/contrib/first $ awk -v path="${COMPONENT}" 'index($1, path) > 0 || index($2, path) > 0 {print $1}' .github/component_labels.txt
receiver/hostmetricsreceiver
receiver/hostmetricsreceiver/internal/scraper/cpuscraper
receiver/hostmetricsreceiver/internal/scraper/diskscraper
receiver/hostmetricsreceiver/internal/scraper/filesystemscraper
receiver/hostmetricsreceiver/internal/scraper/loadscraper
receiver/hostmetricsreceiver/internal/scraper/memoryscraper
receiver/hostmetricsreceiver/internal/scraper/networkscraper
receiver/hostmetricsreceiver/internal/scraper/pagingscraper
receiver/hostmetricsreceiver/internal/scraper/processesscraper
receiver/hostmetricsreceiver/internal/scraper/processscraper
receiver/hostmetricsreceiver/internal/scraper/systemscraper
crobert$ ~/dev/contrib/first $ COMPONENT="extension/encoding"
crobert$ ~/dev/contrib/first $ awk -v path="${COMPONENT}" 'index($1, path) > 0 || index($2, path) > 0 {print $1}' .github/component_labels.txt
extension/encoding
extension/encoding/avrologencodingextension
extension/encoding/awscloudwatchmetricstreamsencodingextension
extension/encoding/awslogsencodingextension
extension/encoding/googlecloudlogentryencodingextension
extension/encoding/jaegerencodingextension
extension/encoding/jsonlogencodingextension
extension/encoding/otlpencodingextension
extension/encoding/skywalkingencodingextension
extension/encoding/textencodingextension
extension/encoding/zipkinencodingextension
```
**After:**
```
crobert$ ~/dev/contrib/first $ COMPONENT="receiver/hostmetrics"
crobert$ ~/dev/contrib/first $ awk -v path="${COMPONENT}" 'index($1, path) > 0 || index($2, path) > 0 {print $1}' .github/component_labels.txt | head -n 1
receiver/hostmetricsreceiver
crobert$ ~/dev/contrib/first $ COMPONENT="extension/encoding"
crobert$ ~/dev/contrib/first $ awk -v path="${COMPONENT}" 'index($1, path) > 0 || index($2, path) > 0 {print $1}' .github/component_labels.txt | head -n 1
extension/encoding
Fiery-Fenix pushed a commit to Fiery-Fenix/opentelemetry-collector-contrib that referenced this pull request Apr 24, 2025
…elemetry#38862)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
After checking the component labels file, `COMPONENT` may be empty if
the label added is not for a component. This is a valid and acceptable
state. If the label does not correspond to a component, code owners
don't need to be pinged.

This is to fix the following [example
failure](https://github.com/open-telemetry/opentelemetry-collector-contrib/actions/runs/13994662160/job/39186701459).

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Related to
open-telemetry#38622

Before the related PR the passed in component was checked to make sure
it wasn't empty and passed directly to the `get-codeowners.sh` script,
which fails if `COMPONENT` is empty, and returns an empty string
successfully if the given label is not a component. After the change,
`COMPONENT` is modified to potentially be empty, then passed to
`get-codeowners.sh`. This is what caused the `1` return code.

<!--Describe what testing was performed and which tests were added.-->
#### Testing
Tested locally with the label `os:windows`. The script passes with the
change, failed before.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge Code review completed; ready to merge by maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove path parts from component label suffixes
4 participants