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

App Insights Tags for Orchestrators and Entities #1301

Merged
merged 23 commits into from Apr 24, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
fbb5d33
naive attempt at adding AppInsight tags
davidmrdavid Apr 2, 2020
d6ed5f9
fixed tag names for Entities
davidmrdavid Apr 2, 2020
ddffbaa
renamed tag fields, moved logging down
davidmrdavid Apr 3, 2020
efdb45e
added safety null check
davidmrdavid Apr 6, 2020
3b770e4
change sinle-line comments to multi-line
davidmrdavid Apr 6, 2020
b2d0c3f
dummy commit to restart test
davidmrdavid Apr 6, 2020
b9b64f8
stylecop error fix: trailing whitespace
davidmrdavid Apr 6, 2020
ae3d5ef
sanity check, will tests pass?
davidmrdavid Apr 6, 2020
98de927
another sanity check: commenting-out all changes
davidmrdavid Apr 7, 2020
a1070d4
fixing commenting-out mistake
davidmrdavid Apr 7, 2020
acc70be
removing all changes
davidmrdavid Apr 7, 2020
9975c72
app insights show the right data
davidmrdavid Apr 8, 2020
847e73d
removed unecessary whitespacing
davidmrdavid Apr 8, 2020
610bd28
incorporate feedback and stylecop
davidmrdavid Apr 8, 2020
70a0d93
Merge branch 'dev' of https://github.com/Azure/azure-functions-durabl…
davidmrdavid Apr 9, 2020
e196471
incorporated feedback: less conditional compilation, refactored logging
davidmrdavid Apr 9, 2020
c03af9a
Merge branch 'dev' of https://github.com/Azure/azure-functions-durabl…
davidmrdavid Apr 10, 2020
ff04a19
attempt to record running status
davidmrdavid Apr 14, 2020
d72eb77
isReplaying enables Application insights to work, dropped status upda…
davidmrdavid Apr 23, 2020
3516b2f
fixed stylecop errors
davidmrdavid Apr 24, 2020
963f77d
removed unecessary imports
davidmrdavid Apr 24, 2020
3a48606
removed unecessary comment
davidmrdavid Apr 24, 2020
19fd5e0
updated task entity shim, removed redundant work
davidmrdavid Apr 24, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/WebJobs.Extensions.DurableTask/Listener/TaskEntityShim.cs
Expand Up @@ -148,6 +148,7 @@ internal void Rehydrate(string serializedInput)

public override async Task<string> Execute(OrchestrationContext innerContext, string serializedInput)
{
string status;
davidmrdavid marked this conversation as resolved.
Show resolved Hide resolved
if (this.operationBatch.Count == 0 && this.lockRequest == null)
{
// we are idle after a ContinueAsNew - the batch is empty.
Expand All @@ -167,6 +168,7 @@ public override async Task<string> Execute(OrchestrationContext innerContext, st
this.Config.GetIntputOutputTrace(serializedInput),
FunctionType.Entity,
isReplay: false);
status = "Running";
davidmrdavid marked this conversation as resolved.
Show resolved Hide resolved

if (this.NumberEventsToReceive > 0)
{
Expand Down Expand Up @@ -211,6 +213,8 @@ public override async Task<string> Execute(OrchestrationContext innerContext, st
description,
functionType: FunctionType.Entity,
isReplay: false);
status = "Failed";

}
else
{
Expand All @@ -222,7 +226,21 @@ public override async Task<string> Execute(OrchestrationContext innerContext, st
continuedAsNew: true,
functionType: FunctionType.Entity,
isReplay: false);
status = "Completed";
}

#if !FUNCTIONS_V1
// Adding "Tags" to activity allows using App Insights to query current state of entities
var activity = Activity.Current;

// The activity may be null when running unit tests, but should be non-null otherwise
if (activity != null)
{
activity.AddTag("DurableFunctionsType", "Entity");
activity.AddTag("DurableFunctionsInstanceId", this.context.InstanceId);
activity.AddTag("DurableFunctionsRuntimeStatus", status);
}
#endif

// The return value is not used.
return string.Empty;
Expand Down
Expand Up @@ -49,6 +49,7 @@ public override void RaiseEvent(OrchestrationContext unused, string eventName, s

public override async Task<string> Execute(OrchestrationContext innerContext, string serializedInput)
{
string status;
if (this.FunctionInvocationCallback == null)
{
throw new InvalidOperationException($"The {nameof(this.FunctionInvocationCallback)} has not been assigned!");
Expand All @@ -69,6 +70,7 @@ public override async Task<string> Execute(OrchestrationContext innerContext, st
this.Config.GetIntputOutputTrace(serializedInput),
FunctionType.Orchestrator,
this.context.IsReplaying);
status = "Running";

var orchestratorInfo = this.Config.GetOrchestratorInfo(new FunctionName(this.context.Name));

Expand Down Expand Up @@ -106,6 +108,8 @@ public override async Task<string> Execute(OrchestrationContext innerContext, st
exceptionDetails,
FunctionType.Orchestrator,
this.context.IsReplaying);
status = "Failed";


if (!this.context.IsReplaying)
{
Expand Down Expand Up @@ -169,6 +173,8 @@ public override async Task<string> Execute(OrchestrationContext innerContext, st
this.context.ContinuedAsNew,
FunctionType.Orchestrator,
this.context.IsReplaying);
status = "Completed";

if (!this.context.IsReplaying)
{
this.context.AddDeferredTask(() => this.Config.LifeCycleNotificationHelper.OrchestratorCompletedAsync(
Expand All @@ -179,6 +185,19 @@ public override async Task<string> Execute(OrchestrationContext innerContext, st
this.context.IsReplaying));
}

#if !FUNCTIONS_V1
// Adding "Tags" to activity allows using App Insights to query current state of orchestrations
var activity = Activity.Current;

// The activity may be null when running unit tests, but should be non-null otherwise
if (activity != null)
{
activity.AddTag("DurableFunctionsType", "Orchestrator");
activity.AddTag("DurableFunctionsInstanceId", context.InstanceId);
activity.AddTag("DurableFunctionsRuntimeStatus", status);
}
#endif

return serializedOutput;
}
}
Expand Down