diff --git a/distributions/otelcol-sampling/.goreleaser.yaml b/distributions/otelcol-sampling/.goreleaser.yaml new file mode 100644 index 0000000..d424e71 --- /dev/null +++ b/distributions/otelcol-sampling/.goreleaser.yaml @@ -0,0 +1,135 @@ +project_name: otelcol-sampling +builds: + - id: otelcol-sampling + goos: + - darwin + - linux + - windows + goarch: + - "386" + - amd64 + - arm64 + - ppc64le + ignore: + - goos: darwin + goarch: "386" + - goos: windows + goarch: arm64 + dir: _build + binary: otelcol-sampling + ldflags: + - -s + - -w + flags: + - -trimpath + env: + - CGO_ENABLED=0 +archives: + - id: otelcol-sampling + builds: + - otelcol-sampling + name_template: '{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}' +nfpms: + - package_name: otelcol-sampling + contents: + - src: otelcol-sampling.service + dst: /lib/systemd/system/otelcol-sampling.service + - src: otelcol-sampling.conf + dst: /etc/otelcol-sampling/otelcol-sampling.conf + type: config|noreplace + - src: otelcol.yaml + dst: /etc/otelcol-sampling/config.yaml + type: config + scripts: + preinstall: preinstall.sh + postinstall: postinstall.sh + preremove: preremove.sh + id: otelcol-sampling + builds: + - otelcol-sampling + formats: + - apk + - deb + - rpm + maintainer: Juraci Paixão Kröhling + description: otelcol-sampling distribution of the OpenTelemetry Collector + license: Apache 2.0 +checksum: + name_template: '{{ .ProjectName }}_checksums.txt' +dockers: + - goos: linux + goarch: "386" + dockerfile: Dockerfile + image_templates: + - ghcr.io/jpkrohling/otelcol-distributions/otelcol-sampling:{{ .Version }}-386 + extra_files: + - otelcol.yaml + build_flag_templates: + - --pull + - --platform=linux/386 + - --label=org.opencontainers.image.created={{.Date}} + - --label=org.opencontainers.image.name={{.ProjectName}} + - --label=org.opencontainers.image.revision={{.FullCommit}} + - --label=org.opencontainers.image.version={{.Version}} + - --label=org.opencontainers.image.source={{.GitURL}} + use: buildx + - goos: linux + goarch: amd64 + dockerfile: Dockerfile + image_templates: + - ghcr.io/jpkrohling/otelcol-distributions/otelcol-sampling:{{ .Version }}-amd64 + extra_files: + - otelcol.yaml + build_flag_templates: + - --pull + - --platform=linux/amd64 + - --label=org.opencontainers.image.created={{.Date}} + - --label=org.opencontainers.image.name={{.ProjectName}} + - --label=org.opencontainers.image.revision={{.FullCommit}} + - --label=org.opencontainers.image.version={{.Version}} + - --label=org.opencontainers.image.source={{.GitURL}} + use: buildx + - goos: linux + goarch: arm64 + dockerfile: Dockerfile + image_templates: + - ghcr.io/jpkrohling/otelcol-distributions/otelcol-sampling:{{ .Version }}-arm64 + extra_files: + - otelcol.yaml + build_flag_templates: + - --pull + - --platform=linux/arm64 + - --label=org.opencontainers.image.created={{.Date}} + - --label=org.opencontainers.image.name={{.ProjectName}} + - --label=org.opencontainers.image.revision={{.FullCommit}} + - --label=org.opencontainers.image.version={{.Version}} + - --label=org.opencontainers.image.source={{.GitURL}} + use: buildx + - goos: linux + goarch: ppc64le + dockerfile: Dockerfile + image_templates: + - ghcr.io/jpkrohling/otelcol-distributions/otelcol-sampling:{{ .Version }}-ppc64le + extra_files: + - otelcol.yaml + build_flag_templates: + - --pull + - --platform=linux/ppc64le + - --label=org.opencontainers.image.created={{.Date}} + - --label=org.opencontainers.image.name={{.ProjectName}} + - --label=org.opencontainers.image.revision={{.FullCommit}} + - --label=org.opencontainers.image.version={{.Version}} + - --label=org.opencontainers.image.source={{.GitURL}} + use: buildx +docker_manifests: + - name_template: ghcr.io/jpkrohling/otelcol-distributions/otelcol-sampling:{{ .Version }} + image_templates: + - ghcr.io/jpkrohling/otelcol-distributions/otelcol-sampling:{{ .Version }}-386 + - ghcr.io/jpkrohling/otelcol-distributions/otelcol-sampling:{{ .Version }}-amd64 + - ghcr.io/jpkrohling/otelcol-distributions/otelcol-sampling:{{ .Version }}-arm64 + - ghcr.io/jpkrohling/otelcol-distributions/otelcol-sampling:{{ .Version }}-ppc64le +sboms: + - id: archive + artifacts: archive + - id: package + artifacts: package diff --git a/distributions/otelcol-sampling/Dockerfile b/distributions/otelcol-sampling/Dockerfile new file mode 100644 index 0000000..c5d5c8f --- /dev/null +++ b/distributions/otelcol-sampling/Dockerfile @@ -0,0 +1,10 @@ +FROM alpine:latest + +ARG USER_UID=10001 +USER ${USER_UID} + +COPY otelcol-sampling /otelcol-sampling +COPY otelcol.yaml /etc/otelcol-sampling/config.yaml +ENTRYPOINT ["/otelcol-sampling"] +CMD ["--config", "/etc/otelcol-sampling/config.yaml"] +EXPOSE 4317 diff --git a/distributions/otelcol-sampling/manifest.yaml b/distributions/otelcol-sampling/manifest.yaml new file mode 100644 index 0000000..8c3b08a --- /dev/null +++ b/distributions/otelcol-sampling/manifest.yaml @@ -0,0 +1,24 @@ +dist: + module: github.com/jpkrohling/otelcol-distributions/otelcol-sampling + name: otelcol + description: OpenTelemetry Collector distribution with sampling processors + version: 0.101.0 + output_path: ./_build + otelcol_version: 0.101.0 + +extensions: + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension v0.101.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/pprofextension v0.101.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/basicauthextension v0.101.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/bearertokenauthextension v0.101.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/oauth2clientauthextension v0.101.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/oidcauthextension v0.101.0 +receivers: + - gomod: go.opentelemetry.io/collector/receiver/otlpreceiver v0.101.0 +exporters: + - gomod: go.opentelemetry.io/collector/exporter/nopexporter v0.101.0 + - gomod: go.opentelemetry.io/collector/exporter/otlpexporter v0.101.0 + - gomod: go.opentelemetry.io/collector/exporter/otlphttpexporter v0.101.0 +processors: + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor v0.101.0 + - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/probabilisticsamplerprocessor v0.101.0 diff --git a/distributions/otelcol-sampling/otelcol-sampling.conf b/distributions/otelcol-sampling/otelcol-sampling.conf new file mode 100644 index 0000000..53b3b3a --- /dev/null +++ b/distributions/otelcol-sampling/otelcol-sampling.conf @@ -0,0 +1,5 @@ +# Systemd environment file for the otelcol-sampling service + +# Command-line options for the otelcol-sampling service. +# Run `/usr/bin/otelcol-sampling --help` to see all available options. +OTELCOL_OPTIONS="--config=/etc/otelcol-sampling/config.yaml" \ No newline at end of file diff --git a/distributions/otelcol-sampling/otelcol-sampling.service b/distributions/otelcol-sampling/otelcol-sampling.service new file mode 100644 index 0000000..217906a --- /dev/null +++ b/distributions/otelcol-sampling/otelcol-sampling.service @@ -0,0 +1,15 @@ +[Unit] +Description=OpenTelemetry Collector distribution with sampling processors +After=network.target + +[Service] +EnvironmentFile=/etc/otelcol-sampling/otelcol-sampling.conf +ExecStart=/usr/bin/otelcol-sampling $OTELCOL_OPTIONS +KillMode=mixed +Restart=on-failure +Type=simple +User=otelcol-sampling +Group=otelcol-sampling + +[Install] +WantedBy=multi-user.target diff --git a/distributions/otelcol-sampling/otelcol-test.yaml b/distributions/otelcol-sampling/otelcol-test.yaml new file mode 100644 index 0000000..1b93df1 --- /dev/null +++ b/distributions/otelcol-sampling/otelcol-test.yaml @@ -0,0 +1,39 @@ +extensions: + health_check: {} + pprof: {} + +receivers: + otlp: + protocols: + grpc: {} + +exporters: + nop: + otlp: + endpoint: otlp.example.com:4317 + otlphttp: + endpoint: https://otlp.example.com/otlp + +processors: + tail_sampling: + decision_wait: 10s + num_traces: 100 + expected_new_traces_per_sec: 10 + policies: + [ + { + name: test-policy-1, + type: always_sample + }, + ] + + probabilistic_sampler: + sampling_percentage: 100 + +service: + extensions: [ health_check, pprof ] + pipelines: + traces: + receivers: [ otlp ] + processors: [ probabilistic_sampler, tail_sampling ] + exporters: [ nop, otlp, otlphttp ] diff --git a/distributions/otelcol-sampling/otelcol.yaml b/distributions/otelcol-sampling/otelcol.yaml new file mode 100644 index 0000000..1b93df1 --- /dev/null +++ b/distributions/otelcol-sampling/otelcol.yaml @@ -0,0 +1,39 @@ +extensions: + health_check: {} + pprof: {} + +receivers: + otlp: + protocols: + grpc: {} + +exporters: + nop: + otlp: + endpoint: otlp.example.com:4317 + otlphttp: + endpoint: https://otlp.example.com/otlp + +processors: + tail_sampling: + decision_wait: 10s + num_traces: 100 + expected_new_traces_per_sec: 10 + policies: + [ + { + name: test-policy-1, + type: always_sample + }, + ] + + probabilistic_sampler: + sampling_percentage: 100 + +service: + extensions: [ health_check, pprof ] + pipelines: + traces: + receivers: [ otlp ] + processors: [ probabilistic_sampler, tail_sampling ] + exporters: [ nop, otlp, otlphttp ] diff --git a/distributions/otelcol-sampling/postinstall.sh b/distributions/otelcol-sampling/postinstall.sh new file mode 100644 index 0000000..95889a2 --- /dev/null +++ b/distributions/otelcol-sampling/postinstall.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# Copyright The OpenTelemetry Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +if command -v systemctl >/dev/null 2>&1; then + systemctl enable otelcol-sampling.service + if [ -f /etc/otelcol-sampling/config.yaml ]; then + systemctl start otelcol-sampling.service + fi +fi diff --git a/distributions/otelcol-sampling/preinstall.sh b/distributions/otelcol-sampling/preinstall.sh new file mode 100644 index 0000000..a07a422 --- /dev/null +++ b/distributions/otelcol-sampling/preinstall.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +# Copyright The OpenTelemetry Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +getent passwd otelcol-sampling >/dev/null || useradd --system --user-group --no-create-home --shell /sbin/nologin otelcol-sampling diff --git a/distributions/otelcol-sampling/preremove.sh b/distributions/otelcol-sampling/preremove.sh new file mode 100644 index 0000000..36b806a --- /dev/null +++ b/distributions/otelcol-sampling/preremove.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# Copyright The OpenTelemetry Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +if command -v systemctl >/dev/null 2>&1; then + systemctl stop otelcol-sampling.service + systemctl disable otelcol-sampling.service +fi