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

[prometheus] Fix collection output buffer management when its resized #5676

Merged
merged 7 commits into from
Jun 24, 2024

Conversation

jcin193
Copy link
Contributor

@jcin193 jcin193 commented Jun 7, 2024

Fixes #5661

Changes

When buffer is too small to fit its initial 85kB size its resized to fit the output, however the resized buffer is not used in final output. This ultimately results in overflow exception as cursor is correct and follows resized buffer. I also changed to use the same buffer variable for WriteTargetInfo, it also can resize the buffer.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

When buffer is too small to fit its initial 85kB size, its resized to fit the output, however the resized buffer is not used in final output. This ultimately results in overflow exception as cursor is correct and follows resized buffer.
I also changed to use the same buffer variable for WriteTargetInfo, it also can resize the buffer.
@jcin193 jcin193 requested a review from a team June 7, 2024 09:26
Copy link

linux-foundation-easycla bot commented Jun 7, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@Kielek
Copy link
Contributor

Kielek commented Jun 7, 2024

@jcin193, could you please sign CLA? Without this your contribution cannot be accepted.

@Kielek Kielek added pkg:OpenTelemetry.Exporter.Prometheus.AspNetCore Issues related to OpenTelemetry.Exporter.Prometheus.AspNetCore NuGet package pkg:OpenTelemetry.Exporter.Prometheus.HttpListener Issues related to OpenTelemetry.Exporter.Prometheus.HttpListener NuGet package labels Jun 7, 2024
@jcin193
Copy link
Contributor Author

jcin193 commented Jun 7, 2024

Yeah, I know, unfortunately I wrote this at work, so I'll see what I can do

Copy link
Contributor

This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or Pushing will instruct the bot to automatically remove the label. This bot runs once per day.

@github-actions github-actions bot added the Stale Issues and pull requests which have been flagged for closing due to inactivity label Jun 15, 2024
@jcin193
Copy link
Contributor Author

jcin193 commented Jun 17, 2024

still working on it

@Kielek Kielek removed the Stale Issues and pull requests which have been flagged for closing due to inactivity label Jun 17, 2024
jcin193 and others added 2 commits June 20, 2024 08:10
Co-authored-by: Reiley Yang <reyang@microsoft.com>
@jcin193
Copy link
Contributor Author

jcin193 commented Jun 21, 2024

can we get these tests running?

bbrandt referenced this pull request Jun 21, 2024
…etrics and plain text formats (#5623)

Co-authored-by: Piotr Kiełkowicz <pkiekowicz@splunk.com>
Co-authored-by: Vishwesh Bankwar <vishweshbankwar@users.noreply.github.com>
Co-authored-by: Mikel Blanchard <mblanchard@macrosssoftware.com>
Copy link

codecov bot commented Jun 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.17%. Comparing base (6250307) to head (518a42f).
Report is 265 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5676      +/-   ##
==========================================
+ Coverage   83.38%   86.17%   +2.79%     
==========================================
  Files         297      254      -43     
  Lines       12531    11054    -1477     
==========================================
- Hits        10449     9526     -923     
+ Misses       2082     1528     -554     
Flag Coverage Δ
unittests ?
unittests-Project-Experimental 86.11% <100.00%> (?)
unittests-Project-Stable 86.16% <100.00%> (?)
unittests-UnstableCoreLibraries-Experimental 85.76% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...tpListener/Internal/PrometheusCollectionManager.cs 86.20% <100.00%> (+8.42%) ⬆️

... and 126 files with indirect coverage changes

@CodeBlanch CodeBlanch changed the title Fix collection output buffer management when its resized [prometheus] Fix collection output buffer management when its resized Jun 24, 2024
CodeBlanch and others added 2 commits June 24, 2024 10:15
Co-authored-by: Vishwesh Bankwar <vishweshbankwar@users.noreply.github.com>
@CodeBlanch CodeBlanch merged commit 2f14c24 into open-telemetry:main Jun 24, 2024
40 checks passed
@JoelDavidLang
Copy link

Thanks for this fix. 🎉 I just spent over an hour trying to find out why my metrics were broken and then finding the issue fixed by a package update, thanks to this PR. You saved me a day of frustration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg:OpenTelemetry.Exporter.Prometheus.AspNetCore Issues related to OpenTelemetry.Exporter.Prometheus.AspNetCore NuGet package pkg:OpenTelemetry.Exporter.Prometheus.HttpListener Issues related to OpenTelemetry.Exporter.Prometheus.HttpListener NuGet package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prometheus exporter produces zero-byte HTTP response
6 participants