Skip to content

Commit

Permalink
Remove ActivityId from HostingLogScope
Browse files Browse the repository at this point in the history
  • Loading branch information
shirhatti committed May 29, 2020
1 parent 9c40ed7 commit 3fdc3f6
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/Hosting/Hosting/src/Internal/HostingLoggerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal static class HostingLoggerExtensions
{
public static IDisposable RequestScope(this ILogger logger, HttpContext httpContext, string activityId)
{
return logger.BeginScope(new HostingLogScope(httpContext, activityId));
return logger.BeginScope(new HostingLogScope(httpContext));
}

public static void ApplicationError(this ILogger logger, Exception exception)
Expand Down Expand Up @@ -96,15 +96,14 @@ private class HostingLogScope : IReadOnlyList<KeyValuePair<string, object>>
{
private readonly string _path;
private readonly string _traceIdentifier;
private readonly string _activityId;

private string _cachedToString;

public int Count
{
get
{
return 3;
return 2;
}
}

Expand All @@ -120,22 +119,17 @@ public KeyValuePair<string, object> this[int index]
{
return new KeyValuePair<string, object>("RequestPath", _path);
}
else if (index == 2)
{
return new KeyValuePair<string, object>("ActivityId", _activityId);
}

throw new ArgumentOutOfRangeException(nameof(index));
}
}

public HostingLogScope(HttpContext httpContext, string activityId)
public HostingLogScope(HttpContext httpContext)
{
_traceIdentifier = httpContext.TraceIdentifier;
_path = (httpContext.Request.PathBase.HasValue
? httpContext.Request.PathBase + httpContext.Request.Path
: httpContext.Request.Path).ToString();
_activityId = activityId;
}

public override string ToString()
Expand All @@ -144,10 +138,9 @@ public override string ToString()
{
_cachedToString = string.Format(
CultureInfo.InvariantCulture,
"RequestPath:{0} RequestId:{1}, ActivityId:{2}",
"RequestPath:{0} RequestId:{1}",
_path,
_traceIdentifier,
_activityId);
_traceIdentifier);
}

return _cachedToString;
Expand Down

0 comments on commit 3fdc3f6

Please sign in to comment.