Skip to content

[receiver/prometheus] add feature flag to be able to disable Prometheus setting to fix high CPU for openmetrics #113683

[receiver/prometheus] add feature flag to be able to disable Prometheus setting to fix high CPU for openmetrics

[receiver/prometheus] add feature flag to be able to disable Prometheus setting to fix high CPU for openmetrics #113683

name: build-and-test-windows
on:
push:
branches:
- "main"
- "releases/**"
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
merge_group:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]
branches:
- main
env:
TEST_RESULTS: testbed/tests/results/junit/results.xml
# Make sure to exit early if cache segment download times out after 2 minutes.
# We limit cache download as a whole to 5 minutes.
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2
# Do not cancel this workflow on main
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions: read-all
jobs:
windows-unittest-matrix:
strategy:
fail-fast: false
matrix:
group:
- receiver-0
- receiver-1
- receiver-2
- receiver-3
- processor-0
- processor-1
- exporter-0
- exporter-1
- exporter-2
- exporter-3
- extension
- connector
- internal
- pkg
- cmd-0
- other
os: [windows-2022, windows-2025]
runs-on: ${{ matrix.os }}
if: ${{ github.actor != 'dependabot[bot]' && (contains(github.event.pull_request.labels.*.name, 'Run Windows') || github.event_name == 'push' || github.event_name == 'merge_group') }}
env:
# Limit memory usage via GC environment variables to avoid OOM on GH runners, especially for `cmd/otelcontribcol`,
# see https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/28682#issuecomment-1802296776
GOGC: 50
GOMEMLIMIT: 2GiB
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: install IIS
run: Install-WindowsFeature -name Web-Server -IncludeManagementTools
- uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5
with:
go-version: 1.23.9
cache: false
- name: Cache Go
id: go-mod-cache
timeout-minutes: 25
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4
with:
path: |
~\go\pkg\mod
~\AppData\Local\go-build
key: go-build-cache-${{ runner.os }}-${{ matrix.group }}-go-${{ hashFiles('**/go.sum') }}
- name: Ensure required ports in the dynamic range are available
run: |
& ${{ github.workspace }}\.github\workflows\scripts\win-required-ports.ps1
- name: Build shared test tools
# If component tests share Makefile targets they need to be added here to avoid
# concurrent component tests clashing when building such targets. This applies
# specifically to Windows, see https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/34691
run: make "$(${PWD} -replace '\\', '/')/.tools/gotestsum"
# Unit tests without JUnit output are much faster, so it's fine to run on every PR.
# The only time we don't run them is when we already ran them with JUnit output.
- name: Run Unit Tests
id: tests
if: github.ref != 'refs/heads/main'
run: make -j2 gotest GROUP=${{ matrix.group }}
# JUnit tests are super long, so we only run them on pushes to the main branch.
# This is used for automation that automatically creates issues for flaky tests that are
# merged to main, so we don't run them on every PR.
- name: Run Unit Tests With JUnit and Coverage
id: tests-with-junit
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
continue-on-error: true # Allow uploading artifacts even if the test fails
run: make gotest-with-junit-and-cover GROUP=${{ matrix.group }}
- uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
with:
name: test-results-windows-${{ matrix.os }}-${{ matrix.group }}
path: internal/tools/testresults/
retention-days: 4
- name: Fail workflow if tests fails
if: always()
shell: bash
run: |
if [[ "${{ steps.tests-with-junit.outcome }}" == "failure" || "${{ steps.tests.outcome }}" == "failure" ]]; then
echo "Tests failed. Failing workflow."
exit 1
else
echo "Tests passed or were skipped. Continuing."
fi
windows-unittest:
if: ${{ github.actor != 'dependabot[bot]' && (contains(github.event.pull_request.labels.*.name, 'Run Windows') || github.event_name == 'push' || github.event_name == 'merge_group') }}
runs-on: windows-latest
needs: [windows-unittest-matrix]
steps:
- name: Print result
run: echo ${{ needs.windows-unittest-matrix.result }}
- name: Interpret result
shell: bash
run: |
if [[ success == ${{ needs.windows-unittest-matrix.result }} ]]
then
echo "All matrix jobs passed!"
else
echo "One or more matrix jobs failed."
false
fi
flakytests-generate-issues:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-24.04
needs: [windows-unittest-matrix]
permissions:
issues: write
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5
with:
go-version: 1.23.9
cache: false
- name: Cache Go
id: go-cache
timeout-minutes: 5
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4
with:
path: |
~/go/bin
~/go/pkg/mod
./.tools
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Install dependencies
if: steps.go-cache.outputs.cache-hit != 'true'
run: make -j2 gomoddownload
- uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4
with:
merge-multiple: true
pattern: test-results-windows-*
path: ./internal/tools/testresults/
- name: Install Tools
if: steps.go-cache.outputs.cache-hit != 'true'
run: make install-tools
- name: Generate Issues
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./.tools/issuegenerator -path ./internal/tools/testresults/