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

Refactoring #1

Merged
merged 3 commits into from
Oct 12, 2024
Merged
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
4,593 changes: 1 addition & 4,592 deletions .editorconfig

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions Amarok.Diagnostics.v3.ncrunchsolution
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<SolutionConfiguration>
<Settings>
<AllowParallelTestExecution>True</AllowParallelTestExecution>
<EnableRDI>False</EnableRDI>
<RdiConfigured>True</RdiConfigured>
<SolutionConfigured>True</SolutionConfigured>
</Settings>
</SolutionConfiguration>
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</PropertyGroup>

<ItemGroup>
<None Include="..\amarok.png" Pack="True" PackagePath="\"/>
<None Include="..\amarok.png" Pack="True" PackagePath="\" />
</ItemGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion nuget.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json"/>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0"/>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Amarok.Diagnostics.Persistence.OpenTelementry.Exporter\Amarok.Diagnostics.Persistence.OpenTelementry.Exporter.csproj"/>
<ProjectReference Include="..\Amarok.Diagnostics.Persistence.OpenTelementry.Exporter\Amarok.Diagnostics.Persistence.OpenTelementry.Exporter.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<ProjectConfiguration>
<Settings>
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely>
</Settings>
</ProjectConfiguration>
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ internal class Program
public static void Main()
{
if (Directory.Exists(OutputDir))
{
Directory.Delete(OutputDir, true);
}

_Writing();
_Reading();
Expand Down Expand Up @@ -86,9 +84,7 @@ private static void _Writing()
activity3?.Dispose();

if (i == 500000)
{
context.Exporter.HotExportAsync(Path.Combine("..", "..", "..", "traces", "export.zip"));
}
}

provider?.Dispose();
Expand Down Expand Up @@ -149,9 +145,7 @@ public void OnBeginReadFrame(Byte[] buffer, Int32 frameLen)
public void OnReadRecord(TraceRecord record)
{
if (record.DataCase != TraceRecord.DataOneofCase.Activity)
{
Console.WriteLine($" RECORD: {record.DataCase}");
}
}

public void OnReadActivity(ActivityInfo activity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0"/>
<PackageReference Include="NFluent" Version="3.0.4"/>
<PackageReference Include="NFluent.Analyzer" Version="0.1.0"/>
<PackageReference Include="NUnit" Version="4.1.0"/>
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0"/>
<PackageReference Include="NUnit.Analyzers" Version="4.2.0">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="NFluent" Version="3.0.4" />
<PackageReference Include="NFluent.Analyzer" Version="0.1.0" />
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -21,7 +21,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Amarok.Diagnostics.Persistence.OpenTelementry.Exporter\Amarok.Diagnostics.Persistence.OpenTelementry.Exporter.csproj"/>
<ProjectReference Include="..\Amarok.Diagnostics.Persistence.OpenTelementry.Exporter\Amarok.Diagnostics.Persistence.OpenTelementry.Exporter.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ public void Cleanup()
mDirectory.Refresh();

if (mDirectory.Exists)
{
mDirectory.Delete(true);
}
}


Expand All @@ -57,7 +55,9 @@ public void UseCase_Single_Activity_Single_Source()
{
// arrange
var options = new AdtxTraceExporterOptions(mDirectory) {
WriterOptions = new TraceWriterOptions { MaxDiskSpaceUsedInMegaBytes = 100 },
WriterOptions = new TraceWriterOptions {
MaxDiskSpaceUsedInMegaBytes = 100,
},
};

// act writing
Expand Down Expand Up @@ -120,7 +120,9 @@ public void UseCase_Many_Activity_Single_Source()
{
// arrange
var options = new AdtxTraceExporterOptions(mDirectory) {
WriterOptions = new TraceWriterOptions { MaxDiskSpaceUsedInMegaBytes = 100 },
WriterOptions = new TraceWriterOptions {
MaxDiskSpaceUsedInMegaBytes = 100,
},
};

// act writing
Expand Down Expand Up @@ -186,7 +188,9 @@ public async Task UseCase_Many_Activity_Single_Source_Single_Export()
{
// arrange
var options = new AdtxTraceExporterOptions(mDirectory) {
WriterOptions = new TraceWriterOptions { MaxDiskSpaceUsedInMegaBytes = 100 },
WriterOptions = new TraceWriterOptions {
MaxDiskSpaceUsedInMegaBytes = 100,
},
};

// act writing
Expand All @@ -211,9 +215,7 @@ public async Task UseCase_Many_Activity_Single_Source_Single_Export()
}

if (i == 3333)
{
await ctx.Exporter.HotExportAsync(Path.Combine(mDirectory.FullName, "export.zip"));
}
}

provider?.ForceFlush();
Expand Down Expand Up @@ -259,7 +261,9 @@ public async Task UseCase_Many_Activity_Single_Source_Many_Export()
{
// arrange
var options = new AdtxTraceExporterOptions(mDirectory) {
WriterOptions = new TraceWriterOptions { MaxDiskSpaceUsedInMegaBytes = 100 },
WriterOptions = new TraceWriterOptions {
MaxDiskSpaceUsedInMegaBytes = 100,
},
};

// act writing
Expand All @@ -284,9 +288,7 @@ public async Task UseCase_Many_Activity_Single_Source_Many_Export()
}

if (i % 1000 == 0)
{
await ctx.Exporter.HotExportAsync(Path.Combine(mDirectory.FullName, "export.zip"));
}
}

