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

[AOT] Removed support for ParseStateValues if the state neither implements IReadOnlyList nor IEnumberable when ParseStateValues is true. #4560

Closed
wants to merge 22 commits into from

Conversation

Yun-Ting
Copy link
Contributor

@Yun-Ting Yun-Ting commented Jun 7, 2023

Towards #3429

Changes

Most TStates implements IReadOnlyList and IEnumerable.
Added a event to log a warning for states, which requires fetching properties at runtime, will be skipped if RuntimeFeature.IsDynamicCodeSupported evaluates to false.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes

@codecov
Copy link

codecov bot commented Jun 8, 2023

Codecov Report

Merging #4560 (cbdef79) into main (5f825cb) will increase coverage by 0.03%.
The diff coverage is 62.50%.

❗ Current head cbdef79 differs from pull request most recent head 90771fe. Consider uploading reports for the commit 90771fe to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4560      +/-   ##
==========================================
+ Coverage   84.88%   84.92%   +0.03%     
==========================================
  Files         313      313              
  Lines       12604    12594      -10     
==========================================
- Hits        10699    10695       -4     
+ Misses       1905     1899       -6     
Impacted Files Coverage Δ
...nTelemetry/Internal/OpenTelemetrySdkEventSource.cs 81.91% <50.00%> (+2.12%) ⬆️
.../OpenTelemetry/Logs/ILogger/OpenTelemetryLogger.cs 87.87% <100.00%> (+1.64%) ⬆️

... and 4 files with indirect coverage changes

@Yun-Ting Yun-Ting marked this pull request as ready for review June 8, 2023 00:09
@Yun-Ting Yun-Ting requested a review from a team as a code owner June 8, 2023 00:09
Copy link
Member

@CodeBlanch CodeBlanch left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

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

Assuming @utpilla and @CodeBlanch are fine with this change, LGTM.

@Yun-Ting Yun-Ting changed the title [AOT] Addressed TypeDescriptor.GetProperties warning. [AOT] Addressed TypeDescriptor.GetProperties warning by removing it. Jun 16, 2023
@Yun-Ting Yun-Ting changed the title [AOT] Addressed TypeDescriptor.GetProperties warning by removing it. [AOT] Removed support for ParseStateValues if the state neither implements IReadOnlyList nor IEnumberable when ParseStateValues is true. Jun 16, 2023
@@ -2,6 +2,12 @@

## Unreleased

* **Breaking Change** Removed support for ParseStateValues if the state
implements neither IReadOnlyList nor IEnumberable when `ParseStateValues` is
Copy link
Contributor

@utpilla utpilla Jun 22, 2023

Choose a reason for hiding this comment

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

Suggested change
implements neither IReadOnlyList nor IEnumberable when `ParseStateValues` is
implements neither `IReadOnlyList<KeyValuePair<string, object>>` nor `IEnumerable<KeyValuePair<string, object>>` when `ParseStateValues` is

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@CodeBlanch Should we be using this instead?

IReadOnlyList<out T> nor IEnumerable<out T> where T is KeyValuePair<string, object>.


return Array.Empty<KeyValuePair<string, object?>>();
}
OpenTelemetrySdkEventSource.Log.LoggerProcessStateSkipped<TState>(typeof(TState).FullName!, "This can be fixed by updating the state to be a type that implements either IReadOnlyList<KeyValuePair<string, object>> or IEnumerable<KeyValuePair<string, object>>.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Update the documentation of ParseStateValues option to reflect this change.

/// <summary>
/// Gets or sets a value indicating whether or not log state should be
/// parsed into <see cref="LogRecord.Attributes"/> on generated <see
/// cref="LogRecord"/>s. Default value: <see langword="false"/>.
/// </summary>
/// <remarks>
/// Notes:
/// <list type="bullet">
/// <item>Parsing is only executed when the state logged does NOT
/// implement <see cref="IReadOnlyList{T}"/> or <see
/// cref="IEnumerable{T}"/> where <c>T</c> is <c>KeyValuePair&lt;string,
/// object&gt;</c>.</item>
/// <item>When <see cref="ParseStateValues"/> is set to <see
/// langword="true"/> <see cref="LogRecord.State"/> will always be <see
/// langword="null"/>.</item>
/// </list>
/// </remarks>
public bool ParseStateValues { get; set; }

Copy link
Member

Choose a reason for hiding this comment

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

Just FYI removing this code ParseStateValues essentially does nothing. Should we obsolete it?

Copy link
Contributor

Choose a reason for hiding this comment

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

That would break build for users who have used this option in their Logs SDK setup, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#4334 redefines ParseStateValues.
With the redefined ParseStateValues, value of public bool ParseStateValues { get; set; } is default to false and only should be set to true if state does not implement either IReadOnlyList or IEnumerable if users want to get the properties with Reflection.

Shall we obsolete this API in this PR or use a follow-up PR for that?

Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we obsolete this API in this PR or use a follow-up PR for that?

It should be its own PR (if at all we decide to do that).

@utpilla
Copy link
Contributor

utpilla commented Jun 28, 2023

This change was merged in #4619

@utpilla utpilla closed this Jun 28, 2023
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.

None yet

7 participants