Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Implement atomic operations for various metrics using Prometheus as the backend storage #773

Closed
wants to merge 12 commits into from

Conversation

gongna-au
Copy link
Contributor

What this PR does:

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


…he backend storage

- Implemented atomic operations for metrics like read/write counts, session counts, etc.
- Integrated Prometheus as the backend storage for these metrics.
- Note: Metrics are not yet instrumented for telemetry.
@cr-gpt
Copy link

cr-gpt bot commented Oct 5, 2023

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

This commit addresses the issue of failing tests caused by modifications to the BootOptions fields. The tests have been updated to align with the new structure, ensuring they pass as expected.
@cr-gpt
Copy link

cr-gpt bot commented Oct 5, 2023

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

@codecov-commenter
Copy link

codecov-commenter commented Oct 5, 2023

Codecov Report

Attention: 603 lines in your changes are missing coverage. Please review.

Comparison is base (ac511fe) 40.00% compared to head (1f1106d) 40.47%.
Report is 1 commits behind head on master.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #773      +/-   ##
==========================================
+ Coverage   40.00%   40.47%   +0.46%     
==========================================
  Files         265      278      +13     
  Lines       26711    27978    +1267     
==========================================
+ Hits        10686    11324     +638     
- Misses      14861    15481     +620     
- Partials     1164     1173       +9     
Files Coverage Δ
pkg/config/model.go 38.00% <ø> (+3.54%) ⬆️
pkg/metrics/stats/kebab_case_converter.go 100.00% <100.00%> (ø)
pkg/metrics/stats/prometheus/collectors.go 100.00% <100.00%> (ø)
pkg/metrics/stats/util.go 100.00% <100.00%> (ø)
pkg/metrics/stats/snake_case_converter.go 86.66% <86.66%> (ø)
pkg/metrics/stats/duration.go 92.00% <92.00%> (ø)
pkg/metrics/stats/prometheus/prometheus_backend.go 86.66% <86.66%> (ø)
pkg/metrics/stats/histogram.go 77.33% <77.33%> (ø)
pkg/metrics/stats/counter.go 49.09% <49.09%> (ø)
pkg/util/sync2/atomic.go 42.02% <42.02%> (ø)
... and 4 more

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cr-gpt
Copy link

cr-gpt bot commented Oct 5, 2023

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

@cr-gpt
Copy link

cr-gpt bot commented Oct 5, 2023

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

@cr-gpt
Copy link

cr-gpt bot commented Oct 5, 2023

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

@cr-gpt
Copy link

cr-gpt bot commented Oct 30, 2023

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

@sonarcloud
Copy link

sonarcloud bot commented Oct 30, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 12 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication


import (
"github.com/arana-db/arana/pkg/util/log"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import style

// Add adds the provided value to the Counter.
func (v *Counter) Add(delta int64) {
if delta < 0 {
log.Warn("[stats] Adding a negative value to a counter, %v should be a gauge instead", v)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log.Warnf

pushBackends[name] = backend

if emitPeriod <= 0 {
log.Warn("[stats] push backend got invalid emitPeriod: %v, use default emitPeriod instead: %v", emitPeriod, defaultEmitPeriod)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log.Warnf

}
err := backend.PushAll()
if err != nil {
log.Warn("Pushing stats to backend %v failed: %v", name, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log.Warnf

for range ticker.C {
backend, ok := pushBackends[name]
if !ok {
log.Fatal(fmt.Sprintf("No PushBackend registered with name %s", name))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没有必要用fmt.Sprintf

@gongna-au gongna-au closed this Nov 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants