@ -17,7 +17,7 @@ public class TelemetryApplicationInfoEnricher : ITelemetryActivityDataEnricher,
public TelemetryApplicationInfoEnricher (
public TelemetryApplicationInfoEnricher (
ITelemetrySessionTypeProvider telemetrySessionTypeProvider ,
ITelemetrySessionTypeProvider telemetrySessionTypeProvider ,
IEnumerable < ITelemetryApplicationInfoContributor > telemetryApplicationInfoContributors ,
IEnumerable < ITelemetryApplicationInfoContributor > telemetryApplicationInfoContributors ,
ITelemetryActivityStorage telemetryActivityStorage )
ITelemetryActivityStorage telemetryActivityStorage )
{
{
_ telemetrySessionTypeProvider = telemetrySessionTypeProvider ;
_ telemetrySessionTypeProvider = telemetrySessionTypeProvider ;
@ -45,7 +45,11 @@ public class TelemetryApplicationInfoEnricher : ITelemetryActivityDataEnricher,
return ;
return ;
}
}
await ContributeApplicationInfoAsync ( activity ) ;
foreach ( var contributor in _ telemetryApplicationInfoContributors )
{
await contributor . ContributeAsync ( activity ) ;
}
activity . Remove ( ActivityPropertyNames . Assembly ) ;
activity . Remove ( ActivityPropertyNames . Assembly ) ;
await _ telemetryActivityStorage . MarkApplicationInfoAsAddedAsync ( projectId . Value ) ;
await _ telemetryActivityStorage . MarkApplicationInfoAsAddedAsync ( projectId . Value ) ;
}
}
@ -57,14 +61,14 @@ public class TelemetryApplicationInfoEnricher : ITelemetryActivityDataEnricher,
private bool ShouldEnrichActivity ( ActivityData activity )
private bool ShouldEnrichActivity ( ActivityData activity )
{
{
return activity . ContainsKey ( ActivityPropertyNames . Assembly ) & &
return activity . ContainsKey ( ActivityPropertyNames . Assembly ) & &
_ telemetrySessionTypeProvider . SessionType = = SessionType . ApplicationRuntime ;
_ telemetrySessionTypeProvider . SessionType = = SessionType . ApplicationRuntime ;
}
}
private static Guid ? ExtractProjectId ( ActivityData activity )
private static Guid ? ExtractProjectId ( ActivityData activity )
{
{
if ( ! activity . TryGetValue ( ActivityPropertyNames . ProjectId , out var projectIdObj ) | |
if ( ! activity . TryGetValue ( ActivityPropertyNames . ProjectId , out var projectIdObj ) | |
projectIdObj is not string projectIdStr | |
projectIdObj is not string projectIdStr | |
! Guid . TryParse ( projectIdStr , out var projectId ) )
! Guid . TryParse ( projectIdStr , out var projectId ) )
{
{
return null ;
return null ;
@ -72,19 +76,4 @@ public class TelemetryApplicationInfoEnricher : ITelemetryActivityDataEnricher,
return projectId ;
return projectId ;
}
}
private async Task ContributeApplicationInfoAsync ( ActivityData activity )
{
foreach ( var contributor in _ telemetryApplicationInfoContributors )
{
try
{
await contributor . ContributeAsync ( activity ) ;
}
catch
{
// ignored
}
}
}
}
}