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

Detect broken Activity stack and gracefully end the loop #23

Merged
merged 5 commits into from
Mar 30, 2018

Conversation

lmolkova
Copy link

Fix #22

@lmolkova lmolkova changed the title Detect broken Activity stack and gracefully end Detect broken Activity stack and gracefully end the loop Mar 29, 2018
@lmolkova
Copy link
Author

@SergeyKanzhelev @Jinhuafei

please review.

{
// silently stop all child activities before activity
while (Activity.Current != activity && Activity.Current != null)
int iteration = 0;
while (currentActivity != activity)
Copy link
Contributor

Choose a reason for hiding this comment

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

we may need a similar logic in recent PR with the tags reading in base SDK

Copy link
Author

Choose a reason for hiding this comment

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

in the base SDK we don't walk up the stack of activities to find ours. If current does not match current operation, we just fail. We can do that for sure, I'll create an issue

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean for the recent PR where tags are read from all parents

Copy link
Author

Choose a reason for hiding this comment

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

If you mean this one: microsoft/ApplicationInsights-dotnet#736, it is for initializing/tracking telemetry before Activity is stopped. Basically, it allows customers to use tags themselves with a custom initializer.

For parent tags reading, walking up the stack is not a problem, as Parent for 'broken' Activity is correct, it's just Stop() that never updates Current to Parent.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was confused. I though to fix this one: microsoft/ApplicationInsights-dotnet#562 we will walk up the parents. When we will be implementing this we need to have the same protection there

Copy link
Author

Choose a reason for hiding this comment

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

There is no problem with parent walking, i.e.

var activity = Activity.Current;
while (activity != null) {
  // do something
  activity = activity.Parent;
}

is not affected by this Stop issue.

It might be a hypothetical problem if we'll ever have a cycle in the parents stack.
I'll update the Tags issue and mention it.

WriteEvent(6, id, name);
}

[Event(7, Message = "Activity stack is too deep, Current Id: '{0}', Name: '{1}'", Level = EventLevel.Error)]
Copy link
Contributor

Choose a reason for hiding this comment

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

It may be a good idea to subscribe on these in base SDK so we have them reported as SDK errors.

Copy link
Author

Choose a reason for hiding this comment

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

Agree, will do

<Reference Include="System.Diagnostics.DiagnosticSource, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Diagnostics.DiagnosticSource.4.4.0\lib\net45\System.Diagnostics.DiagnosticSource.dll</HintPath>
<Reference Include="System.Diagnostics.DiagnosticSource, Version=4.0.2.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Diagnostics.DiagnosticSource.4.4.1\lib\net45\System.Diagnostics.DiagnosticSource.dll</HintPath>
Copy link
Contributor

Choose a reason for hiding this comment

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

is this reference upgrade necessary? I worry it may break something or introduce some unnecessary binding redirects.

Copy link
Author

Choose a reason for hiding this comment

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

you are right, it is not necessary

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.

2 participants