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

enabled CGO for Macos otelcol contrib #626

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion .github/workflows/base-ci-goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
GOARCH: arm
- GOOS: windows
GOARCH: s390x
runs-on: ubuntu-22.04
runs-on: ${{ fromJSON( inputs.runs-on) }}

steps:
- name: Checkout
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/base-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
GOARCH: arm
- GOOS: windows
GOARCH: s390x
runs-on: ubuntu-22.04
runs-on: ${{ fromJSON( inputs.runs-on) }}

steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
Expand Down Expand Up @@ -101,7 +101,7 @@ jobs:

release:
name: ${{ inputs.distribution }} Release
runs-on: ubuntu-22.04
runs-on: ${{ fromJSON( inputs.runs-on) }}
needs: prepare

permissions:
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/ci-goreleaser-contrib-cgo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Continuous Integration - Contrib - GoReleaser

on:
push:
branches: [main]
paths:
- "distributions/otelcol-contrib-cgo/**"
- "cmd/**"
- ".github/**"
- "scripts/**"
- "Makefile"
- "go.mod"
- "go.sum"
pull_request:
branches: [main]
paths:
- "distributions/otelcol-contrib-cgo/**"
- "cmd/**"
- ".github/**"
- "scripts/**"
- "Makefile"
- "go.mod"
- "go.sum"

jobs:
check-goreleaser:
name: Continuous Integration - Contrib CGO - GoReleaser
uses: ./.github/workflows/base-ci-goreleaser.yaml
with:
distribution: otelcol-contrib-cgo
goos: '[ "darwin" ]'
goarch: '[ "amd64", "arm64" ]'
runs-on: '[ macos-latest ]'
secrets: inherit
1 change: 1 addition & 0 deletions .github/workflows/ci-goreleaser-contrib.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
distribution: otelcol-contrib
goos: '[ "linux", "windows", "darwin" ]'
goarch: '[ "386", "amd64", "arm64", "ppc64le", "arm", "s390x" ]'
runs-on: '[ ubuntu-22.04 ]'
secrets: inherit

package-tests:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-goreleaser-core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
distribution: otelcol
goos: '[ "linux", "windows", "darwin" ]'
goarch: '[ "386", "amd64", "arm64", "ppc64le", "arm", "s390x" ]'
runs-on: '[ ubuntu-22.04 ]'
secrets: inherit

package-tests:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-goreleaser-k8s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ jobs:
distribution: otelcol-k8s
goos: '[ "linux" ]'
goarch: '[ "amd64", "arm64", "ppc64le", "s390x" ]'
runs-on: '[ ubuntu-22.04 ]'
secrets: inherit
17 changes: 17 additions & 0 deletions .github/workflows/release-contrib-cgo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Release Contrib
pureklkl marked this conversation as resolved.
Show resolved Hide resolved

on:
push:
tags: ["v*"]

jobs:
release:
name: Release Contrib
uses: ./.github/workflows/base-release.yaml
with:
distribution: otelcol-contrib-cgo
goos: '[ "darwin" ]'
goarch: '[ "amd64", "arm64" ]'
runs-on: '[ macos-latest ]'
secrets: inherit
permissions: write-all
1 change: 1 addition & 0 deletions .github/workflows/release-contrib.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ jobs:
distribution: otelcol-contrib
goos: '[ "linux", "windows", "darwin" ]'
goarch: '[ "386", "amd64", "arm64", "ppc64le", "arm", "s390x" ]'
runs-on: '[ ubuntu-22.04 ]'
secrets: inherit
permissions: write-all
1 change: 1 addition & 0 deletions .github/workflows/release-core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ jobs:
distribution: otelcol
goos: '[ "linux", "windows", "darwin" ]'
goarch: '[ "386", "amd64", "arm64", "ppc64le", "arm", "s390x" ]'
runs-on: '[ ubuntu-22.04 ]'
secrets: inherit
permissions: write-all
1 change: 1 addition & 0 deletions .github/workflows/release-k8s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ jobs:
distribution: otelcol-k8s
goos: '[ "linux" ]'
goarch: '[ "amd64", "arm64", "ppc64le", "s390x" ]'
runs-on: '[ ubuntu-22.04 ]'
secrets: inherit
permissions: write-all
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ OTELCOL_BUILDER_VERSION ?= 0.106.1
OTELCOL_BUILDER_DIR ?= ${HOME}/bin
OTELCOL_BUILDER ?= ${OTELCOL_BUILDER_DIR}/ocb

