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

Update start stop activity computer to support OpenTelemetry-Sdk EventSource #2139

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion src/TraceEvent/Computers/StartStopActivityComputer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ public StartStopActivityComputer(TraceLogEventSource source, ActivityComputer ta
}
}
#endif

// TODO decide what the correct heuristic for deciding what start-stop events are interesting.
// Currently I only do this for things that might be an EventSource
if (!TraceEventProviders.MaybeAnEventSource(data.ProviderGuid))
Expand Down Expand Up @@ -176,6 +177,11 @@ public StartStopActivityComputer(TraceLogEventSource source, ActivityComputer ta
{
FixAndProcessAdoNetEvents(data);
}
// Special case - OpenTelemetry-Sdk
else if (data.Opcode == TraceEventOpcode.Info && data.providerGuid == OpenTelemetrySdkProvider)
{
FixAndProcessAzureMonitorOpenTelemetryEvents(data);
}

return;
}
Expand Down Expand Up @@ -710,7 +716,7 @@ internal static unsafe string CreateActivityPathString(Guid guid)
{
uint nibble = (uint)(*bytePtr >> 4);
bool secondNibble = false; // are we reading the second nibble (low order bits) of the byte.
NextNibble:
NextNibble:
if (nibble == (uint)NumberListCodes.End)
{
break;
Expand Down Expand Up @@ -802,6 +808,7 @@ internal static unsafe string CreateActivityPathString(Guid guid)
private static readonly Guid AdoNetProvider = new Guid("6a4dfe53-eb50-5332-8473-7b7e10a94fd1");
private static readonly Guid MicrosoftWindowsHttpService = new Guid("dd5ef90a-6398-47a4-ad34-4dcecdef795f");
private static readonly Guid MicrosoftDiagnosticsDiagnosticSourceProvider = new Guid("ADB401E1-5296-51F8-C125-5FDA75826144");
private static readonly Guid OpenTelemetrySdkProvider = new Guid("af2d5796-946b-50cb-5f76-166a609afcbb");

// EventSourceName: Microsoft-ApplicationInsights-Data
// Reference for definition: https://raw.githubusercontent.com/Microsoft/ApplicationInsights-dotnet/e8f047f6e48abae0e88a9c77bf65df858c442940/src/Microsoft.ApplicationInsights/Extensibility/Implementation/RichPayloadEventSource.cs
Expand Down Expand Up @@ -1131,6 +1138,20 @@ private bool TryProcessDiagnosticSourceStartEvents(TraceEvent data)
return false;
}

private void FixAndProcessAzureMonitorOpenTelemetryEvents(TraceEvent data)
xiaomi7732 marked this conversation as resolved.
Show resolved Hide resolved
{
Debug.Assert(data.ProviderGuid == OpenTelemetrySdkProvider);
if (data.EventName == "ActivityStarted")
{
string extraInfo = (string)data.PayloadByName("id");
OnStart(data, extraInfo);
}
else if (data.EventName == "ActivityStopped")
{
OnStop(data);
}
}

private void FixAndProcessAppInsightsEvents(TraceEvent data)
{
Debug.Assert(data.ProviderGuid == MicrosoftApplicationInsightsDataProvider);
Expand Down