Skip to content

Conversation

@marcalff
Copy link
Member

@marcalff marcalff commented Oct 22, 2025

Contributes to #2544

Changes

Please provide a brief description of the changes here.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@marcalff marcalff requested a review from a team as a code owner October 22, 2025 10:23
@codecov
Copy link

codecov bot commented Oct 22, 2025

Codecov Report

❌ Patch coverage is 44.44444% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.90%. Comparing base (755411e) to head (5f23f20).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...pi/include/opentelemetry/context/runtime_context.h 44.45% 5 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3709      +/-   ##
==========================================
- Coverage   89.95%   89.90%   -0.05%     
==========================================
  Files         225      225              
  Lines        7273     7281       +8     
==========================================
+ Hits         6542     6545       +3     
- Misses        731      736       +5     
Files with missing lines Coverage Δ
...pi/include/opentelemetry/context/runtime_context.h 92.31% <44.45%> (-5.28%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

}
if (size_ > max_capacity_)
{
return Context();
Copy link
Member

Choose a reason for hiding this comment

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

Just curious - should it return the last valid context, instead of empty one ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question.

In my understanding, Scope will attach and detach contexts on creation and destruction, adding/removing from the stack.

If the code returns the last valid context, then we will have:

  • every scope nested at depth max_capacity_, max_capacity_ + 1, ..., max_capacity_ + N share the same context.
  • Scope at max_capacity_ + N will destroy the last valid scope on destruction, causing side effects.

So, I think Top() and Pop() should return an empty context instead, once the stack depth goes beyond the limit.

This is very theoretical, because any process with 1 million nested scopes in the call stack will never reach this point, being long dead, already killed for other reasons (stack overflow, out of memory).

Copy link
Member

@lalitb lalitb left a comment

Choose a reason for hiding this comment

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

LGTM. The edge case shouldn’t occur in any normal usage scenario :)

@marcalff marcalff merged commit 70daba9 into open-telemetry:main Oct 23, 2025
67 checks passed
}
if (size_ > capacity_)
{
Resize(size_ * 2);
Copy link
Contributor

@Reneg973 Reneg973 Oct 25, 2025

Choose a reason for hiding this comment

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

@marcalff
Did you see this line?
Resize(size_ * 2);

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.

3 participants