Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
77 changes: 77 additions & 0 deletions backup_otel_collector_patches.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SRC_COLLECTOR="${ROOT_DIR}/opentelemetry-collector"
DEST_DIR="${ROOT_DIR}/opentelemetry-collector-patch"

copy_path() {
local src="$1"
local dest="$2"

if [[ -d "${src}" ]]; then
rm -rf "${dest}"
mkdir -p "$(dirname "${dest}")"
cp -R "${src}" "${dest}"
echo "Copied directory: ${dest}"
elif [[ -f "${src}" ]]; then
mkdir -p "$(dirname "${dest}")"
cp "${src}" "${dest}"
echo "Copied file: ${dest}"
else
echo "Skipping ${src} (not found)"
fi
}

ensure_git_repo() {
local repo_dir="$1"

if [[ ! -d "${repo_dir}" ]]; then
echo "Source repo not found at ${repo_dir}" >&2
exit 1
fi

# Pass safe.directory inline to avoid global git config issues.
if ! git -C "${repo_dir}" -c safe.directory="${repo_dir}" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "Directory ${repo_dir}" \
" is not a git repository (did you check out the collector source?)" >&2
exit 1
fi
}

backup_repo() {
local repo_dir="$1"
local dest_dir="$2"

ensure_git_repo "${repo_dir}"

mapfile -t CHANGED < <(git -C "${repo_dir}" -c safe.directory="${repo_dir}" status --porcelain)

if [[ ${#CHANGED[@]} -eq 0 ]]; then
echo "No modified files detected in ${repo_dir}"
return
fi

for entry in "${CHANGED[@]}"; do
local status="${entry:0:2}"
local path="${entry:3}"

# Skip deletions; we only copy modified/added/renamed paths.
if [[ "${status}" =~ ^D ]]; then
continue
fi

# Handle renamed paths from git status output.
if [[ "${path}" == *" -> "* ]]; then
path="${path##* -> }"
fi

local src_path="${repo_dir}/${path}"
local dest_path="${dest_dir}/${path}"
copy_path "${src_path}" "${dest_path}"
done

echo "Copied ${#CHANGED[@]} changed paths into ${dest_dir}"
}

backup_repo "${SRC_COLLECTOR}" "${DEST_DIR}"
1 change: 1 addition & 0 deletions backup_otel_patches.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

"${ROOT_DIR}/backup_otel_collector_contrib_patches.sh" "$@"
"${ROOT_DIR}/backup_otel_collector_patches.sh" "$@"
"${ROOT_DIR}/backup_otel_client_patches.sh" "$@"
"${ROOT_DIR}/backup_otel_proto_patches.sh" "$@"
1 change: 1 addition & 0 deletions opentelemetry-collector
Submodule opentelemetry-collector added at b2aeb6
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
go.sum
go.mod
*.go
ddsketchcol
10 changes: 10 additions & 0 deletions opentelemetry-collector-contrib-patch/cmd/ddsketchcol/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Build:
```bash
cd DataCollector/opentelemetry-collector-contrib
builder --config ./cmd/ddsketchcol/builder-config.yaml
```

Run:
```bash
./ddsketchcol --config config.yaml
```

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions opentelemetry-collector-contrib-patch/cmd/ddsketchcol/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
receivers:
otlp:
protocols:
grpc:
http:

processors:
ddsketch:

exporters:
debug:
verbosity: detailed

service:
pipelines:
metrics:
receivers: [otlp]
processors: [ddsketch]
exporters: [debug]

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
telemetrygen
105 changes: 105 additions & 0 deletions opentelemetry-collector-patch/Makefile.Common
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
SHELL = /bin/bash
# ALL_PKGS is the list of all packages where ALL_SRC files reside.
ALL_PKGS := $(sort $(shell go list ./...))
# COVER_PKGS is the list of packages to include in the coverage
COVER_PKGS := $(shell go list ./... | tr "\n" ",")

CURR_MOD := $(shell go list -m | tr '/' '-' )

GOCMD?= go
GOOS := $(shell $(GOCMD) env GOOS)
GOARCH := $(shell $(GOCMD) env GOARCH)
GOTEST_TIMEOUT?=240s
# -race is not supported on windows arm64
GOTEST_OPT?= -timeout $(GOTEST_TIMEOUT) $(if $(and $(filter windows,$(GOOS)), $(filter arm64,$(GOARCH))),, -race)
GOFMT := $(shell $(GOCMD) env GOROOT)/bin/gofmt

# SRC_ROOT is the top of the source tree.
SRC_ROOT := $(shell git rev-parse --show-toplevel)

TOOLS_MOD_DIR := $(SRC_ROOT)/internal/tools
TOOLS_MOD_FILE := $(TOOLS_MOD_DIR)/go.mod
GO_TOOL := $(GOCMD) tool -modfile $(TOOLS_MOD_FILE)
CHLOGGEN_CONFIG := .chloggen/config.yaml
# no trailing slash
JUNIT_OUT_DIR ?= $(TOOLS_MOD_DIR)/testresults

.PHONY: test
test:
$(GO_TOOL) gotestsum --packages="./..." -- $(GOTEST_OPT)

.PHONY: test-with-cover
test-with-cover:
mkdir -p $(PWD)/coverage/unit
$(GO_TOOL) gotestsum \
--packages="./..." -- \
$(GOTEST_OPT) -cover -covermode=atomic -coverpkg $(COVER_PKGS) -args -test.gocoverdir="$(PWD)/coverage/unit"

.PHONY: test-with-junit
test-with-junit:
mkdir -p $(JUNIT_OUT_DIR)
$(GO_TOOL) gotestsum \
--packages="./..." --junitfile $(JUNIT_OUT_DIR)/$(CURR_MOD)-junit.xml -- \
$(GOTEST_OPT) ./...

.PHONY: benchmark
benchmark:
MEMBENCH=yes $(GO_TOOL) gotestsum \
--packages="$(ALL_PKGS)" -- \
-bench=. -run=notests ./... | tee benchmark.txt

.PHONY: fmt
fmt: common/gofmt common/goimports common/gofumpt

# `modernize' cannot be installed as a Go tool via `go get -tool'.
#
# See [1] for more details.
#
# [1]: https://github.com/golang/go/issues/73279
.PHONY: modernize
modernize:
$(GOCMD) run \
golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest \
-fix -test -v ./...

.PHONY: tidy
tidy:
rm -fr go.sum
$(GOCMD) mod tidy -compat=1.24.0

.PHONY: lint
lint:
$(GO_TOOL) golangci-lint run

.PHONY: common/gofmt
common/gofmt:
$(GOFMT) -w -s ./

.PHONY: common/goimports
common/goimports:
$(GO_TOOL) goimports -w -local go.opentelemetry.io/collector ./

.PHONY: common/gofumpt
common/gofumpt:
$(GO_TOOL) gofumpt -l -w -extra .

.PHONY: vulncheck
vulncheck:
$(GO_TOOL) govulncheck ./...

.PHONY: generate
generate:
$(GOCMD) generate ./...

.PHONY: impi
impi:
$(GO_TOOL) impi \
--local go.opentelemetry.io/collector \
--scheme stdThirdPartyLocal ./...

.PHONY: moddownload
moddownload:
$(GOCMD) mod download

timebenchmark:
go test -bench=. -benchtime=1s ./...
Loading