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

otelhttp: set unit on all instruments #4500

Merged
merged 7 commits into from Nov 4, 2023

Conversation

ash2k
Copy link
Contributor

@ash2k ash2k commented Oct 31, 2023

Currently the histogram metric doesn't have units specified. It's good to have them explicitly specified.

The recorded value is actually milliseconds, not microseconds:

// Use floating point division here for higher precision (instead of Millisecond method).
elapsedTime := float64(time.Since(requestStartTime)) / float64(time.Millisecond)
h.valueRecorders[ServerLatency].Record(ctx, elapsedTime, o)

@ash2k ash2k requested review from Aneurysm9, dmathieu and a team as code owners October 31, 2023 11:20
@codecov
Copy link

codecov bot commented Oct 31, 2023

Codecov Report

Merging #4500 (ea1784d) into main (badf346) will increase coverage by 0.0%.
The diff coverage is 100.0%.

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #4500   +/-   ##
=====================================
  Coverage   80.9%   80.9%           
=====================================
  Files        150     150           
  Lines      10292   10304   +12     
=====================================
+ Hits        8327    8339   +12     
  Misses      1825    1825           
  Partials     140     140           
Files Coverage Δ
instrumentation/net/http/otelhttp/common.go 100.0% <ø> (ø)
instrumentation/net/http/otelhttp/handler.go 87.7% <100.0%> (+0.7%) ⬆️

@pellared
Copy link
Member

pellared commented Oct 31, 2023

Can you set units for all of the metric instruments?
How about also adding description?
Reference: https://github.com/open-telemetry/opentelemetry-specification/blob/v1.17.0/specification/metrics/semantic_conventions/http-metrics.md

@ash2k
Copy link
Contributor Author

ash2k commented Oct 31, 2023

@pellared Done. I think the spec and what is actually implemented is not the same thing because the spec talks about compressed payload but the implementation measures uncompressed data read/written by the app. This is probably fine, but perhaps the spec needs to be augmented with metrics for uncompressed data. Also, some description language in the spec seem to be not written grammatically correct (from what I can tell, not a native speaker).

@ash2k
Copy link
Contributor Author

ash2k commented Nov 1, 2023

Side note/question: it's really weird that maps are used when just normal fields could be. What is the reason? Map lookup involves computing the hash of the string key, etc and is definitely more work for the CPU vs just a pointer dereference.

@ash2k ash2k changed the title otelhttp: set unit on the server latency histogram otelhttp: set unit on all instruments Nov 1, 2023
CHANGELOG.md Outdated Show resolved Hide resolved
@pellared
Copy link
Member

pellared commented Nov 2, 2023

Side note/question: it's really weird that maps are used when just normal fields could be. What is the reason? Map lookup involves computing the hash of the string key, etc and is definitely more work for the CPU vs just a pointer dereference.

Yeah, I saw this as well and I agree 👍 I created #4502

@pellared
Copy link
Member

pellared commented Nov 2, 2023

@pellared Done.

Thank you ❤️

I think the spec and what is actually implemented is not the same thing because the spec talks about compressed payload but the implementation measures uncompressed data read/written by the app. This is probably fine, but perhaps the spec needs to be augmented with metrics for uncompressed data. Also, some description language in the spec seem to be not written grammatically correct (from what I can tell, not a native speaker).

I think the current main version is a lot better: https://github.com/open-telemetry/semantic-conventions/blob/main/docs/http/http-metrics.md. Thank you for all the remarks 👍

instrumentation/net/http/otelhttp/handler.go Outdated Show resolved Hide resolved
instrumentation/net/http/otelhttp/handler.go Outdated Show resolved Hide resolved
instrumentation/net/http/otelhttp/handler.go Outdated Show resolved Hide resolved
ash2k and others added 3 commits November 3, 2023 15:07
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
@pellared pellared merged commit a31f843 into open-telemetry:main Nov 4, 2023
22 checks passed
@ash2k ash2k deleted the add-http-latency-unit branch November 4, 2023 22:57
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

4 participants