Skip to content
This repository has been archived by the owner on Jun 2, 2022. It is now read-only.

Minor changes to the internal implementation of TimedTelemetryEvent. #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 2 additions & 4 deletions src/Eshopworld.Core/Eshopworld.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>

<Version>2.1.1</Version>
<Version>2.1.2</Version>
<PackageReleaseNotes>declare friendship to eshopworld.web (including tests)</PackageReleaseNotes>

<TargetFramework>netstandard2.0</TargetFramework>
Expand All @@ -16,7 +16,7 @@
<PackageProjectUrl>https://github.com/eShopWorld/core</PackageProjectUrl>
<Description>eShopWorld core package</Description>
<Product>Eshopworld.Core</Product>
<Copyright>Copyright 2018</Copyright>
<Copyright>Copyright 2019</Copyright>
<PackageTags>Eshopworld, Telemetry, Core</PackageTags>

<IncludeSource>True</IncludeSource>
Expand All @@ -26,12 +26,10 @@

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath>bin\Debug\</OutputPath>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<OutputPath>bin\Release\</OutputPath>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions src/Eshopworld.Core/TimedTelemetryEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class TimedTelemetryEvent : TelemetryEvent
/// The START time for this event.
/// </summary>
[JsonIgnore]
internal DateTime StartTime = DateTimeNow.Invoke();
internal DateTime StartTime = DateTimeNow();

/// <summary>
/// The END time for thie event.
Expand All @@ -23,15 +23,15 @@ public class TimedTelemetryEvent : TelemetryEvent

/// <summary>
/// Gets the total elapsed processing time.
/// If End() hasn't been called it will use <see cref="DateTime.Now"/> as the current end time without setting an EndTime.
/// If End() hasn't been called it will use current time as the end time without setting an EndTime.
/// </summary>
[JsonIgnore]
public TimeSpan ProcessingTime => EndTime?.Subtract(StartTime) ?? DateTimeNow.Invoke().Subtract(StartTime);
public TimeSpan ProcessingTime => (EndTime ?? DateTimeNow()).Subtract(StartTime);

/// <summary>
/// testability delegate so that we have full control over timing aspects
/// </summary>
internal static Func<DateTime> DateTimeNow { get; set; } = () => DateTime.Now;
internal static Func<DateTime> DateTimeNow { get; set; } = () => DateTime.UtcNow;

/// <summary>
/// Ends the event by marking that the process it's tracking has finished.
Expand All @@ -40,7 +40,7 @@ public void End()
{
if (EndTime == null)
{
EndTime = DateTimeNow.Invoke();
EndTime = DateTimeNow();
}
}
}
Expand Down