Commit Graph

46 Commits

Author SHA1 Message Date
Dave Protasowski 44d1d7d978
Go1.19 changes (#2631)
* run goimports

* ignore linter errors for now

* fix boilerplate
2022-11-03 22:34:05 +00:00
Dave Protasowski ff956846a1
make METRICS_DOMAIN optional when backend is not OpenCensus (#2617) 2022-10-25 18:42:56 +00:00
Pierangelo Di Pilato a850b9e047
Use t.Setenv instead of os.Setenv in tests (#2454)
Go 1.17 introduced a new handy API for setting env vars scoped for
a single test so we can avoid the hard to read set and reset env
loops.

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
2022-03-10 10:00:48 -08:00
Julian Friedman 787aec59e7
Remove unused recorder field (#2358) 2021-11-23 05:51:50 -08:00
Dave Protasowski aff7376aba
drop stackdriver metrics and tracing exporters (#2183)
* drop stack driver as a tracing backend

* drop stackdriver as a metrics backend

* update deps - dropping stackdriver

* fix linting issues

* drop further references to stack driver

* drop serving & eventing metric key constants
these have been moved to their respective repos
see: https://github.com/knative/pkg/issues/608

* move source metrickeys to pkg/source

We're going to move the StatsReporter downstream eventually

related:
https://github.com/knative/eventing/pull/5587
https://github.com/knative/eventing/pull/5586

* fix linter
2021-07-14 11:45:31 -07:00
Stavros Kontopoulos 448ae657fb
Metric unit fixes (#2018)
* metric unit fixes

* additional fixes
2021-02-12 12:38:35 -08:00
Matt Moore 27db5ac24c
Add nostackdriver to metrics as well (#1975) 2020-12-23 18:48:04 -08:00
Stavros Kontopoulos c73d344c89
Add host config option to the prometheus exporter (#1882)
* add host to the prometheus exporter

* typo

* fix imports

* updates

* fixes

* more fixes

* typos

* respect the default

* fix comment

* use default

* nits
2020-11-04 11:38:04 -08:00
Markus Thömmes 22e4e0a702
Fix API stutter in metric option functions (#1837) 2020-10-23 09:37:37 -07:00
Victor Agababov 324e49bc7f
Some cleanups arounds the metrics code (#1834)
- use switch
- add new method that won't trigger lint, with a deprecation notice when deps are updated
- other minor things
2020-10-22 18:21:37 -07:00
Victor Agababov a371418524
v2 (#1754) 2020-09-29 13:18:29 -07:00
Markus Thömmes 754da4653a
Enable unparam linter to catch unused parameters (#1731) 2020-09-22 09:13:40 -07:00
Evan Anderson 8c2ebdb0e0
Speed up & deflake tests by disabling bundling (#1689)
* Speed up & deflake tests by disabling bundling

* Fix `go vet` and races detected

* Address @vagababov comments, add nil check
2020-09-18 16:34:45 -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
Victor Agababov 34838c4559
Remove all ClearAll calls from pkg UTs (#1654)
We need this in order to deprecate the function.
Serving is already free of those.
2020-08-27 13:13:07 -07:00
jjzeng-seattle bac0302109
Set reporting period for all meters (#1575)
* Set reporting period for all meters

* using switch statement to simplify

* Change 60 seconds to a minute

* Add a test case for openCencus customed reporting period
2020-08-04 15:06:28 -07:00
Evan Anderson b9a30ee123
Update config_test.go and metricstest to support multiple Meters. (#1421) 2020-06-18 10:50:25 -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
Antoine Cotten ffb929374a
Make Prometheus exporter port configurable via env (#1411) 2020-06-16 16:26:24 -07:00
Antoine Cotten 0d967ff0d8
Clean metrics config tests (#1412)
* Use constants in metrics config tests

* Normalize test cases indentation
2020-06-16 11:09:24 -07:00
Victor Agababov 1ceb875570
Fix \" escaping and other nits in the pkg (#1339) 2020-05-16 09:36:02 -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
cshou 62801f1d34 Allow to specify default exporter option when updating from ConfigMap (#1006)
* Allow to specify default exporter option when updating from ConfigMap

* renaming

* rename test
2020-01-22 15:34:23 -08:00
Matt Moore b8dc5fbc6d golang format tools (#990)
Produced via:
  `gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)`
  `goimports -w $(find -name '*.go' | grep -v vendor | grep -v third_party)`
/assign n3wscott
/cc n3wscott
2020-01-13 10:25:02 -08:00
Evan Anderson 8c11c24324 Add support for OpenCensus Agent as a destination for Knative metrics. (#978)
* Add support for OpenCensus Agent as a destination for Knative metrics.

* Update with comments from @mattmoor and @anniefu

* Remember to register exporter.

Fix tests.

* Fix naming per discussion with @anniefu
2020-01-10 18:42:58 -08:00
Matt Moore e96196e347 golang format tools (#876)
Produced via:
  `gofmt -s -w $(find -path './vendor' -prune -o -type f -name '*.go' -print))`
  `goimports -w $(find -name '*.go' | grep -v vendor)`
/assign n3wscott
2019-11-13 15:49:28 -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
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
Annie Fu 66c91bcfa6 Fix race condition when updating Stackdriver exporter (#769)
* Remove race condition between reading updates to config-observability
and updating stackdriver exporter

* Simply isNewExporterRequired if statement

* Remove unused thread-safe versions of functions

* Use a reader-writer lock & add function comment

* Make internal unlocked function names consistent
2019-10-18 13:48:19 -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
mattmoor-sockpuppet a07e7def0a golang format tools (#659)
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-09-11 07:12:29 -07:00
Ignacio Cano c56cedc7e7 Serializing/Deserializing Logging and Metrics configs (#656)
* 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

* comments after review

* removing the other constants
2019-09-10 12:36:29 -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
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
Matt Moore 35a6f90d16 Sprinkle more ClearAll around to enabled -count=N (#485) 2019-06-23 19:24:02 -07:00
Yanwei Guo 5323eaf18b Expose UpdateExporter function to accept map as parameter (#347)
* expose func

* use different metric name

* remove stackdriver change

* change comment

* return err
2019-03-29 16:38:54 -07: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 1aca435944 Read metrics backend from environment variable (#218)
* add env to set backend

* join two lines
2019-01-10 11:03:42 -08:00
Yanwei Guo 08febf8f13 Change Stackdriver resource type for metrics (#210)
* change resource type

* copied PR #188

* add unit tests

* change Fatal back to Error

* solve comments

* change to use map

* modify tests
2019-01-08 13:14:42 -08:00
jonjohnsonjr a8c40a9e3b Default metrics.backend-destination to Prometheus (#213)
Fixes #212
2019-01-08 09:54:43 -08:00
Mustafa Demirhan 53b1235c2a Use different reporting periods based on the metrics backend (#182)
* Use different reporting periods based on the metrics backend. Original implementation was setting this value to 1 min to accommodate the minimum allowed value for stackdriver, but that is a sub optimal behavior for Prometheus. The change also allows operator to override the default values.

* Fix the units of reconciler latency from nano seconds to milliseconds.

* Address PR comments.

* Add better logging for reconciliation.

* Remove unnecessary lock in the UT.

* Address PR comments.
2018-12-04 15:16:25 -08:00
akyyy 02b354e3a4 Relax the requirement for stackdriver project id for metrics exporter. (#147)
* fix flaky test

* relax the requirement for stackdriver project id

* improve log

* add comment for stackdriverProjectIDKey not provided case

* minor format

* simplify the map access
2018-10-30 16:20:34 -07:00
akyyy 10ceeb6163 Add stackdriver exporter support in pkg. (#126)
* update dep golang.org/x/net

* Add stackdriver exporter support in pkg

* fix race and tests

* Use thread safe newMetricsExporter in tests

* address cr comments

* minor fix

* checkpoint

* Address cr comments

* add test for UpdateExporterFromConfigMap

* Move lock position

* add a test case for stackdriver error check

* minor change

* removing one test case since it seems app default creds exists for presubmit tests

* replace promSrvChan with promSrv as cr suggsted

* use a local var server for ListenAndServe

* add getter and setter for shared variables

* add func isMetricsConfigChanged and test

* address cr comments

* Update opencensus-go-exporter-stackdriver to v0.7.0

* Revert "Update opencensus-go-exporter-stackdriver to v0.7.0"

This reverts commit 9825f641f8.

* run update-deps.sh

* merge conflict

* run update-deps.sh

* Update Gopkg.toml so it doesn't have stackdriver exporter

* remove regex for metrics domain at pkg repo per cr comments

* merge conflict
2018-10-24 15:23:31 -07:00