DISTRIBUTIONS ?= "otelcol,otelcol-contrib,otelcol-k8s"
DISTRIBUTIONS ?= "otelcol,otelcol-contrib,otelcol-k8s,otelcol-contrib-cgo"
GEN_CONFIG_DISTRIBUTIONS ?= "otelcol,otelcol-contrib"

ci: check build
Expand Down
46 changes: 46 additions & 0 deletions distributions/otelcol-contrib-cgo/.goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
partial:
by: target
version: 2
project_name: opentelemetry-collector-releases
env:
- COSIGN_YES=true
builds:
- id: otelcol-contrib-cgo
goos:
- darwin
goarch:
- amd64
- arm64
dir: _build
binary: otelcol-contrib-cgo
ldflags:
- -s
- -w
flags:
- -trimpath
env:
- CGO_ENABLED=1
archives:
- id: otelcol-contrib-cgo
builds:
- otelcol-contrib-cgo
name_template: '{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}'
checksum:
name_template: '{{ .ProjectName }}_otelcol-contrib-cgo_checksums.txt'
signs:
- cmd: cosign
args:
- sign-blob
- --output-signature
- ${artifact}.sig
- --output-certificate
- ${artifact}.pem
- ${artifact}
signature: ${artifact}.sig
artifacts: all
certificate: ${artifact}.pem
sboms:
- id: archive
artifacts: archive
- id: package
artifacts: package
11 changes: 11 additions & 0 deletions distributions/otelcol-contrib-cgo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# OpenTelemetry Collector Contrib CGO Distro
Copy link
Member

Choose a reason for hiding this comment

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

As a user, I would find it confusing. Why should I care? What does it bring that others don't?

I'm not sure I like the idea of a distribution with just a different platform or compilation mechanism. I would prefer a solution where we built with the right options based on what we need to ship.

Does hostmetrics require cgo when compiled for Darwin? Then we should use cgo to compile the distributions that include that component for Darwin.

I find a separate cgo distribution confusing, and opens the door for a cgo distribution for other platforms, which is not something we want.

Copy link
Author

Choose a reason for hiding this comment

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

My concern is that when CGO is enabled, the binary is coupled to certain OS versions and will support less OS versions.

Copy link
Author

Choose a reason for hiding this comment

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

@jpkrohling
Hi, I have updated the PR to just enable CGO for Macos otelcol contrib, could you review it again?

Copy link
Member

Choose a reason for hiding this comment

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

I would like to have it discussed as part of the SIG and have buy-in from other maintainers.

Copy link
Author

Choose a reason for hiding this comment

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

Hi, I have tested with golang 10.15 and it works, which is also the oldest macos version that golang >= 1.21 supported ref
I think we could just turn on the CGO option without a separated distribution.


This distribution is a CGO enabled version of [OpenTelemetry Collector Contrib](https://github.com/open-telemetry/opentelemetry-collector-contrib). This distribution contains the same components with [OpenTelemetry Collector Contrib Distro](https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib).

## Components

The full list of components is available in the [manifest](manifest.yaml)

### Rules for Component Inclusion

- Include all extensions at [Alpha stability](https://github.com/open-telemetry/opentelemetry-collector#alpha) or higher and pipeline components that have at least 1 signal at [Alpha stability](https://github.com/open-telemetry/opentelemetry-collector#alpha) or higher.
Loading