provider?.ForceFlush();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1"/>
<PackageReference Include="OpenTelemetry" Version="1.9.0"/>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.2" />
<PackageReference Include="OpenTelemetry" Version="1.9.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Amarok.Diagnostics.Persistence.Tracing\Amarok.Diagnostics.Persistence.Tracing.csproj"/>
<ProjectReference Include="..\Amarok.Diagnostics.Persistence.Tracing\Amarok.Diagnostics.Persistence.Tracing.csproj" />
</ItemGroup>

<ItemGroup>
<InternalsVisibleTo Include="$(TargetName).Tests"/>
<InternalsVisibleTo Include="$(TargetName).Tests" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -43,33 +43,25 @@ protected override Boolean OnForceFlush(Int32 timeoutMilliseconds)
protected override Boolean OnShutdown(Int32 timeoutMilliseconds)
{
if (mWriter == null)
{
return true;
}

var snapshotTask = mSnapshotTask;

if (snapshotTask != null && !snapshotTask.IsCompleted)
{
snapshotTask.GetAwaiter().GetResult();
}

var task = mWriter.DisposeAsync();

if (!task.IsCompleted)
{
task.AsTask().Wait();
}

return true;
}

public override ExportResult Export(in Batch<Activity> batch)
{
if (mWriter == null)
{
return ExportResult.Success;
}

mSnapshotBarrier.Wait();

Expand All @@ -85,9 +77,7 @@ public override ExportResult Export(in Batch<Activity> batch)
var task = mWriter.FlushAsync();

if (!task.IsCompleted)
{
task.AsTask().Wait();
}

return ExportResult.Success;
}
Expand All @@ -104,16 +94,12 @@ public override ExportResult Export(in Batch<Activity> batch)
public async Task HotExportAsync(String archivePath)
{
if (mIsSnapshotRunning)
{
throw new InvalidOperationException("Another snapshot operation is pending.");
}

var writer = mWriter;

if (writer == null)
{
throw new InvalidOperationException("Not initialized or already disposed.");
}

try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ namespace Amarok.Diagnostics.Persistence.OpenTelementry.Exporter;
public sealed class AdtxTraceExporterOptions
{
/// <summary>
/// The directory used for storing rolling trace log files (.adtx). The directory gets created if it doesn't exist.
/// The directory used for storing rolling trace log files (.adtx). The directory gets created if it doesn't
/// exist.
/// </summary>
public DirectoryInfo Directory { get; }

Expand All @@ -27,8 +28,8 @@ public sealed class AdtxTraceExporterOptions
/// </summary>
///
/// <param name="directoryPath">
/// The path to the directory used for storing rolling trace log files (.adtx). The directory gets created if it
/// doesn't exist.
/// The path to the directory used for storing rolling trace log files (.adtx). The directory gets created if
/// it doesn't exist.
/// </param>
public AdtxTraceExporterOptions(String directoryPath)
{
Expand All @@ -40,7 +41,8 @@ public AdtxTraceExporterOptions(String directoryPath)
/// </summary>
///
/// <param name="directory">
/// The directory used for storing rolling trace log files (.adtx). The directory gets created if it doesn't exist.
/// The directory used for storing rolling trace log files (.adtx). The directory gets created if it doesn't
/// exist.
/// </param>
public AdtxTraceExporterOptions(DirectoryInfo directory)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ public static TracerProviderBuilder AddAdtxTraceExporter(
)
: new SimpleActivityExportProcessor(exporter);

context = new AdtxTraceExporterContext { Exporter = exporter };
context = new AdtxTraceExporterContext {
Exporter = exporter,
};

return builder.AddProcessor(processor);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ namespace Amarok.Diagnostics.Persistence.OpenTelementry.Exporter;
public interface IAdtxTraceExporter
{
/// <summary>
/// Exports all trace log files into a Zip file at the given location. This method can be invoked at any time.
/// Exports all trace log files into a Zip file at the given location. This method can be invoked at any
/// time.
/// </summary>
/// <param name="archivePath">
/// The path to the output Zip file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0"/>
<PackageReference Include="NFluent" Version="3.0.4"/>
<PackageReference Include="NFluent.Analyzer" Version="0.1.0"/>
<PackageReference Include="NUnit" Version="4.1.0"/>
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0"/>
<PackageReference Include="NUnit.Analyzers" Version="4.2.0">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="NFluent" Version="3.0.4" />
<PackageReference Include="NFluent.Analyzer" Version="0.1.0" />
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -21,7 +21,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Amarok.Diagnostics.Persistence.Tracing\Amarok.Diagnostics.Persistence.Tracing.csproj"/>
<ProjectReference Include="..\Amarok.Diagnostics.Persistence.Tracing\Amarok.Diagnostics.Persistence.Tracing.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ public void Cleanup()
mDirectory.Refresh();

if (mDirectory.Exists)
{
mDirectory.Delete(true);
}
}


Expand Down
Loading