in src/ServiceProfiler.EventPipe.Otel/Microsoft.ApplicationInsights.Profiler.Shared/Contracts/SampleActivity.cs [83:102]
private bool IsGoodActivityIdPath(string? activityId, ILogger logger)
{
if (string.IsNullOrEmpty(activityId))
{
logger?.LogTrace("Invalid activity id path. Activity id is empty.");
return false;
}
// TODO: pay attention to the performance of the regular expression. Refactor it when time permits.
// Exclude activity id in form of: /#1503500717/
Regex regex = _validActivityIdPathRegex;
if (regex.IsMatch(activityId))
{
logger?.LogTrace("Activity id {0} doesn't match regex: {1}", activityId, regex);
return false;
}
// Passed all validation
return true;
}