Skip to content

Commit

Permalink
[dev] Vendor modules and add patch file for StatsD Receiver (#2221)
Browse files Browse the repository at this point in the history
* go mod vendor

* Apply changes to workflows to apply patches

* Add statd feature gate patch

* Don't link check vendor docs

* Ignore vendor dir for linters

* Ignore shell scripts in vendor

* increase timeout for golangcilint
  • Loading branch information
bryan-aguilar authored Jul 27, 2023
1 parent af553ea commit 9468cd0
Show file tree
Hide file tree
Showing 13,498 changed files with 4,096,283 additions and 5 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 4 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: apply patches
run: make apply-patches

# Set up building environment, patch the dev repo code on dispatch events.
- name: Set up Go 1.x
uses: actions/setup-go@v4
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/PR-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- name: Get changed files
id: changes
run: |
echo "MDS=$(git diff --name-only --diff-filter=ACMRTUXB $(git merge-base origin/${{ github.event.pull_request.base.ref }} ${{ github.event.pull_request.head.sha }}) ${{ github.event.pull_request.head.sha }} | grep .md$ | xargs)" >> $GITHUB_ENV
echo "MDS=$(git diff --name-only --diff-filter=ACMRTUXB $(git merge-base origin/${{ github.event.pull_request.base.ref }} ${{ github.event.pull_request.head.sha }}) ${{ github.event.pull_request.head.sha }} | grep .md$ | grep -v vendor/ | xargs)" >> $GITHUB_ENV
- name: Install markdown-link-check
run: npm install -g markdown-link-check
Expand Down Expand Up @@ -104,6 +104,11 @@ jobs:
- name: Checkout
if: ${{ needs.changes.outputs.changed == 'true' }}
uses: actions/checkout@v3

- name: apply patches
if: ${{ needs.changes.outputs.changed == 'true' }}
run: make apply-patches

# Set up building environment, patch the dev repo code on dispatch events.
- name: Set up Go 1.x
if: ${{ needs.changes.outputs.changed == 'true' }}
Expand Down Expand Up @@ -133,6 +138,10 @@ jobs:
if: ${{ needs.changes.outputs.changed == 'true' }}
uses: actions/checkout@v3

- name: apply patches
if: ${{ needs.changes.outputs.changed == 'true' }}
run: make apply-patches

# Set up building environment, patch the dev repo code on dispatch events.
- name: Set up Go 1.x
if: ${{ needs.changes.outputs.changed == 'true' }}
Expand Down
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@ ALL_SRC := $(shell find . -name '*.go' \
-not -path './bin/*' \
-not -path './build/*' \
-not -path './tools/workflow/linters/*' \
-not -path './vendor/*' \
-type f | sort)

# ALL_MODULES includes ./* dirs (excludes . dir)
ALL_MODULES := $(shell find . -type f -name "go.mod" -exec dirname {} \; | sort | egrep '^./' )

ALL_SHELL_SCRIPTS := $(shell find . -type f -name "*.sh" )
ALL_SHELL_SCRIPTS := $(shell find . -type f -name "*.sh" -not -path './vendor/*' )
SHELLCHECK_OPTS := "-e SC1071"

BUILD_INFO_IMPORT_PATH=$(AOC_IMPORT_PATH)/tools/version

GOBUILD=GO111MODULE=on CGO_ENABLED=0 installsuffix=cgo go build -trimpath
GOBUILD=GO111MODULE=on CGO_ENABLED=0 GOPROXY=off installsuffix=cgo go build -trimpath

# Use linker flags to provide version/build settings
LDFLAGS=-ldflags "-s -w -X $(BUILD_INFO_IMPORT_PATH).GitHash=$(GIT_SHA) \
Expand All @@ -50,7 +51,9 @@ $(GOMODULES):
.PHONY: for-all-target
for-all-target: $(GOMODULES)


PATCHES := $(shell find ./patches -name *.patch)
apply-patches: $(PATCHES)
$(foreach patch,$(PATCHES), patch --posix --forward -p1 < $(patch))

all-modules:
@echo $(ALL_MODULES) | tr ' ' '\n' | sort
Expand Down
2 changes: 1 addition & 1 deletion Makefile.Common
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fmt:

.PHONY: lint
lint:
$(TOOL_BIN)/$(LINT) run --timeout 5m --enable gosec
$(TOOL_BIN)/$(LINT) run --timeout 10m --enable gosec

.PHONY: mod-tidy
mod-tidy:
Expand Down
84 changes: 84 additions & 0 deletions patches/statsDfeatGateInstrumentationScope.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
commit 2effc76f12019edc9689388204ab9faab63ff8f4
Author: Bryan Aguilar <[email protected]>
Date: Tue Jul 25 17:33:22 2023 -0700

Add feature gate for instrumentation scope in statsd receiver

diff --git a/vendor/github.com/open-telemetry/opentelemetry-collector-contrib/receiver/statsdreceiver/protocol/statsd_parser.go b/vendor/github.com/open-telemetry/opentelemetry-collector-contrib/receiver/statsdreceiver/protocol/statsd_parser.go
index 1cfec5cf..699d6ee7 100644
--- a/vendor/github.com/open-telemetry/opentelemetry-collector-contrib/receiver/statsdreceiver/protocol/statsd_parser.go
+++ b/vendor/github.com/open-telemetry/opentelemetry-collector-contrib/receiver/statsdreceiver/protocol/statsd_parser.go
@@ -14,6 +14,7 @@ import (
"github.com/lightstep/go-expohisto/structure"
"go.opentelemetry.io/collector/client"
"go.opentelemetry.io/collector/component"
+ "go.opentelemetry.io/collector/featuregate"
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/pmetric"
"go.opentelemetry.io/otel/attribute"
@@ -30,6 +31,13 @@ type (
ObserverType string // How the server will aggregate histogram and timings ("gauge", "summary")
)

+var instNameFeatGate = featuregate.GlobalRegistry().MustRegister("aws.statsd.populateInstrumentationScope",
+ featuregate.StageAlpha,
+ featuregate.WithRegisterFromVersion("v0.82.0"),
+ featuregate.WithRegisterDescription("populates instrumentation scope library name on StatsD receiver "+
+ "metric data points"),
+)
+
const (
tagMetricType = "metric_type"

@@ -194,21 +202,35 @@ func (p *StatsDParser) GetMetrics() []BatchMetrics {
}
rm := batch.Metrics.ResourceMetrics().AppendEmpty()
for _, metric := range instrument.gauges {
- p.copyMetricAndScope(rm, metric)
+ if instNameFeatGate.IsEnabled() {
+ p.copyMetricAndScope(rm, metric)
+ } else {
+ metric.CopyTo(rm.ScopeMetrics().AppendEmpty())
+ }
}

for _, metric := range instrument.timersAndDistributions {
- p.copyMetricAndScope(rm, metric)
+ if instNameFeatGate.IsEnabled() {
+ p.copyMetricAndScope(rm, metric)
+ } else {
+ metric.CopyTo(rm.ScopeMetrics().AppendEmpty())
+ }
}

for _, metric := range instrument.counters {
setTimestampsForCounterMetric(metric, p.lastIntervalTime, now)
- p.copyMetricAndScope(rm, metric)
+ if instNameFeatGate.IsEnabled() {
+ p.copyMetricAndScope(rm, metric)
+ } else {
+ metric.CopyTo(rm.ScopeMetrics().AppendEmpty())
+ }
}

for desc, summaryMetric := range instrument.summaries {
ilm := rm.ScopeMetrics().AppendEmpty()
- p.setVersionAndNameScope(ilm.Scope())
+ if instNameFeatGate.IsEnabled() {
+ p.setVersionAndNameScope(ilm.Scope())
+ }

buildSummaryMetric(
desc,
@@ -222,8 +244,10 @@ func (p *StatsDParser) GetMetrics() []BatchMetrics {

for desc, histogramMetric := range instrument.histograms {
ilm := rm.ScopeMetrics().AppendEmpty()
- p.setVersionAndNameScope(ilm.Scope())
+ if instNameFeatGate.IsEnabled() {
+ p.setVersionAndNameScope(ilm.Scope())

+ }
buildHistogramMetric(
desc,
histogramMetric,
202 changes: 202 additions & 0 deletions vendor/cloud.google.com/go/compute/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions vendor/cloud.google.com/go/compute/internal/version.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9468cd0

Please sign in to comment.