-
Notifications
You must be signed in to change notification settings - Fork 764
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
[sdk] Provide better concurrency modes #5643
Conversation
@@ -5,6 +5,7 @@ | |||
using OpenTelemetry; | |||
using OpenTelemetry.Logs; | |||
|
|||
[ConcurrencyModes(ConcurrencyModes.Multithreaded | ConcurrencyModes.Reentrant)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to show how the attributes can be used, once folks agree with the direction, I'll revert the example code and update the changelog.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5643 +/- ##
==========================================
+ Coverage 83.38% 85.67% +2.29%
==========================================
Files 297 255 -42
Lines 12531 11051 -1480
==========================================
- Hits 10449 9468 -981
+ Misses 2082 1583 -499
Flags with carried forward coverage won't be shown. Click here to find out more.
|
/// Reentrant, the component can be invoked recursively without resulting | ||
/// a deadlock or infinite loop. | ||
/// </summary> | ||
Reentrant = 0b1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We removed Global
for now should we also remove Reentrant
? Doesn't seem to be used at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My gut feeling is no. Multithreaded and Reentrant are closely related, the existing implementation (which uses lock(obj)
) implies that the exporter supports reentrancy but not multithreading (which is buggy IMHO).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No strong feelings though, I can scope this out and add it later once we figured out how to correctly handle reentrancy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. So if the attribute is not specified and defaults to 0 our implied default is essentially SingleThreaded | Reentrant
?
Should the defined Reentrant
flag then negate the default behavior?
public enum ConcurrencyModes : byte
{
/// <summary>
/// Nonreentrant, the component cannot be invoked recursively without resulting
/// in a deadlock or infinite loop.
/// </summary>
Nonreentrant = 0b1,
/// <summary>
/// Multithreaded, the component can be invoked concurrently across
/// multiple threads.
/// </summary>
Multithreaded = 0b10,
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. So if the attribute is not specified and defaults to 0 our implied default is essentially
SingleThreaded | Reentrant
?
Maybe. I personally consider this as a bug in the current SDK implementation.
Should the defined
Reentrant
flag then negate the default behavior?
I guess no, better to treat it as a bug, then figure out how to fix it in a non-breaking way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thinking - if the exporter doesn't have the attribute at all, fall back to the old (and buggy) behavior, if the exporter has the attribute, start to enforce the correct behavior.
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. |
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. |
Closed as inactive. Feel free to reopen if this PR is still being worked on. |
@reyang @CodeBlanch - I see this got closed due to inactivity. Do we have a plan for removing the private reflection in the GenevaExporter? |
@CodeBlanch would you follow up? |
@eerhardt Still working on the plan. I've been exploring some other possible APIs/alternatives. Hoping to have something to propose soon and then we'll pick a direction to have in place for the next release. |
This is following the same design as push/pull metrics exporter:
opentelemetry-dotnet/src/OpenTelemetry/Metrics/ExportModesAttribute.cs
Lines 9 to 10 in 3cff6db
Exporter (also processors, samplers, etc.) authors can optionally provide additional hints so the SDK can better serve the need:
In addition, I envision that Console Exporters can leverage this to provide synchronization across multiple instances, so a log exporter and metrics exporter won't have race condition and cause garbled text in stdout: