Skip to content

Commit fb510a9

Browse files
authored
Moved from github.com/observatorium/opentelemetry-collector-builder (open-telemetry#3)
Signed-off-by: Juraci Paixão Kröhling <[email protected]>
1 parent 3c1dd9e commit fb510a9

27 files changed

+1609
-2
lines changed

.github/mergify.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
pull_request_rules:
2+
- name: remove outdated reviews
3+
conditions:
4+
- base=master
5+
actions:
6+
dismiss_reviews: {}
7+
8+
- name: Automatic merge when all checks pass and the PR is approved
9+
conditions:
10+
- "#approved-reviews-by>=1"
11+
- "-draft"
12+
- "status-success=Unit tests"
13+
- "status-success=Code standards (linting)"
14+
- "status-success=Security"
15+
- "status-success=Integration test"
16+
actions:
17+
merge:
18+
method: squash
19+
commit_message: title+body

.github/workflows/go.yaml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: "Continuous Integration"
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
unit-tests:
11+
name: Unit tests
12+
runs-on: ubuntu-20.04
13+
steps:
14+
15+
- name: Set up Go
16+
uses: actions/setup-go@v2
17+
with:
18+
go-version: 1.14
19+
20+
- name: Check out code into the Go module directory
21+
uses: actions/checkout@v2
22+
23+
- name: Test
24+
run: go test -v ./...
25+
26+
lint:
27+
name: Code standards (linting)
28+
runs-on: ubuntu-20.04
29+
steps:
30+
- name: Check out code into the Go module directory
31+
uses: actions/checkout@v2
32+
33+
- name: Lint
34+
uses: golangci/golangci-lint-action@v2
35+
with:
36+
version: v1.29
37+
args: --enable=gosec,maligned,misspell
38+
only-new-issues: true
39+
40+
security:
41+
name: Security
42+
runs-on: ubuntu-20.04
43+
steps:
44+
- name: Check out code into the Go module directory
45+
uses: actions/checkout@v2
46+
47+
- name: Initialize CodeQL
48+
uses: github/codeql-action/init@v1
49+
with:
50+
languages: go
51+
52+
- name: Autobuild
53+
uses: github/codeql-action/autobuild@v1
54+
55+
- name: Perform CodeQL Analysis
56+
uses: github/codeql-action/analyze@v1
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Integration tests
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
integration-test:
11+
name: Integration test
12+
runs-on: ubuntu-20.04
13+
steps:
14+
15+
- name: Set up Go
16+
uses: actions/setup-go@v2
17+
with:
18+
go-version: 1.14
19+
20+
- name: Check out code into the Go module directory
21+
uses: actions/checkout@v2
22+
23+
- name: Test
24+
run: ./test/test.sh

.github/workflows/release.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: goreleaser
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
goreleaser:
10+
runs-on: ubuntu-20.04
11+
steps:
12+
-
13+
name: Checkout
14+
uses: actions/checkout@v2
15+
with:
16+
fetch-depth: 0
17+
-
18+
name: Set up Go
19+
uses: actions/setup-go@v2
20+
with:
21+
go-version: 1.14
22+
-
23+
name: Run GoReleaser
24+
uses: goreleaser/goreleaser-action@v2
25+
with:
26+
version: latest
27+
args: release --rm-dist
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
# Created by https://www.toptal.com/developers/gitignore/api/go,vscode
3+
# Edit at https://www.toptal.com/developers/gitignore?templates=go,vscode
4+
5+
### Go ###
6+
# Binaries for programs and plugins
7+
*.exe
8+
*.exe~
9+
*.dll
10+
*.so
11+
*.dylib
12+
13+
# Test binary, built with `go test -c`
14+
*.test
15+
16+
# Output of the go coverage tool, specifically when used with LiteIDE
17+
*.out
18+
19+
# Dependency directories (remove the comment below to include it)
20+
# vendor/
21+
22+
### Go Patch ###
23+
/vendor/
24+
/Godeps/
25+
26+
### vscode ###
27+
.vscode/*
28+
!.vscode/settings.json
29+
!.vscode/tasks.json
30+
!.vscode/launch.json
31+
!.vscode/extensions.json
32+
*.code-workspace
33+
34+
# End of https://www.toptal.com/developers/gitignore/api/go,vscode
35+
36+
/dist/
37+
opentelemetry-collector-builder

.golangci.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# all available settings of specific linters
2+
linters-settings:
3+
goheader:
4+
template-path: header.txt
5+
goimports:
6+
local-prefixes: github.com/open-telemetry/opentelemetry-collector-builder
7+
maligned:
8+
suggest-new: true
9+
misspell:
10+
locale: US
11+
12+
linters:
13+
enable:
14+
- goheader
15+
- goimports
16+
- maligned
17+
- misspell
18+
- gosec

.goreleaser.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
before:
2+
hooks:
3+
- go mod download
4+
builds:
5+
- flags:
6+
- -trimpath
7+
ldflags:
8+
- -s -w -X github.com/open-telemetry/opentelemetry-collector-builder/cmd.version={{.Version}} -X github.com/open-telemetry/opentelemetry-collector-builder/cmd.date={{.Date}}
9+
env:
10+
- CGO_ENABLED=0
11+
goos:
12+
- linux
13+
- windows
14+
- darwin
15+
goarch:
16+
- amd64
17+
- arm
18+
- arm64
19+
goarm:
20+
- 6
21+
- 7
22+
archives:
23+
- format: binary
24+
checksum:
25+
name_template: "checksums.txt"
26+
snapshot:
27+
name_template: "{{ .Tag }}-next"
28+
changelog:
29+
sort: asc
30+
filters:
31+
exclude:
32+
- "^docs:"
33+
- "^test:"

LICENSE

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
Apache License
23
Version 2.0, January 2004
34
http://www.apache.org/licenses/

README.md

+87-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,87 @@
1-
# opentelemetry-collector-builder
2-
OpenTelemetry Collector Builder
1+
# OpenTelemetry Collector builder
2+
3+
This program generates a custom OpenTelemetry Collector binary based on a given configuration.
4+
5+
## TL;DR
6+
```console
7+
$ go get github.com/open-telemetry/opentelemetry-collector-builder
8+
$ cat > ~/.otelcol-builder.yaml <<EOF
9+
exporters:
10+
- gomod: "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter v0.19.0"
11+
EOF
12+
$ opentelemetry-collector-builder --output-path=/tmp/dist
13+
$ cat > /tmp/otelcol.yaml <<EOF
14+
receivers:
15+
otlp:
16+
protocols:
17+
grpc:
18+
endpoint: localhost:4317
19+
20+
processors:
21+
batch:
22+
23+
exporters:
24+
logging:
25+
26+
service:
27+
pipelines:
28+
traces:
29+
receivers:
30+
- otlp
31+
processors:
32+
- batch
33+
exporters:
34+
- logging
35+
EOF
36+
$ /tmp/dist/otelcol-custom --config=/tmp/otelcol.yaml
37+
```
38+
39+
## Installation
40+
41+
Download the binary for your respective platform under the ["Releases"](https://github.com/open-telemetry/opentelemetry-collector-builder/releases/latest) page.
42+
43+
## Running
44+
45+
A configuration file isn't strictly required, but the final artifact won't be different than a regular OpenTelemetry Collector. You probably want to specify at least one module (extension, exporter, receiver, processor) to add to your distribution. You can specify them via a configuration file. When no `--config` flag is provided with the location for the configuration file, `${HOME}/.otelcol-builder.yaml` will be used, if available.
46+
47+
```console
48+
$ opentelemetry-collector-builder --config config.yaml
49+
```
50+
51+
Use `opentelemetry-collector-builder --help` to learn about which flags are available.
52+
53+
## Configuration
54+
55+
The configuration file is composed of two main parts: `dist` and module types. All `dist` options can be specified via command line flags:
56+
57+
```console
58+
$ opentelemetry-collector-builder --name="my-otelcol"
59+
```
60+
61+
The module types are specified at the top-level, and might be: `extensions`, `exporters`, `receivers` and `processors`. They all accept a list of components, and each component is required to have at least the `gomod` entry. When not specified, the `import` value is inferred from the `gomod`. When not specified, the `name` is inferred from the `import`.
62+
63+
The `import` might specify a more specific path than what is specified in the `gomod`. For instance, your Go module might be `gitlab.com/myorg/myrepo` and the `import` might be `gitlab.com/myorg/myrepo/myexporter`.
64+
65+
The `name` will typically be omitted, except when multiple components have the same name. In such case, set a unique name for each module.
66+
67+
Optionally, a list of `go mod` replace entries can be provided, in case custom overrides are needed. This is typically necessary when a processor or some of its transitive dependencies have dependency problems.
68+
69+
```yaml
70+
dist:
71+
module: github.com/open-telemetry/opentelemetry-collector-builder # the module name for the new distribution, following Go mod conventions. Optional, but recommended.
72+
name: otelcol-custom # the binary name. Optional.
73+
description: "Custom OpenTelemetry Collector distribution" # a long name for the application. Optional.
74+
include_core: true # whether the core components should be included in the distribution. Optional.
75+
otelcol_version: "0.19.0" # the OpenTelemetry Collector version to use as base for the distribution. Optional.
76+
output_path: /tmp/otelcol-distributionNNN # the path to write the output (sources and binary). Optional.
77+
version: "1.0.0" # the version for your custom OpenTelemetry Collector. Optional.
78+
go: "/usr/bin/go" # which Go binary to use to compile the generated sources. Optional.
79+
exporters:
80+
- gomod: "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter v0.19.0" # the Go module for the component. Required.
81+
import: "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter" # the import path for the component. Optional.
82+
name: "alibabacloudlogserviceexporter" # package name to use in the generated sources. Optional.
83+
path: "./alibabacloudlogserviceexporter" # in case a local version should be used for the module, the path relative to the current dir, or a full path can be specified. Optional.
84+
replaces:
85+
# a list of "replaces" directives that will be part of the resulting go.mod
86+
- github.com/open-telemetry/opentelemetry-collector-contrib/internal/common => github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.19.0
87+
```

RELEASE.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Releasing the OpenTelemetry Collector Builder
2+
3+
This project uses [`goreleaser`](https://github.com/goreleaser/goreleaser) to manage the release of new versions.
4+
5+
To release a new version, simply add a tag named `vX.Y.Z`, like:
6+
7+
```
8+
git tag -a v0.1.1 -m "Release v0.1.1"
9+
git push upstream v0.1.1
10+
```
11+
12+
A new GitHub workflow should be started, and at the end, a GitHub release should have been created, similar with the ["Release v0.1.0"](https://github.com/open-telemetry/opentelemetry-collector-builder/releases/tag/v0.1.0).

0 commit comments

Comments
 (0)