Skip to content

Commit

Permalink
Initialize repo with delta-to-cumulative processor distribution
Browse files Browse the repository at this point in the history
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
  • Loading branch information
jpkrohling committed Apr 2, 2024
1 parent 0d58945 commit a89a5ae
Show file tree
Hide file tree
Showing 34 changed files with 1,045 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/base-goreleaser-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Reusable GoReleaser CI workflow

on:
workflow_call:
inputs:
distribution:
required: true
type: string

jobs:
check-goreleaser:
name: Check GoReleaser Configuration for ${{ inputs.distribution }}
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64,ppc64le

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.21

- uses: anchore/sbom-action/[email protected]

- name: Generate the sources
run: make generate-sources

- name: Run GoReleaser for ${{ inputs.distribution }}
uses: goreleaser/goreleaser-action@v5
with:
workdir: distributions/${{ inputs.distribution }}
version: latest
args: --snapshot --rm-dist --timeout 2h
54 changes: 54 additions & 0 deletions .github/workflows/base-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Reusable release workflow

on:
workflow_call:
inputs:
distribution:
required: true
type: string

jobs:
release:
name: Release ${{ inputs.distribution }}
environment: release
runs-on: ubuntu-22.04

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64,ppc64le

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.21

- uses: anchore/sbom-action/[email protected]

- name: Generate distribution sources
run: make generate-sources

- name: Login to GitHub Package Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
version: latest
workdir: distributions/${{ inputs.distribution }}
args: release --clean --timeout 2h
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15 changes: 15 additions & 0 deletions .github/workflows/ci-loadbalancing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Continuous Integration - load-balancing

on:
workflow_run:
workflows: [Continuous Integration]
types:
- completed

jobs:
release:
name: Continuous Integration - loadbalancing - GoReleaser
uses: ./.github/workflows/base-goreleaser-ci.yaml
with:
distribution: loadbalancing
secrets: inherit
15 changes: 15 additions & 0 deletions .github/workflows/ci-sidecar.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Continuous Integration - sidecar

on:
workflow_run:
workflows: [Continuous Integration]
types:
- completed

jobs:
release:
name: Continuous Integration - sidecar - GoReleaser
uses: ./.github/workflows/base-goreleaser-ci.yaml
with:
distribution: sidecar
secrets: inherit
15 changes: 15 additions & 0 deletions .github/workflows/ci-tracing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Continuous Integration - tracing

on:
workflow_run:
workflows: [Continuous Integration]
types:
- completed

jobs:
release:
name: Continuous Integration - sidecar - GoReleaser
uses: ./.github/workflows/base-goreleaser-ci.yaml
with:
distribution: tracing
secrets: inherit
25 changes: 25 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Continuous Integration

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
name: Build
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.21

- name: Verify
run: make ci
14 changes: 14 additions & 0 deletions .github/workflows/release-loadbalancing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Release loadbalancing

on:
release:
types: [published]

jobs:
release:
name: Release loadbalancing
uses: ./.github/workflows/base-release.yaml
with:
distribution: loadbalancing
secrets: inherit
permissions: write-all
14 changes: 14 additions & 0 deletions .github/workflows/release-sidecar.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Release sidecar

on:
release:
types: [published]

jobs:
release:
name: Release sidecar
uses: ./.github/workflows/base-release.yaml
with:
distribution: sidecar
secrets: inherit
permissions: write-all
14 changes: 14 additions & 0 deletions .github/workflows/release-tracing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Release tracing

on:
release:
types: [published]

jobs:
release:
name: Release tracing
uses: ./.github/workflows/base-release.yaml
with:
distribution: tracing
secrets: inherit
permissions: write-all
52 changes: 52 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
GO ?= go

OTELCOL_BUILDER_VERSION ?= 0.97.0
OTELCOL_BUILDER_DIR ?= ${HOME}/bin
OTELCOL_BUILDER ?= ${OTELCOL_BUILDER_DIR}/ocb

