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

Issue #88 Adding Host Label to all metrics #89

Merged
merged 3 commits into from
Mar 1, 2023

Conversation

ankittiwari-harness
Copy link
Contributor

Added Changes for #88.

This change makes sense as the Host Label is crucial to identify similar metrics across multiple services with same running endpoints

@codecov
Copy link

codecov bot commented Mar 1, 2023

Codecov Report

Patch coverage: 90.90% and project coverage change: -1.00 ⚠️

Comparison is base (5f12f87) 59.79% compared to head (bdd4529) 58.79%.

❗ Current head bdd4529 differs from pull request most recent head ad31a48. Consider uploading reports for the commit ad31a48 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #89      +/-   ##
==========================================
- Coverage   59.79%   58.79%   -1.00%     
==========================================
  Files           8        8              
  Lines         679      682       +3     
==========================================
- Hits          406      401       -5     
- Misses        252      258       +6     
- Partials       21       23       +2     
Impacted Files Coverage Δ
jaegertracing/jaegertracing.go 56.12% <66.66%> (ø)
prometheus/prometheus.go 49.15% <100.00%> (-2.78%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@aldas aldas left a comment

Choose a reason for hiding this comment

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

Could you tweak this testcase to look for host also

assert.Regexp(t, "request_duration_seconds.*le=\"0.005\"", rec.Body.String(), "duration should have time bucket (like, 0.005s)")
assert.NotRegexp(t, "request_duration_seconds.*le=\"512000\"", rec.Body.String(), "duration should NOT have a size bucket (like, 512K)")
assert.Regexp(t, "response_size_bytes.*le=\"512000\"", rec.Body.String(), "response size should have a 512K (size) bucket")
assert.NotRegexp(t, "response_size_bytes.*le=\"0.005\"", rec.Body.String(), "response size should NOT have time bucket (like, 0.005s)")
assert.Regexp(t, "request_size_bytes.*le=\"512000\"", rec.Body.String(), "request size should have a 512K (size) bucket")
assert.NotRegexp(t, "request_size_bytes.*le=\"0.005\"", rec.Body.String(), "request should NOT have time bucket (like, 0.005s)")

@ankittiwari-harness
Copy link
Contributor Author

Could you tweak this testcase to look for host also

assert.Regexp(t, "request_duration_seconds.*le=\"0.005\"", rec.Body.String(), "duration should have time bucket (like, 0.005s)")
assert.NotRegexp(t, "request_duration_seconds.*le=\"512000\"", rec.Body.String(), "duration should NOT have a size bucket (like, 512K)")
assert.Regexp(t, "response_size_bytes.*le=\"512000\"", rec.Body.String(), "response size should have a 512K (size) bucket")
assert.NotRegexp(t, "response_size_bytes.*le=\"0.005\"", rec.Body.String(), "response size should NOT have time bucket (like, 0.005s)")
assert.Regexp(t, "request_size_bytes.*le=\"512000\"", rec.Body.String(), "request size should have a 512K (size) bucket")
assert.NotRegexp(t, "request_size_bytes.*le=\"0.005\"", rec.Body.String(), "request should NOT have time bucket (like, 0.005s)")

Done

@aldas
Copy link
Contributor

aldas commented Mar 1, 2023

I think assert.Contains(t, rec.Body.String(), `host="example.com"`, "host must be present") is little bit too broad.

Before this PR we had lines like this in response body

echo_request_duration_seconds_bucket{code="404",method="GET",url="/ping",le="0.005"} 1

With this PR we have:

echo_request_duration_seconds_bucket{code="404",host="example.com",method="GET",url="/ping",le="0.005"} 1

it would be better if we change these regexps to ordinary contains checks like that:

	body := rec.Body.String()
	assert.Contains(t, body, `echo_request_duration_seconds_bucket{code="404",host="example.com",method="GET",url="/ping",le="0.005"}`)

@ankittiwari-harness
Copy link
Contributor Author

I think assert.Contains(t, rec.Body.String(), `host="example.com"`, "host must be present") is little bit too broad.

Before this PR we had lines like this in response body

echo_request_duration_seconds_bucket{code="404",method="GET",url="/ping",le="0.005"} 1

With this PR we have:

echo_request_duration_seconds_bucket{code="404",host="example.com",method="GET",url="/ping",le="0.005"} 1

it would be better if we change these regexps to ordinary contains checks like that:

	body := rec.Body.String()
	assert.Contains(t, body, `echo_request_duration_seconds_bucket{code="404",host="example.com",method="GET",url="/ping",le="0.005"}`)

@aldas Changed the checks to use contains/notContains instead of regex

Copy link
Contributor

@aldas aldas left a comment

Choose a reason for hiding this comment

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

LGTM

@ankittiwari-harness
Copy link
Contributor Author

LGTM

perfect. Request you to merge it and release update package as and when planned

@aldas aldas merged commit 5bb0f68 into labstack:master Mar 1, 2023
@ankittiwari-harness ankittiwari-harness deleted the feature/add-host-label branch March 1, 2023 11:05
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.

None yet

2 participants