Skip to content

Commit 0a0d449

Browse files
gizasvigneshshanmugamkaiyan-sheng
authored
[Ratelimit Processor] Instrument the ratelimiter service with telemetry metrics (#562)
* first effort to instrument Signed-off-by: Andreas Gkizas <[email protected]> * adding initial implementation for metrics provider in ratelimiter Signed-off-by: Andreas Gkizas <[email protected]> * updating test to read projectid from metadata Signed-off-by: Andreas Gkizas <[email protected]> * license update Signed-off-by: Andreas Gkizas <[email protected]> * update with correct attributes as fucntions Signed-off-by: Andreas Gkizas <[email protected]> * changing Meter namespace Signed-off-by: Andreas Gkizas <[email protected]> * make goproto Signed-off-by: Andreas Gkizas <[email protected]> * run with metadata Signed-off-by: Andreas Gkizas <[email protected]> * run with metadata and remove unneeded funcsions Signed-off-by: Andreas Gkizas <[email protected]> * make go generate Signed-off-by: Andreas Gkizas <[email protected]> * make lint Signed-off-by: Andreas Gkizas <[email protected]> * adding err for projectID Signed-off-by: Andreas Gkizas <[email protected]> * license update Signed-off-by: Andreas Gkizas <[email protected]> * remove files Signed-off-by: Andreas Gkizas <[email protected]> * fixing tests Signed-off-by: Andreas Gkizas <[email protected]> * make fmt Signed-off-by: Andreas Gkizas <[email protected]> * make default projectID empty Signed-off-by: Andreas Gkizas <[email protected]> * make gogenerate Signed-off-by: Andreas Gkizas <[email protected]> * make gogenerate Signed-off-by: Andreas Gkizas <[email protected]> * Update processor/ratelimitprocessor/gubernator.go Co-authored-by: Vignesh Shanmugam <[email protected]> * abstract the metadata function and use WithErrorReason Signed-off-by: Andreas Gkizas <[email protected]> * Update processor/ratelimitprocessor/gubernator.go Co-authored-by: kaiyan-sheng <[email protected]> * Update processor/ratelimitprocessor/gubernator.go Co-authored-by: kaiyan-sheng <[email protected]> * moving to common function and changed labels Signed-off-by: Andreas Gkizas <[email protected]> * adding to local and also duraton metric Signed-off-by: Andreas Gkizas <[email protected]> * fix reason values and rerun make generate * Add limit_threshold and throttle_behavior attrs * run make license-update * add test for limit threshold * fix CodeGen and error message * downgrade mdatagen to v0.124.0 to avoid missing import in generated file * change mdatagen to v0.123.0 * remove project_id attr * return errTooManyRequests when throttling * Add goimports to fix the generated files * add go install for goimports * remove processor_id and reason field * remove reason field when throttled in local.go * fix errors Signed-off-by: Andreas Gkizas <[email protected]> * fix errors Signed-off-by: Andreas Gkizas <[email protected]> * fix errors Signed-off-by: Andreas Gkizas <[email protected]> * fix test * move `metadata.NewTelemetryBuilder` to factory.go * fix tests * fix local_test.go * remove attributes * generate new documentation.md * adding test with AssertEqualRatelimitRequests Signed-off-by: Andreas Gkizas <[email protected]> * add comment for the goimports workaround --------- Signed-off-by: Andreas Gkizas <[email protected]> Co-authored-by: Vignesh Shanmugam <[email protected]> Co-authored-by: kaiyan-sheng <[email protected]>
1 parent a2d4b06 commit 0a0d449

File tree

33 files changed

+743
-48
lines changed

33 files changed

+743
-48
lines changed

.github/workflows/checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ jobs:
162162
run: |
163163
make -j2 gogenerate && make -j2 license-update
164164
if [[ -n $(git status -s) ]]; then
165-
echo 'Generated code is out of date, please run "make generate" and commit the changes in this PR.'
165+
echo 'Generated code is out of date, please run "make gogenerate && make license-update" and commit the changes in this PR.'
166166
exit 1
167167
fi
168168
unittest-matrix:

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ gotidy:
6565

6666
.PHONY: gogenerate
6767
gogenerate:
68+
# This is a workaround for a bug in mdatagen upstream: https://github.com/open-telemetry/opentelemetry-collector/issues/13069
69+
@command -v goimports >/dev/null 2>&1 || $(MAKE) -B install-tools
6870
@$(MAKE) $(FOR_GROUP_TARGET) TARGET="generate"
6971
@$(MAKE) $(FOR_GROUP_TARGET) TARGET="fmt"
7072

Makefile.Common

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ lint: $(LINT) misspell
7575
.PHONY: generate
7676
generate: $(MDATAGEN)
7777
$(GOCMD) generate ./...
78+
goimports -w ./
7879

7980
.PHONY: moddownload
8081
moddownload:

connector/elasticapmconnector/generated_package_test.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extension/apmconfigextension/generated_package_test.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extension/beatsauthextension/generated_package_test.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extension/configintegrationextension/generated_package_test.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extension/fileintegrationextension/generated_package_test.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/tools/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ require (
1111
go.opentelemetry.io/build-tools/multimod v0.22.0
1212
go.opentelemetry.io/collector/cmd/builder v0.125.0
1313
go.opentelemetry.io/collector/cmd/mdatagen v0.125.0
14+
golang.org/x/tools v0.31.0
1415
golang.org/x/vuln v1.1.4
1516
)
1617

@@ -236,7 +237,6 @@ require (
236237
golang.org/x/sys v0.32.0 // indirect
237238
golang.org/x/telemetry v0.0.0-20240522233618-39ace7a40ae7 // indirect
238239
golang.org/x/text v0.24.0 // indirect
239-
golang.org/x/tools v0.31.0 // indirect
240240
google.golang.org/genproto/googleapis/rpc v0.0.0-20250219182151-9fdb1cabc7b2 // indirect
241241
google.golang.org/grpc v1.72.0 // indirect
242242
google.golang.org/protobuf v1.36.6 // indirect

internal/tools/tools.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ import (
3333
_ "go.opentelemetry.io/build-tools/multimod"
3434
_ "go.opentelemetry.io/collector/cmd/builder"
3535
_ "go.opentelemetry.io/collector/cmd/mdatagen"
36+
_ "golang.org/x/tools/cmd/goimports"
3637
_ "golang.org/x/vuln/cmd/govulncheck"
3738
)

0 commit comments

Comments
 (0)