forked from Azure/azure-functions-host
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New columns: HostInstanceId, FunctionInvocationId (Azure#2489)
* New columns: HostInstanceId, FunctionInvocationId
- Loading branch information
1 parent
1f243e9
commit bafab95
Showing
32 changed files
with
507 additions
and
417 deletions.
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
321 changes: 6 additions & 315 deletions
321
src/WebJobs.Script.WebHost/Diagnostics/EventGenerator.cs
Large diffs are not rendered by default.
Oops, something went wrong.
246 changes: 246 additions & 0 deletions
246
src/WebJobs.Script.WebHost/Diagnostics/ExtendedEventSource.cs
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,246 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Diagnostics.Tracing; | ||
using System.Reflection; | ||
|
||
namespace Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics | ||
{ | ||
public abstract unsafe class ExtendedEventSource : EventSource | ||
{ | ||
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "For this type", Target = "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics")] | ||
[NonEvent] | ||
[Obsolete("Do not use params object[] overload, create a explicit WriteEvent in ExtendedEventSource.", true)] | ||
protected new void WriteEvent(int eventNum, params object[] args) | ||
{ | ||
base.WriteEvent(eventNum, args); | ||
} | ||
|
||
// LogFunctionExecutionAggregateEvent | ||
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")] | ||
[NonEvent] | ||
protected void WriteEvent(int eventNumber, string a, string b, ulong c, ulong d, ulong e, ulong f) | ||
{ | ||
const int count = 6; | ||
fixed (char* aPtr = a, bPtr = b) | ||
{ | ||
EventData* data = stackalloc EventData[count]; | ||
data[0].DataPointer = (IntPtr)aPtr; | ||
data[0].Size = (a.Length + 1) * sizeof(char); | ||
data[1].DataPointer = (IntPtr)bPtr; | ||
data[1].Size = (b.Length + 1) * sizeof(char); | ||
data[2].DataPointer = (IntPtr)(&c); | ||
data[2].Size = sizeof(ulong); | ||
data[3].DataPointer = (IntPtr)(&d); | ||
data[3].Size = sizeof(ulong); | ||
data[4].DataPointer = (IntPtr)(&e); | ||
data[4].Size = sizeof(ulong); | ||
data[5].DataPointer = (IntPtr)(&f); | ||
data[5].Size = sizeof(ulong); | ||
|
||
WriteEventCore(eventNumber, count, data); | ||
} | ||
} | ||
|
||
// LogFunctionDetailsEvent | ||
[NonEvent] | ||
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")] | ||
protected void WriteEvent(int eventNum, string a, string b, string c, string d, string e, bool f) | ||
{ | ||
const int count = 6; | ||
fixed (char* aPtr = a, | ||
bPtr = b, | ||
cPtr = c, | ||
dPtr = d, | ||
ePtr = e) | ||
{ | ||
EventData* data = stackalloc EventData[count]; | ||
data[0].DataPointer = (IntPtr)aPtr; | ||
data[0].Size = (a.Length + 1) * sizeof(char); | ||
data[1].DataPointer = (IntPtr)bPtr; | ||
data[1].Size = (b.Length + 1) * sizeof(char); | ||
data[2].DataPointer = (IntPtr)cPtr; | ||
data[2].Size = (c.Length + 1) * sizeof(char); | ||
data[3].DataPointer = (IntPtr)dPtr; | ||
data[3].Size = (d.Length + 1) * sizeof(char); | ||
data[4].DataPointer = (IntPtr)ePtr; | ||
data[4].Size = (e.Length + 1) * sizeof(char); | ||
data[5].DataPointer = (IntPtr)(&f); | ||
data[5].Size = 4; // boolean variables have size 4 | ||
|
||
WriteEventCore(eventNum, count, data); | ||
} | ||
} | ||
|
||
// LogFunctionExecutionEvent | ||
[NonEvent] | ||
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")] | ||
protected void WriteEvent(int eventNum, string a, string b, int c, string d, string e, string f, ulong g, bool h) | ||
{ | ||
const int count = 8; | ||
fixed (char* aPtr = a, | ||
bPtr = b, | ||
dPtr = d, | ||
ePtr = e, | ||
fPtr = f) | ||
{ | ||
EventData* data = stackalloc EventData[count]; | ||
data[0].DataPointer = (IntPtr)aPtr; | ||
data[0].Size = (a.Length + 1) * sizeof(char); | ||
data[1].DataPointer = (IntPtr)bPtr; | ||
data[1].Size = (b.Length + 1) * sizeof(char); | ||
data[2].DataPointer = (IntPtr)(&c); | ||
data[2].Size = sizeof(int); | ||
data[3].DataPointer = (IntPtr)dPtr; | ||
data[3].Size = (d.Length + 1) * sizeof(char); | ||
data[4].DataPointer = (IntPtr)ePtr; | ||
data[4].Size = (e.Length + 1) * sizeof(char); | ||
data[5].DataPointer = (IntPtr)fPtr; | ||
data[5].Size = (f.Length + 1) * sizeof(char); | ||
data[6].DataPointer = (IntPtr)(&g); | ||
data[6].Size = sizeof(ulong); | ||
data[7].DataPointer = (IntPtr)(&h); | ||
data[7].Size = 4; // boolean variables have size 4 | ||
|
||
WriteEventCore(eventNum, count, data); | ||
} | ||
} | ||
|
||
// RaiseFunctionsEventVerbose/Info/Warning | ||
[NonEvent] | ||
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")] | ||
protected void WriteEvent(int eventNum, string a, string b, string c, string d, string e, string f, string g, string h, string i, string j, string k) | ||
{ | ||
int count = MethodBase.GetCurrentMethod().GetParameters().Length; | ||
fixed (char* aPtr = a, | ||
bPtr = b, | ||
cPtr = c, | ||
dPtr = d, | ||
ePtr = e, | ||
fPtr = f, | ||
gPtr = g, | ||
hPtr = h, | ||
iPtr = i, | ||
jPtr = j, | ||
kPtr = k) | ||
{ | ||
EventData* data = stackalloc EventData[count]; | ||
data[0].DataPointer = (IntPtr)aPtr; | ||
data[0].Size = (a.Length + 1) * sizeof(char); | ||
data[1].DataPointer = (IntPtr)bPtr; | ||
data[1].Size = (b.Length + 1) * sizeof(char); | ||
data[2].DataPointer = (IntPtr)cPtr; | ||
data[2].Size = (c.Length + 1) * sizeof(char); | ||
data[3].DataPointer = (IntPtr)dPtr; | ||
data[3].Size = (d.Length + 1) * sizeof(char); | ||
data[4].DataPointer = (IntPtr)ePtr; | ||
data[4].Size = (e.Length + 1) * sizeof(char); | ||
data[5].DataPointer = (IntPtr)fPtr; | ||
data[5].Size = (f.Length + 1) * sizeof(char); | ||
data[6].DataPointer = (IntPtr)gPtr; | ||
data[6].Size = (g.Length + 1) * sizeof(char); | ||
data[7].DataPointer = (IntPtr)hPtr; | ||
data[7].Size = (h.Length + 1) * sizeof(char); | ||
data[8].DataPointer = (IntPtr)iPtr; | ||
data[8].Size = (i.Length + 1) * sizeof(char); | ||
data[9].DataPointer = (IntPtr)jPtr; | ||
data[9].Size = (j.Length + 1) * sizeof(char); | ||
data[10].DataPointer = (IntPtr)kPtr; | ||
data[10].Size = (k.Length + 1) * sizeof(char); | ||
WriteEventCore(eventNum, count, data); | ||
} | ||
} | ||
|
||
// RaiseFunctionsEventError | ||
[NonEvent] | ||
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")] | ||
protected void WriteEvent(int eventNum, string a, string b, string c, string d, string e, string f, string g, string h, string i, string j, string k, string l, string m) | ||
{ | ||
int count = MethodBase.GetCurrentMethod().GetParameters().Length; | ||
fixed (char* aPtr = a, | ||
bPtr = b, | ||
cPtr = c, | ||
dPtr = d, | ||
ePtr = e, | ||
fPtr = f, | ||
gPtr = g, | ||
hPtr = h, | ||
iPtr = i, | ||
jPtr = j, | ||
kPtr = k, | ||
lPtr = l, | ||
mPtr = m) | ||
{ | ||
EventData* data = stackalloc EventData[count]; | ||
data[0].DataPointer = (IntPtr)aPtr; | ||
data[0].Size = (a.Length + 1) * sizeof(char); | ||
data[1].DataPointer = (IntPtr)bPtr; | ||
data[1].Size = (b.Length + 1) * sizeof(char); | ||
data[2].DataPointer = (IntPtr)cPtr; | ||
data[2].Size = (c.Length + 1) * sizeof(char); | ||
data[3].DataPointer = (IntPtr)dPtr; | ||
data[3].Size = (d.Length + 1) * sizeof(char); | ||
data[4].DataPointer = (IntPtr)ePtr; | ||
data[4].Size = (e.Length + 1) * sizeof(char); | ||
data[5].DataPointer = (IntPtr)fPtr; | ||
data[5].Size = (f.Length + 1) * sizeof(char); | ||
data[6].DataPointer = (IntPtr)gPtr; | ||
data[6].Size = (g.Length + 1) * sizeof(char); | ||
data[7].DataPointer = (IntPtr)hPtr; | ||
data[7].Size = (h.Length + 1) * sizeof(char); | ||
data[8].DataPointer = (IntPtr)iPtr; | ||
data[8].Size = (i.Length + 1) * sizeof(char); | ||
data[9].DataPointer = (IntPtr)jPtr; | ||
data[9].Size = (j.Length + 1) * sizeof(char); | ||
data[10].DataPointer = (IntPtr)kPtr; | ||
data[10].Size = (k.Length + 1) * sizeof(char); | ||
data[11].DataPointer = (IntPtr)lPtr; | ||
data[11].Size = (l.Length + 1) * sizeof(char); | ||
data[12].DataPointer = (IntPtr)mPtr; | ||
data[12].Size = (m.Length + 1) * sizeof(char); | ||
WriteEventCore(eventNum, count, data); | ||
} | ||
} | ||
|
||
// LogFunctionMetricEvent | ||
[NonEvent] | ||
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")] | ||
protected void WriteEvent(int eventNum, string a, string b, string c, string d, long e, long f, long g, long h, string i, string j) | ||
{ | ||
int count = MethodBase.GetCurrentMethod().GetParameters().Length; | ||
fixed (char* aPtr = a, | ||
bPtr = b, | ||
cPtr = c, | ||
dPtr = d, | ||
iPtr = i, | ||
jPtr = j) | ||
{ | ||
EventData* data = stackalloc EventData[count]; | ||
data[0].DataPointer = (IntPtr)aPtr; | ||
data[0].Size = (a.Length + 1) * sizeof(char); | ||
data[1].DataPointer = (IntPtr)bPtr; | ||
data[1].Size = (b.Length + 1) * sizeof(char); | ||
data[2].DataPointer = (IntPtr)cPtr; | ||
data[2].Size = (c.Length + 1) * sizeof(char); | ||
data[3].DataPointer = (IntPtr)dPtr; | ||
data[3].Size = (d.Length + 1) * sizeof(char); | ||
data[4].DataPointer = (IntPtr)(&e); | ||
data[4].Size = sizeof(long); | ||
data[5].DataPointer = (IntPtr)(&f); | ||
data[5].Size = sizeof(long); | ||
data[6].DataPointer = (IntPtr)(&g); | ||
data[6].Size = sizeof(long); | ||
data[7].DataPointer = (IntPtr)(&h); | ||
data[7].Size = sizeof(long); | ||
data[8].DataPointer = (IntPtr)iPtr; | ||
data[8].Size = (i.Length + 1) * sizeof(char); | ||
data[9].DataPointer = (IntPtr)jPtr; | ||
data[9].Size = (j.Length + 1) * sizeof(char); | ||
|
||
WriteEventCore(eventNum, count, data); | ||
} | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/WebJobs.Script.WebHost/Diagnostics/FunctionsEventSource.cs
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,50 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using System.Diagnostics.CodeAnalysis; | ||
using System.Diagnostics.Tracing; | ||
|
||
namespace Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics | ||
{ | ||
[EventSource(Guid = "08D0D743-5C24-43F9-9723-98277CEA5F9B")] | ||
public sealed class FunctionsEventSource : ExtendedEventSource | ||
{ | ||
internal static readonly FunctionsEventSource Instance = new FunctionsEventSource(); | ||
|
||
[SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ms")] | ||
[SuppressMessage("Microsoft.Naming", "CA1704:IdentfiersShouldBeSpelledCorrectly", MessageId = "Ms")] | ||
[Event(57907, Level = EventLevel.Informational, Channel = EventChannel.Operational, Keywords = FunctionsKeywords.DefaultMetricsKeyword)] | ||
public void LogFunctionExecutionAggregateEvent(string siteName, string functionName, ulong executionTimeInMs, ulong functionStartedCount, ulong functionCompletedCount, ulong functionFailedCount) | ||
{ | ||
if (IsEnabled()) | ||
{ | ||
WriteEvent(57907, siteName, functionName, executionTimeInMs, functionStartedCount, functionCompletedCount, functionFailedCount); | ||
} | ||
} | ||
|
||
[Event(57908, Level = EventLevel.Informational, Channel = EventChannel.Operational, Keywords = FunctionsKeywords.DefaultMetricsKeyword)] | ||
[SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly")] | ||
public void LogFunctionDetailsEvent(string siteName, string functionName, string inputBindings, string outputBindings, string scriptType, bool isDisabled) | ||
{ | ||
if (IsEnabled()) | ||
{ | ||
WriteEvent(57908, siteName, functionName, inputBindings, outputBindings, scriptType, isDisabled); | ||
} | ||
} | ||
|
||
[Event(57909, Level = EventLevel.Informational, Channel = EventChannel.Operational, Keywords = FunctionsKeywords.DefaultMetricsKeyword)] | ||
[SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly")] | ||
public void LogFunctionExecutionEvent(string executionId, string siteName, int concurrency, string functionName, string invocationId, string executionStage, ulong executionTimeSpan, bool success) | ||
{ | ||
if (IsEnabled()) | ||
{ | ||
WriteEvent(57909, executionId, siteName, concurrency, functionName, invocationId, executionStage, executionTimeSpan, success); | ||
} | ||
} | ||
|
||
internal class FunctionsKeywords | ||
{ | ||
public const EventKeywords DefaultMetricsKeyword = unchecked((EventKeywords)0x8000000000000000); | ||
} | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
src/WebJobs.Script.WebHost/Diagnostics/FunctionsSystemLogsEventSource.cs
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,80 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Diagnostics.Tracing; | ||
|
||
namespace Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics | ||
{ | ||
[EventSource(Guid = "a7044dd6-c8ef-4980-858c-942d972b6250")] | ||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1313:ParameterNamesMustBeginWithLowerCaseLetter", Justification = "MDS columns names need to Pascal case", Scope = "member", Target = "~M:Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.EventGenerator.FunctionsSystemLogsEventSource)")] | ||
public sealed class FunctionsSystemLogsEventSource : ExtendedEventSource | ||
{ | ||
internal static readonly FunctionsSystemLogsEventSource Instance = new FunctionsSystemLogsEventSource(); | ||
|
||
[SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", Justification = "MDS columns names are Pascal Cased")] | ||
[SuppressMessage("Microsoft.Design", "CA1030:UseEventsWhereAppropriate")] | ||
[Event(65520, Level = EventLevel.Verbose, Channel = EventChannel.Operational, Version = 4)] | ||
public void RaiseFunctionsEventVerbose(string SubscriptionId, string AppName, string FunctionName, string EventName, string Source, string Details, string Summary, string HostVersion, string EventTimestamp, string FunctionInvocationId, string HostInstanceId) | ||
{ | ||
if (IsEnabled()) | ||
{ | ||
WriteEvent(65520, SubscriptionId, AppName, FunctionName, EventName, Source, Details, Summary, HostVersion, EventTimestamp, FunctionInvocationId, HostInstanceId); | ||
} | ||
} | ||
|
||
[SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly")] | ||
[SuppressMessage("Microsoft.Design", "CA1030:UseEventsWhereAppropriate")] | ||
[Event(65521, Level = EventLevel.Informational, Channel = EventChannel.Operational, Version = 4)] | ||
public void RaiseFunctionsEventInfo(string SubscriptionId, string AppName, string FunctionName, string EventName, string Source, string Details, string Summary, string HostVersion, string EventTimestamp, string FunctionInvocationId, string HostInstanceId) | ||
{ | ||
if (IsEnabled()) | ||
{ | ||
WriteEvent(65521, SubscriptionId, AppName, FunctionName, EventName, Source, Details, Summary, HostVersion, EventTimestamp, FunctionInvocationId, HostInstanceId); | ||
} | ||
} | ||
|
||
[SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly")] | ||
[SuppressMessage("Microsoft.Design", "CA1030:UseEventsWhereAppropriate")] | ||
[Event(65522, Level = EventLevel.Warning, Channel = EventChannel.Operational, Version = 4)] | ||
public void RaiseFunctionsEventWarning(string SubscriptionId, string AppName, string FunctionName, string EventName, string Source, string Details, string Summary, string HostVersion, string EventTimestamp, string FunctionInvocationId, string HostInstanceId) | ||
{ | ||
if (IsEnabled()) | ||
{ | ||
WriteEvent(65522, SubscriptionId, AppName, FunctionName, EventName, Source, Details, Summary, HostVersion, EventTimestamp, FunctionInvocationId, HostInstanceId); | ||
} | ||
} | ||
|
||
[SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly")] | ||
[SuppressMessage("Microsoft.Design", "CA1030:UseEventsWhereAppropriate")] | ||
[Event(65523, Level = EventLevel.Error, Channel = EventChannel.Operational, Version = 4)] | ||
public void RaiseFunctionsEventError(string SubscriptionId, string AppName, string FunctionName, string EventName, string Source, string Details, string Summary, string HostVersion, string EventTimestamp, string InnerExceptionType, string InnerExceptionMessage, string FunctionInvocationId, string HostInstanceId) | ||
{ | ||
if (IsEnabled()) | ||
{ | ||
WriteEvent(65523, SubscriptionId, AppName, FunctionName, EventName, Source, Details, Summary, HostVersion, EventTimestamp, InnerExceptionType, InnerExceptionMessage, FunctionInvocationId, HostInstanceId); | ||
} | ||
} | ||
|
||
[Event(65524, Level = EventLevel.Informational, Channel = EventChannel.Operational, Version = 4)] | ||
[SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly")] | ||
[SuppressMessage("Microsoft.Design", "CA1030:UseEventsWhereAppropriate")] | ||
public void LogFunctionMetricEvent(string SubscriptionId, string AppName, string FunctionName, string EventName, long Average, long Minimum, long Maximum, long Count, string HostVersion, string EventTimestamp) | ||
{ | ||
if (IsEnabled()) | ||
{ | ||
WriteEvent(65524, SubscriptionId, AppName, FunctionName, EventName, Average, Minimum, Maximum, Count, HostVersion, EventTimestamp); | ||
} | ||
} | ||
|
||
public void SetActivityId(string activityId) | ||
{ | ||
Guid guid; | ||
if (!string.IsNullOrEmpty(activityId) && Guid.TryParse(activityId, out guid)) | ||
{ | ||
SetCurrentThreadActivityId(guid); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.