Skip to content

Refactor prometheus exporter to slightly improve performance#3351

Merged
MrAlias merged 1 commit into
open-telemetry:mainfrom
dashpole:refactor_prom
Oct 20, 2022
Merged

Refactor prometheus exporter to slightly improve performance#3351
MrAlias merged 1 commit into
open-telemetry:mainfrom
dashpole:refactor_prom

Conversation

@dashpole
Copy link
Copy Markdown
Collaborator

Depends on #3342

This removes the intermediary metricData struct for storing metrics, and instead directly constructs them and places them in the channel.

Before:

goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/exporters/prometheus
cpu: Intel(R) Xeon(R) CPU @ 2.20GHz
BenchmarkCollect1-16        	   34020	     36013 ns/op	   34377 B/op	      37 allocs/op
BenchmarkCollect10-16       	   17280	     71593 ns/op	   43729 B/op	     223 allocs/op
BenchmarkCollect100-16      	    3484	    315440 ns/op	  141521 B/op	    2049 allocs/op
BenchmarkCollect1000-16     	     403	   3019380 ns/op	 1178601 B/op	   20133 allocs/op
BenchmarkCollect10000-16    	      37	  31071324 ns/op	11247557 B/op	  200570 allocs/op
PASS
ok  	go.opentelemetry.io/otel/exporters/prometheus	7.537s

After:

goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/exporters/prometheus
cpu: Intel(R) Xeon(R) CPU @ 2.20GHz
BenchmarkCollect1-16        	   35424	     33992 ns/op	   34265 B/op	      34 allocs/op
BenchmarkCollect10-16       	   20886	     57156 ns/op	   42440 B/op	     198 allocs/op
BenchmarkCollect100-16      	    3814	    315079 ns/op	  129088 B/op	    1841 allocs/op
BenchmarkCollect1000-16     	     506	   2380297 ns/op	 1049404 B/op	   18121 allocs/op
BenchmarkCollect10000-16    	      45	  23002387 ns/op	 9850371 B/op	  180552 allocs/op
PASS
ok  	go.opentelemetry.io/otel/exporters/prometheus	7.234s

@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 17, 2022

Codecov Report

Attention: Patch coverage is 41.17647% with 20 lines in your changes missing coverage. Please review.

Project coverage is 77.9%. Comparing base (587437b) to head (15ab000).
Report is 1864 commits behind head on main.

Files with missing lines Patch % Lines
exporters/prometheus/exporter.go 41.1% 17 Missing and 3 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #3351     +/-   ##
=======================================
- Coverage   78.0%   77.9%   -0.1%     
=======================================
  Files        164     164             
  Lines      11363   11323     -40     
=======================================
- Hits        8865    8826     -39     
+ Misses      2301    2299      -2     
- Partials     197     198      +1     
Files with missing lines Coverage Δ
exporters/prometheus/exporter.go 81.1% <41.1%> (-3.0%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dashpole dashpole added pkg:exporter:prometheus Related to the Prometheus exporter package enhancement New feature or request Skip Changelog PRs that do not require a CHANGELOG.md entry labels Oct 18, 2022
@dashpole
Copy link
Copy Markdown
Collaborator Author

This is tough to rebase. I'll wait until after #3352 as well

@dashpole
Copy link
Copy Markdown
Collaborator Author

rebased now

Copy link
Copy Markdown
Contributor

@MrAlias MrAlias left a comment

Choose a reason for hiding this comment

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

🎉

@MrAlias MrAlias merged commit 1133977 into open-telemetry:main Oct 20, 2022
@MrAlias MrAlias added this to the Metric v0.34.0 milestone Oct 27, 2022
@MrAlias MrAlias added the area:metrics Part of OpenTelemetry Metrics label Jun 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:metrics Part of OpenTelemetry Metrics enhancement New feature or request pkg:exporter:prometheus Related to the Prometheus exporter package Skip Changelog PRs that do not require a CHANGELOG.md entry

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants