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

some TraceableSession functions do not await the activity #2294

Merged
merged 2 commits into from
Sep 2, 2023

Conversation

bhnaphade
Copy link
Contributor

@bhnaphade bhnaphade commented Sep 1, 2023

Proposed changes

Current Behavior
e.g. this call doesn't measure the duraction correctly because the Task returns directly, the caller waits

public Task TransferSubscriptionsAsync(SubscriptionCollection subscriptions, bool sendInitialValues, CancellationToken ct = default)
{
using (Activity activity = ActivitySource.StartActivity(nameof(TransferSubscriptionsAsync)))
{
return m_session.TransferSubscriptionsAsync(subscriptions, sendInitialValues, ct);
}
}

    Expected Behavior

public async Task TransferSubscriptionsAsync(SubscriptionCollection subscriptions, bool sendInitialValues, CancellationToken ct = default)
{
using (Activity activity = ActivitySource.StartActivity(nameof(TransferSubscriptionsAsync)))
{
return await m_session.TransferSubscriptionsAsync(subscriptions, sendInitialValues, ct).ConfigureAwait(false);
}
}

Related Issues

Types of changes

What types of changes does your code introduce?
Put an x in the boxes that apply. You can also fill these out after creating the PR.

  • Bugfix (non-breaking change which fixes an issue)
  • Enhancement (non-breaking change which adds functionality)
  • Test enhancement (non-breaking change to increase test coverage)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected, requires version increase of Nuget packages)
  • Documentation Update (if none of the other choices apply)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc.
  • I have signed the CLA.
  • I ran tests locally with my changes, all passed.
  • I fixed all failing tests in the CI pipelines.
  • I fixed all introduced issues with CodeQL and LGTM.
  • I have added tests that prove my fix is effective or that my feature works and increased code coverage.
  • I have added necessary documentation (if appropriate).
  • Any dependent changes have been merged and published in downstream modules.

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

@bhnaphade bhnaphade self-assigned this Sep 1, 2023
@codecov
Copy link

codecov bot commented Sep 1, 2023

Codecov Report

Patch coverage: 47.22% and project coverage change: +0.23% 🎉

Comparison is base (67c2ba9) 58.84% compared to head (84f5ee8) 59.07%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2294      +/-   ##
==========================================
+ Coverage   58.84%   59.07%   +0.23%     
==========================================
  Files         330      330              
  Lines       63320    63320              
==========================================
+ Hits        37262    37408     +146     
+ Misses      26058    25912     -146     
Files Changed Coverage Δ
Libraries/Opc.Ua.Client/TraceableSession.cs 50.43% <47.22%> (-0.71%) ⬇️

... and 22 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bhnaphade bhnaphade marked this pull request as ready for review September 1, 2023 15:55
@@ -390,11 +390,11 @@ public ReferenceDescription FindDataDescription(NodeId encodingId)
}

/// <inheritdoc/>
public Task<DataDictionary> FindDataDictionary(NodeId descriptionId)
public async Task<DataDictionary> FindDataDictionary(NodeId descriptionId)

Choose a reason for hiding this comment

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

Also, if the method returns a Task, it needs to have the suffix Async: FindDataDictionaryAsync

@@ -956,11 +956,11 @@ public ResponseHeader EndAddNodes(IAsyncResult result, out AddNodesResultCollect
}

/// <inheritdoc/>
public Task<AddNodesResponse> AddNodesAsync(RequestHeader requestHeader, AddNodesItemCollection nodesToAdd, CancellationToken ct)
public async Task<AddNodesResponse> AddNodesAsync(RequestHeader requestHeader, AddNodesItemCollection nodesToAdd, CancellationToken ct)

This comment was marked as resolved.

Choose a reason for hiding this comment

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

I retract my comment. When using "using", then this is a must.

@@ -390,11 +390,11 @@ public ReferenceDescription FindDataDescription(NodeId encodingId)
}

/// <inheritdoc/>
public Task<DataDictionary> FindDataDictionary(NodeId descriptionId)
public async Task<DataDictionary> FindDataDictionary(NodeId descriptionId)

Choose a reason for hiding this comment

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

Ah, I retract my comment. When using "using", then this is a must.

@mregen mregen merged commit 5d4e962 into master Sep 2, 2023
69 of 72 checks passed
@mregen mregen deleted the sometraceabletaskDoNotAwait branch September 2, 2023 05:29
@mregen mregen added this to the 1.4.372 updates milestone Oct 25, 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

4 participants