Skip to content

Commit

Permalink
[cmd/githubgen] add distribution reports (open-telemetry#29697)
Browse files Browse the repository at this point in the history
**Description:**
Adds a set of distribution reports that can be used to notify
distribution maintainers of any changes to distributions.

**Link to tracking Issue:**
Fixes open-telemetry#28628
  • Loading branch information
atoulme committed Dec 12, 2023
1 parent 95fe4ca commit 97764b9
Show file tree
Hide file tree
Showing 19 changed files with 843 additions and 4 deletions.
27 changes: 27 additions & 0 deletions .chloggen/add_distribution_owners.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: githubgen

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Adds a set of distribution reports that can be used to notify distribution maintainers of any changes to distributions.

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [28628]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
15 changes: 15 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,21 @@ testbed/ @open-telemetry/collect
testbed/mockdatareceivers/mockawsxrayreceiver/ @open-telemetry/collector-contrib-approvers @wangzlei @srprash
testbed/mockdatasenders/mockdatadogagentexporter/ @open-telemetry/collector-contrib-approvers @boostchicken

#####################################################
#
# List of distribution maintainers for OpenTelemetry Collector Contrib
#
#####################################################
reports/distributions/core.yaml @open-telemetry/collector-contrib-approvers
reports/distributions/contrib.yaml @open-telemetry/collector-contrib-approvers
reports/distributions/aws.yaml @open-telemetry/collector-contrib-approvers
reports/distributions/grafana.yaml @open-telemetry/collector-contrib-approvers
reports/distributions/observiq.yaml @open-telemetry/collector-contrib-approvers
reports/distributions/redhat.yaml @open-telemetry/collector-contrib-approvers
reports/distributions/splunk.yaml @open-telemetry/collector-contrib-approvers atoulme dmitryax hughesjj rfitzpatrick
reports/distributions/sumo.yaml @open-telemetry/collector-contrib-approvers
reports/distributions/liatrio.yaml @open-telemetry/collector-contrib-approvers


## UNMAINTAINED components

4 changes: 4 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ jobs:
run: |
make genoteltestbedcol
git diff -s --exit-code || (echo 'Generated code is out of date, please run "make genoteltestbedcol" and commit the changes in this PR.' && exit 1)
- name: Gen distributions
run: |
make gendistributions
git diff -s --exit-code || (echo 'Generated code is out of date, please run "make gendistributions" and commit the changes in this PR.' && exit 1)
- name: CodeGen
run: |
make -j2 generate
Expand Down
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,18 @@ mdatagen-test:
cd cmd/mdatagen && $(GOCMD) generate ./...
cd cmd/mdatagen && $(GOCMD) test ./...

.PHONY: gengithub
gengithub:
.PHONY: githubgen-install
githubgen-install:
cd cmd/githubgen && $(GOCMD) install .

.PHONY: gengithub
gengithub: githubgen-install
githubgen

.PHONY: gendistributions
gendistributions: githubgen-install
githubgen distributions

.PHONY: update-codeowners
update-codeowners: gengithub generate

Expand Down
2 changes: 1 addition & 1 deletion cmd/githubgen/allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ agoallikmaa
architjugran
asaharn
billmeyer
braydonk
emreyalvac
keep94
kiranmayib
Expand All @@ -22,3 +21,4 @@ am-kinetica
mcube8
sokoide
zdaratom
braydonk
19 changes: 19 additions & 0 deletions cmd/githubgen/codeowners.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ const codeownersHeader = `# Code generated by githubgen. DO NOT EDIT.
* @open-telemetry/collector-contrib-approvers
`

const distributionCodeownersHeader = `
#####################################################
#
# List of distribution maintainers for OpenTelemetry Collector Contrib
#
#####################################################
`

type codeownersGenerator struct {
}

Expand Down Expand Up @@ -140,6 +148,17 @@ LOOP:
}
}

codeowners += distributionCodeownersHeader
longestName := 0
for _, dist := range data.distributions {
if longestName < len(dist.Name) {
longestName = len(dist.Name)
}
}
for _, dist := range data.distributions {
codeowners += fmt.Sprintf("reports/distributions/%s.yaml%s @open-telemetry/collector-contrib-approvers %s\n", dist.Name, strings.Repeat(" ", longestName-len(dist.Name)), strings.Join(dist.Maintainers, " "))
}

