Commit Graph

23 Commits

Author SHA1 Message Date
Victor Agababov a371418524
v2 (#1754) 2020-09-29 13:18:29 -07:00
Zbynek Roubalik 2d4efecc6b
bump to k8s 1.18 (#1428)
* bump to k8s 1.18.8

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>

* plumbing ctx through

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>

* add more ctx plumbing

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>

* ctx WithCancel()

Signed-off-by: Zbynek Roubalik <zroubali@redhat.com>
2020-09-11 07:54:00 -07:00
Markus Thömmes cb729b8ae6
Assorted linting fixes. (#1507)
- Remove unused code.
- Remove unnecessary conversion.
- Prevent copies of structs that contain sync.Mutex.
2020-07-16 05:59:33 -07:00
Evan Anderson e7bd895fbd
Introduce `pkg/metrics` support for multiple Resources (#1392)
* Update OpenCensus to include #1196.

* Extend OpenCensus to track per-Resource stats.

* Add generic ResourceView mechanics, part 1. TODO: wire newFactory, tests

* Move factory creation to where it can be customized per-backend

* Integrate opencensus export with Resource-based exporters

* Add stackdriver support for resource views

* address feedbacks

* add test cases

* make KnativeRevision a map

* Update go modules to point to latest opencensus which includes `view.Meter`.

* Add support for Resources to Prometheus Exporter.

This involved copying/improving much of the contrib prometheus exporter.

* add resource_view tests and fix minor issues

* add recorder tests for meter

* Update resource_view_test with an e2e export test.

* Fix prometheus e2e resource_view_test.

Found a fun circular lock.

Found a fun double-registration in metricproducer/Meter.

Found some unnecessary extra code.

Fixed prometheus string sanitization.

Removed a layer of Prometheus wrapping which made debugging more challenging.

* Add test for standard view exports and non-resourced views to e2e test.

* Add UnregisterResourceView to fix tests

* Add OpenCensus e2e resource export test.

Still a little flaky, so work around that with "<=".

* Fix tests for OpenCensus export.

* Fix flakiness / timing issues in OpenCensus exporter e2e test.

* Update to latest ocagent to fix `Resources` bug.

* Don't swallow errors from stackdriver init.

* Get Stackdriver export mostly working in e2e tests

Tests still fail because stackdriver converts custom metrics to a namespaced format and seems to lose Resource information.

* Add support for Stackdriver resource export.

* ./hack/update-codegen.sh

* Fix data race with graceful shutdown.

* Fix issues noticed by @vagababov

* Address mattmoor-bot comments.

* Remove MonitoredResource and apply suggestions from yanweiguo

* More cleanup to stackdriver_exporter_test.go

* Update tests (particularly config_test.go) for Stackdriver recorder changes which sometimes record with additional resources.

* Avoid setting two `view.WithRecorder` options on record

* Add stackdriver tests

* Address comments

* Switch Prometheus port due to possible conflict in test env

* Fix missing :=

* FIx data races around *view.Data shared across Meters.

Cleanup resource_view_test.

* Remove unneeded monitored_resources.go

* Use sync.WaitGroup to avoid data races on closing channel.

* Sort the map for ResourceAsString

* Apply lint and vagababov changes.

* Fix typos

* refactor ResourceAsString

* Update stackdriver exporter version

* Update metrics/resource_view_test.go

Remove accidental paste

* Fix go.sum

* Address yanweiguo comments on comments

* Fix autogen/go mod

* Handling resource extraction when custom metrics are allowed

* Add tests for AllowCustomMetrics set to true

* Address vagababov and yanweiguo comments.

Signed-off-by: Evan Anderson <evan.k.anderson@gmail.com>

* address comments

* Renaming

* Reduce some condition nesting

* go fmt

* Sleep for 1ms to allow metrics being sent (#9)

* Address yanweiguo comments

Co-authored-by: JJ Zeng <jjzeng@google.com>
Co-authored-by: jjzeng-seattle <56568376+jjzeng-seattle@users.noreply.github.com>
2020-07-14 10:46:19 -07:00
Victor Agababov 34c17cc2d5
Make things private that should be so (#1417)
* Make things private that should be so

Make some constants and enums private.
The ones I found to be used elsewhere, I kept public.

* sort
2020-06-17 09:26:24 -07:00
Annie Fu 099343d49e
Make updating metrics config and metrics exporter atomic (#1271)
* Make updating metricsConfig and updating metricsExporter atomic

This requires doing anything with a kubeclient before obtaining the
metricsMux lock.

* Address PR
2020-05-01 15:35:42 -07:00
Yanwei Guo 94a34e416c Upgrade OpenCensus Stackdriver exporter (#865)
* upgrade

* change unit tests

* upgrade os sd again

* change unit tests

* add comment

* add comment

* address comments
2019-12-03 14:12:37 -08:00
Ignacio (Nacho) Cano 93838817ef Eventing StackDriver internal metrics (#846)
* marking the metrics as internal as we need to pre-process them to include
pod_name and container_name...

* removing eventSource

* updates

* rollbacking changes to source

* updating changes to source

* minimizing change

* minimizing change
2019-11-06 10:38:03 -08:00
Yanwei Guo 7d0779c71d Add fake functions for GCP metadata and Stackdriver back (#850)
* add fack back

* rename
2019-11-05 15:51:02 -08:00
Evan Anderson a9bdd123b7 Start moving Stackdriver and Prometheus-specific code to a strategy pattern (#812)
* Start moving Stackdriver and Prometheus-specific code to a strategy pattern.

* Respond to review feedback, add test.

* gofmt
2019-11-04 16:05:21 -08:00
Annie Fu 4d39b058e2 Restrict metric pkg Stackdriver Secret to controlled name & namespace (#824)
* Restrict Stackdriver Secret to controlled name & namespace

* Address PR comments

* Lock when reading secret name & namespace

* Export StackdriverClientConfig struct so consumers don't have to
redefine it

* Ensure metrics pkg consumers call SetStackdriverSecretLocation to set
Secret name and namespace

* Export StackdriverClientConfig consts & helper function

* Add TODO for secret watcher
2019-11-04 11:57:19 -08:00
Annie Fu f684a1078a Add field to metrics config for configuring Stackdriver exporter client (#794)
* Add field to metrics config for configuring Stackdriver exporter client
options

* Fix test setting global state and interfering with other tests

* Use correct GCP metadata values & cleanup

* Some code cleanup

* Remove as much test-specific function stubbing as possible

* Remove more stubbed out test code

* Make more descriptive error when getting secret

* Use former locking pattern to avoid deadlock

There is a cyclical dependency between the metrics pkg and client-go
kubeclient where the kubeclient will attempt to read the metricsConfig
to record metrics about kubeclient requests. This prevents using a kubeclient within the metricsMux lock.
2019-10-25 10:28:36 -07:00
Yanwei Guo 4befa47ec5 Change built-in metrics to use internal ones for activator and revision (#795)
* metrics/

* fix tests
2019-10-23 22:19:36 -07:00
Ignacio Cano 6b1c5cf09a StackDriver CustomMetrics with Custom Domain Prefix (#676)
* renaming source_name and source_resource_group to name and resource_group,
as they will be used in other resources

* updating

* updates based on code review

* update

* fix
2019-09-13 15:50:35 -07:00
Ignacio Cano 1633d4dded renaming source_name and source_resource_group to name and resource_group, (#675)
as they will be used in other resources
2019-09-13 14:03:35 -07:00
Ignacio Cano 62d3aa64b5 Renaming Importer to Source (#662)
* source stats reporter... should be used by well-behaved sources

* public fields

* moving serialization/deserialization of metrics and logging maps to pkg

* nits

* adding UT

* same order

* updates

* sock-puppet

* unregistration problem?

* removing base64 encoding

* removing TODO

* removing config changes... done in another PR

* to properly address the comment

* changing importer to source
2019-09-11 13:16:31 -07:00
Ignacio Cano ec2f20ae67 Eventing Stackdriver integration (#612)
* adding eventing metrics, and tried to split separable things to ease
future refactors.

* updates

* updates after code review
2019-08-30 09:13:49 -07:00
mattmoor-sockpuppet 1864f499dc golang format tools (#497)
Produced via:
  `gofmt -s -w $(find -path './vendor' -prune -o -type f -name '*.go' -print))`
  `goimports -w $(find -name '*.go' | grep -v vendor)`
/assign @mattmoor
2019-06-27 07:37:08 -07:00
Matt Moore 222dd25986 Migrate pkg to use the knative.dev/pkg import path (#489)
* Manual changes.

* scripted changes.
2019-06-26 13:02:06 -07:00
Mustafa Demirhan 3c8c4a9354 Add support to flush the metrics exporter (#391)
* Add support to flush the metrics exporter.

* Updates to the comments.
2019-04-18 20:12:27 -07:00
Yanwei Guo 2b411285d2 Use a fake exporter in unit tests (#311)
* add fake exporter

* change comment
2019-03-07 16:12:41 -08:00
Yanwei Guo b4a3bde045 Decide whether to record metrics according to current metrics config (#292)
* split and update

* bug fixed

* change the copyright year

* use fake metadata in tests

* exclude test coverage for gcp_metadata

* add record

* add tests

* revert 2019 and add a new var

* change documents

* address comment

* change line
2019-03-07 10:26:42 -08:00
Yanwei Guo 1494b24d7f Update OpenCensus Stackdriver exporter version (#280)
* split and update

* bug fixed

* change the copyright year

* use fake metadata in tests

* exclude test coverage for gcp_metadata

* revert 2019 change on existing files
2019-02-20 14:18:46 -08:00