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

feat: add subscribed message metrics instrumentations #2080

Merged
merged 5 commits into from
Oct 27, 2023

Conversation

Xunzhuo
Copy link
Member

@Xunzhuo Xunzhuo commented Oct 26, 2023

After: #1982
Part of: #700

image

refer: #2089

@Xunzhuo Xunzhuo requested a review from a team as a code owner October 26, 2023 08:06
@codecov
Copy link

codecov bot commented Oct 26, 2023

Codecov Report

Merging #2080 (3316827) into main (131178b) will decrease coverage by 0.02%.
The diff coverage is 44.11%.

@@            Coverage Diff             @@
##             main    #2080      +/-   ##
==========================================
- Coverage   64.42%   64.40%   -0.02%     
==========================================
  Files         109      109              
  Lines       15049    15094      +45     
==========================================
+ Hits         9695     9721      +26     
- Misses       4752     4770      +18     
- Partials      602      603       +1     
Files Coverage Δ
internal/xds/translator/runner/runner.go 69.81% <100.00%> (+0.58%) ⬆️
internal/gatewayapi/runner/runner.go 20.80% <25.00%> (-0.34%) ⬇️
internal/message/watchutil.go 88.57% <84.00%> (-11.43%) ⬇️
internal/xds/server/runner/runner.go 28.18% <0.00%> (-0.53%) ⬇️
internal/provider/kubernetes/controller.go 51.92% <30.30%> (-0.40%) ⬇️

... and 1 file with indirect coverage changes

@zirain
Copy link
Contributor

zirain commented Oct 26, 2023

I think you can add a simple e2e test for prometheus

package main

import (
	"fmt"
	"io"
	"log"
	"net/http"
	"strings"
	"time"

	"github.com/prometheus/common/expfmt"
)

func main() {
	_, body, err := HTTPGet(fmt.Sprintf("http://127.0.0.1:%d/stats/prometheus", 9901))
	if err != nil {
		fmt.Println("get metric error: %v", err)
		return
	}
	reader := strings.NewReader(body)
	_, err = (&expfmt.TextParser{}).TextToMetricFamilies(reader)
	if err != nil {
		fmt.Println("parse metric error: %v body: %s", err, body)
	}
}

func HTTPGet(url string) (code int, respBody string, err error) {
	log.Println("HTTP GET", url)
	client := &http.Client{Timeout: time.Minute}
	resp, err := client.Get(url)
	if err != nil {
		log.Println(err)
		return 0, "", err
	}
	defer resp.Body.Close()
	body, err := io.ReadAll(resp.Body)
	if err != nil {
		log.Println(err)
		return 0, "", err
	}
	respBody = string(body)
	code = resp.StatusCode
	return code, respBody, nil
}

@Xunzhuo Xunzhuo force-pushed the add-subcribed-message-metrics branch from 05a49b2 to 6b2d605 Compare October 26, 2023 08:29
@Xunzhuo
Copy link
Member Author

Xunzhuo commented Oct 26, 2023

@zirain Can you help with it in a sparate PR?

) {
errChans := make(chan error, 10)
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason for use 10 for buffer size?

Copy link
Member Author

Choose a reason for hiding this comment

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

We need some buffers to make sure the errChan will not be stuck when observing errors from snapshot.Updates. As for the size, I am not sure about it, a suggested value from chatgpt.

Copy link
Contributor

Choose a reason for hiding this comment

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

can you add some comments for it, or a TODO: find a suitable value for this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@arkodg
Copy link
Contributor

arkodg commented Oct 26, 2023

@Xunzhuo are we following metric naming conventions similar to EnvoyProxy ?

internal/message/metrics.go Outdated Show resolved Hide resolved
@arkodg
Copy link
Contributor

arkodg commented Oct 27, 2023

hey @Xunzhuo, ive made some suggestions for now mainly around naming, prefer- watchable_subscribed_duration_seconds{resource="provider-resources", runner="gateway-api"}

would also like to replace subscribed with something else, but can't think of anything rn

Signed-off-by: bitliu <bitliu@tencent.com>
Signed-off-by: bitliu <bitliu@tencent.com>
@Xunzhuo Xunzhuo force-pushed the add-subcribed-message-metrics branch from 3876fd2 to d6bf031 Compare October 27, 2023 06:38
internal/message/metrics.go Outdated Show resolved Hide resolved
Signed-off-by: bitliu <bitliu@tencent.com>
Signed-off-by: bitliu <bitliu@tencent.com>
@arkodg
Copy link
Contributor

arkodg commented Oct 27, 2023

thanks @Xunzhuo, hey @zirain can you ptal

@zirain
Copy link
Contributor

zirain commented Oct 27, 2023

can udpate an image of the latest output?

Signed-off-by: bitliu <bitliu@tencent.com>
@Xunzhuo
Copy link
Member Author

Xunzhuo commented Oct 27, 2023

@zirain updated the pic in PR desc.

@Xunzhuo Xunzhuo requested review from zirain and arkodg October 27, 2023 07:52
@qicz qicz merged commit 845e874 into envoyproxy:main Oct 27, 2023
17 of 18 checks passed
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.

4 participants