-
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
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
72a2553
Provide better concurrency modes
reyang 226c19e
Merge branch 'main' into reyang/concurrency
reyang 458faaf
scope down
reyang 67324bd
clean up
reyang 08201f2
using
reyang 608da98
nullable
reyang 638ad10
Merge branch 'main' into reyang/concurrency
reyang 3bad975
changelog
reyang fd36fc9
Merge branch 'main' into reyang/concurrency
reyang c5b6dd1
Merge branch 'main' into reyang/concurrency
reyang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
namespace OpenTelemetry; | ||
|
||
/// <summary> | ||
/// Describes the concurrency mode of an OpenTelemetry extension. | ||
/// </summary> | ||
[Flags] | ||
public enum ConcurrencyModes : byte | ||
{ | ||
/* | ||
0 0 0 0 0 0 0 0 | ||
| | | | | | | | | ||
| | | | | | | +--- Reentrant | ||
| | | | | | +----- Multithreaded | ||
| | | | | +------- (reserved) | ||
| | | | +--------- (reserved) | ||
| | | +----------- (reserved) | ||
| | +------------- (reserved) | ||
| +--------------- (reserved) | ||
+----------------- (reserved) | ||
*/ | ||
|
||
/// <summary> | ||
/// Reentrant, the component can be invoked recursively without resulting | ||
/// a deadlock or infinite loop. | ||
/// </summary> | ||
Reentrant = 0b1, | ||
|
||
/// <summary> | ||
/// Multithreaded, the component can be invoked concurrently across | ||
/// multiple threads. | ||
/// </summary> | ||
Multithreaded = 0b10, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
namespace OpenTelemetry; | ||
|
||
/// <summary> | ||
/// An attribute for declaring the supported <see cref="ConcurrencyModes"/> of an OpenTelemetry extension. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] | ||
public sealed class ConcurrencyModesAttribute : Attribute | ||
{ | ||
private readonly ConcurrencyModes supportedConcurrencyModes; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ConcurrencyModesAttribute"/> class. | ||
/// </summary> | ||
/// <param name="supported"><see cref="ConcurrencyModes"/>.</param> | ||
public ConcurrencyModesAttribute(ConcurrencyModes supported) | ||
{ | ||
this.supportedConcurrencyModes = supported; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the supported <see cref="ConcurrencyModes"/>. | ||
/// </summary> | ||
public ConcurrencyModes Supported => this.supportedConcurrencyModes; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 removeReentrant
? 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?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.
Maybe. I personally consider this as a bug in the current SDK implementation.
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.