DISTRIBUTIONS ?= $(shell echo $(notdir $(wildcard ./distributions/*)) | tr " " ",") # outputs comma separated directories names

ci: check build
check: test

build: go ocb
@./scripts/build.sh -d "${DISTRIBUTIONS}" -b ${OTELCOL_BUILDER} -g ${GO}

test: build
@./test/test-all.sh -d "${DISTRIBUTIONS}"

generate: generate-sources generate-goreleaser

generate-goreleaser: go
@./scripts/generate-goreleaser.sh -d "${DISTRIBUTIONS}" -g ${GO}

generate-sources: go ocb
@./scripts/build.sh -d "${DISTRIBUTIONS}" -s true -b ${OTELCOL_BUILDER} -g ${GO}

.PHONY: ocb
ocb:
ifeq (, $(shell command -v ocb 2>/dev/null))
@{ \
[ ! -x '$(OTELCOL_BUILDER)' ] || exit 0; \
set -e ;\
os=$$(uname | tr A-Z a-z) ;\
machine=$$(uname -m) ;\
[ "$${machine}" != x86 ] || machine=386 ;\
[ "$${machine}" != x86_64 ] || machine=amd64 ;\
echo "Installing ocb ($${os}/$${machine}) at $(OTELCOL_BUILDER_DIR)";\
mkdir -p $(OTELCOL_BUILDER_DIR) ;\
curl -sLo $(OTELCOL_BUILDER) "https://github.com/open-telemetry/opentelemetry-collector/releases/download/cmd%2Fbuilder%2Fv$(OTELCOL_BUILDER_VERSION)/ocb_$(OTELCOL_BUILDER_VERSION)_$${os}_$${machine}" ;\
chmod +x $(OTELCOL_BUILDER) ;\
}
else
OTELCOL_BUILDER=$(shell command -v ocb)
endif

.PHONY: go
go:
@{ \
if ! command -v '$(GO)' >/dev/null 2>/dev/null; then \
echo >&2 '$(GO) command not found. Please install golang. https://go.dev/doc/install'; \
exit 1; \
fi \
}
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# OpenTelemetry Collector distributions by jpkrohling

This repository has a personal collection of OpenTelemetry Collector distributions curated by [@jpkrohling](https://github.com/jpkrohling).

At every new version of the Collector, distributions are updated and published.

## Adding a new distribution

To add a new distribution to this repository:

1) create a directory under `distributions` and place the `manifest.yaml` there
2) add `./github/workflows/ci-<distribution>.yaml` and `./github/workflows/release-<distribution>.yaml` files based on one of the existing distributions

You can test your new distribution with:

```console
./test/test.sh -d YOUR_DISTRIBUTION
```

Or, to run everything the CI would run:

```console
make ci
```
10 changes: 10 additions & 0 deletions distributions/delta-to-cumulative/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM alpine:latest

ARG USER_UID=10001
USER ${USER_UID}

COPY delta-to-cumulative /delta-to-cumulative
COPY otelcol.yaml /etc/delta-to-cumulative/config.yaml
ENTRYPOINT ["/delta-to-cumulative"]
CMD ["--config", "/etc/delta-to-cumulative/config.yaml"]
EXPOSE 4317
5 changes: 5 additions & 0 deletions distributions/delta-to-cumulative/delta-to-cumulative.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Systemd environment file for the delta-to-cumulative service

# Command-line options for the delta-to-cumulative service.
# Run `/usr/bin/delta-to-cumulative --help` to see all available options.
OTELCOL_OPTIONS="--config=/etc/delta-to-cumulative/config.yaml"
15 changes: 15 additions & 0 deletions distributions/delta-to-cumulative/delta-to-cumulative.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=Delta to cummulative distribution of the OpenTelemetry Collector
After=network.target

[Service]
EnvironmentFile=/etc/delta-to-cumulative/delta-to-cumulative.conf
ExecStart=/usr/bin/delta-to-cumulative $OTELCOL_OPTIONS
KillMode=mixed
Restart=on-failure
Type=simple
User=delta-to-cumulative
Group=delta-to-cumulative

[Install]
WantedBy=multi-user.target
16 changes: 16 additions & 0 deletions distributions/delta-to-cumulative/manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
dist:
module: github.com/grafana/opentelemetry-collector-components/delta-to-cumulative
name: otelcol
description: Delta to cumulative distribution of the OpenTelemetry Collector
version: 0.97.0
output_path: ./_build
otelcol_version: 0.97.0

extensions:
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension v0.97.0
receivers:
- gomod: go.opentelemetry.io/collector/receiver/otlpreceiver v0.97.0
exporters:
- gomod: go.opentelemetry.io/collector/exporter/otlpexporter v0.97.0
processors:
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor v0.97.0
25 changes: 25 additions & 0 deletions distributions/delta-to-cumulative/otelcol-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
extensions:
health_check:

receivers:
otlp:
protocols:
grpc:

processors:
deltatocumulative:

exporters:
otlp:
endpoint: example.com:4317

service:
extensions: [health_check]
pipelines:
metrics:
receivers:
- otlp
processors:
- deltatocumulative
exporters:
- otlp
25 changes: 25 additions & 0 deletions distributions/delta-to-cumulative/otelcol.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
extensions:
health_check:

receivers:
otlp:
protocols:
grpc:

processors:
deltatocumulative:

exporters:
otlp:
endpoint: example.com:4317

service:
extensions: [health_check]
pipelines:
metrics:
receivers:
- otlp
processors:
- deltatocumulative
exporters:
- otlp
Loading

0 comments on commit a89a5ae

Please sign in to comment.