err = os.WriteFile(filepath.Join(".github", "CODEOWNERS"), []byte(codeowners+unmaintainedCodeowners), 0600)
if err != nil {
return err
Expand Down
63 changes: 63 additions & 0 deletions cmd/githubgen/distributions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package main

import (
"fmt"
"os"
"path/filepath"
"sort"

"gopkg.in/yaml.v3"
)

type distributionsGenerator struct {
}

type distOutput struct {
Name string `yaml:"name"`
URL string `yaml:"url"`
Maintainers []string `yaml:"maintainers"`
Components map[string][]string `yaml:"components"`
}

func (cg distributionsGenerator) generate(data *githubData) error {
for _, dist := range data.distributions {
components := map[string][]string{}
for _, c := range data.components {
inDistro := false
for _, componentDistro := range c.Status.Distributions {
if dist.Name == componentDistro {
inDistro = true
break
}
}
if inDistro {
array, ok := components[c.Status.Class]
if !ok {
array = []string{}
}
components[c.Status.Class] = append(array, c.Type)
}
}
for _, comps := range components {
sort.Strings(comps)
}
output := distOutput{
Name: dist.Name,
URL: dist.URL,
Maintainers: dist.Maintainers,
Components: components,
}
b, err := yaml.Marshal(output)
if err != nil {
return nil
}
err = os.WriteFile(filepath.Join("reports", "distributions", fmt.Sprintf("%s.yaml", dist.Name)), b, 0600)
if err != nil {
return nil
}
}
return nil
}
2 changes: 1 addition & 1 deletion cmd/githubgen/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.20
require (
github.com/google/go-github/v53 v53.2.0
go.opentelemetry.io/collector/confmap v0.91.0
gopkg.in/yaml.v3 v3.0.1
)

require (
Expand All @@ -27,5 +28,4 @@ require (
golang.org/x/sys v0.14.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
23 changes: 23 additions & 0 deletions cmd/githubgen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import (
"fmt"
"io/fs"
"log"
"os"
"path/filepath"
"sort"

"go.opentelemetry.io/collector/confmap/provider/fileprovider"
"gopkg.in/yaml.v3"
)

const unmaintainedStatus = "unmaintained"
Expand All @@ -25,6 +27,7 @@ type generator interface {
// .github/CODEOWNERS
// .github/ALLOWLIST
// .github/ISSUE_TEMPLATES/*.yaml (list of components)
// reports/distributions/*
func main() {
folder := flag.String("folder", ".", "folder investigated for codeowners")
allowlistFilePath := flag.String("allowlist", "cmd/githubgen/allowlist.txt", "path to a file containing an allowlist of members outside the OpenTelemetry organization")
Expand All @@ -36,6 +39,8 @@ func main() {
generators = append(generators, issueTemplatesGenerator{})
case "codeowners":
generators = append(generators, codeownersGenerator{})
case "distributions":
generators = append(generators, distributionsGenerator{})
default:
panic(fmt.Sprintf("Unknown generator: %s", arg))
}
Expand Down Expand Up @@ -71,12 +76,19 @@ type metadata struct {
Status *Status `mapstructure:"status"`
}

type distributionData struct {
Name string `yaml:"name"`
URL string `yaml:"url"`
Maintainers []string `yaml:"maintainers,omitempty"`
}

type githubData struct {
folders []string
codeowners []string
allowlistFilePath string
maxLength int
components map[string]metadata
distributions []distributionData
}

func loadMetadata(filePath string) (metadata, error) {
Expand Down Expand Up @@ -147,12 +159,23 @@ func run(folder string, allowlistFilePath string, generators []generator) error
}
sort.Strings(codeownersList)

var distributions []distributionData
dd, err := os.ReadFile(filepath.Join(folder, "distributions.yaml"))
if err != nil {
return err
}
err = yaml.Unmarshal(dd, &distributions)
if err != nil {
return err
}

data := &githubData{
folders: foldersList,
codeowners: codeownersList,
allowlistFilePath: allowlistFilePath,
maxLength: maxLength,
components: components,
distributions: distributions,
}

for _, g := range generators {
Expand Down
27 changes: 27 additions & 0 deletions distributions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# A collection of distributions that can be referenced in the metadata.yaml files.
# The rules below apply to every distribution added to this list:
# - The distribution must be open source.
# - The link must point to a publicly accessible repository.
- name: core
url: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol
- name: contrib
url: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
- name: aws
url: https://github.com/aws-observability/aws-otel-collector
- name: grafana
url: https://github.com/grafana/agent
- name: observiq
url: https://github.com/observIQ/observiq-otel-collector
- name: redhat
url: https://github.com/os-observability/redhat-opentelemetry-collector
- name: splunk
url: https://github.com/signalfx/splunk-otel-collector
maintainers:
- atoulme
- dmitryax
- hughesjj
- rfitzpatrick
- name: sumo
url: https://github.com/SumoLogic/sumologic-otel-collector
- name: liatrio
url: https://github.com/liatrio/liatrio-otel-collector
46 changes: 46 additions & 0 deletions reports/distributions/aws.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: aws
url: https://github.com/aws-observability/aws-otel-collector
maintainers: []
components:
exporter:
- awsemf
- awsxray
- datadog
- dynatrace
- file
- kafka
- loadbalancing
- logzio
- prometheus
- prometheusremotewrite
- sapm
- signalfx
extension:
- awsproxy
- ecs_observer
- health_check
- pprof
- sigv4auth
processor:
- attributes
- cumulativetodelta
- deltatorate
- experimental_metricsgeneration
- filter
- groupbytrace
- k8sattributes
- metricstransform
- probabilistic_sampler
- resource
- resourcedetection
- span
- tail_sampling
receiver:
- awscontainerinsightreceiver
- awsecscontainermetrics
- awsxray
- jaeger
- kafka
- prometheus
- statsd
- zipkin
Loading

0 comments on commit 97764b9

Please sign in to comment.