Skip to content

Commit 90555a5

Browse files
authored
Merge pull request #124 from homiedopie/feature/DOTNET-105
DOTNET-105 - Add helper for profiler environment and app name
2 parents d141b67 + c8488b1 commit 90555a5

File tree

11 files changed

+102
-16
lines changed

11 files changed

+102
-16
lines changed

Src/FFWebApp462/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<package id="Antlr" version="3.5.0.2" targetFramework="net462" />
44
<package id="bootstrap" version="3.4.1" targetFramework="net462" />
55
<package id="jQuery" version="3.3.1" targetFramework="net462" />
6-
<package id="log4net" version="2.0.8" targetFramework="net462" />
6+
<package id="log4net" version="2.0.11" targetFramework="net462" />
77
<package id="Microsoft.AspNet.Mvc" version="5.2.4" targetFramework="net462" />
88
<package id="Microsoft.AspNet.Razor" version="3.2.4" targetFramework="net462" />
99
<package id="Microsoft.AspNet.TelemetryCorrelation" version="1.0.0" targetFramework="net462" />
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="log4net" version="2.0.0" targetFramework="net40" />
3+
<package id="log4net" version="2.0.11" targetFramework="net40" />
44
</packages>

Src/StackifyLib.log4net.Tests/StackifyLib.log4net.Tests.csproj

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\packages\NUnit.3.13.2\build\NUnit.props" Condition="Exists('..\packages\NUnit.3.13.2\build\NUnit.props')" />
34
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
45
<PropertyGroup>
56
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -11,6 +12,8 @@
1112
<AssemblyName>StackifyLib.log4net.Tests</AssemblyName>
1213
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
1314
<FileAlignment>512</FileAlignment>
15+
<NuGetPackageImportStamp>
16+
</NuGetPackageImportStamp>
1417
</PropertyGroup>
1518
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1619
<DebugSymbols>true</DebugSymbols>
@@ -30,20 +33,19 @@
3033
<WarningLevel>4</WarningLevel>
3134
</PropertyGroup>
3235
<ItemGroup>
33-
<Reference Include="log4net, Version=1.2.11.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
34-
<HintPath>..\packages\log4net.2.0.0\lib\net40-full\log4net.dll</HintPath>
35-
<Private>True</Private>
36+
<Reference Include="log4net, Version=2.0.11.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
37+
<HintPath>..\packages\log4net.2.0.11\lib\net45\log4net.dll</HintPath>
3638
</Reference>
37-
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
38-
<HintPath>..\packages\Newtonsoft.Json.6.0.6\lib\net45\Newtonsoft.Json.dll</HintPath>
39-
<Private>True</Private>
39+
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
40+
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
4041
</Reference>
41-
<Reference Include="nunit.framework, Version=3.0.5813.39031, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
42-
<HintPath>..\packages\NUnit.3.0.1\lib\net45\nunit.framework.dll</HintPath>
43-
<Private>True</Private>
42+
<Reference Include="nunit.framework, Version=3.13.2.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
43+
<HintPath>..\packages\NUnit.3.13.2\lib\net45\nunit.framework.dll</HintPath>
4444
</Reference>
4545
<Reference Include="System" />
46+
<Reference Include="System.Configuration" />
4647
<Reference Include="System.Core" />
48+
<Reference Include="System.Web" />
4749
<Reference Include="System.Xml.Linq" />
4850
<Reference Include="System.Data.DataSetExtensions" />
4951
<Reference Include="Microsoft.CSharp" />
@@ -69,6 +71,12 @@
6971
</ProjectReference>
7072
</ItemGroup>
7173
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
74+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
75+
<PropertyGroup>
76+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
77+
</PropertyGroup>
78+
<Error Condition="!Exists('..\packages\NUnit.3.13.2\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit.3.13.2\build\NUnit.props'))" />
79+
</Target>
7280
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
7381
Other similar extension points exist, see Microsoft.Common.targets.
7482
<Target Name="BeforeBuild">
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="log4net" version="2.0.0" targetFramework="net452" />
4-
<package id="Newtonsoft.Json" version="6.0.6" targetFramework="net452" />
5-
<package id="NUnit" version="3.0.1" targetFramework="net452" />
3+
<package id="log4net" version="2.0.11" targetFramework="net452" />
4+
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net452" />
5+
<package id="NUnit" version="3.13.2" targetFramework="net452" />
66
</packages>

Src/StackifyLib.log4net/StackifyLib.log4net.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
</ItemGroup>
2727

2828
<ItemGroup>
29-
<PackageReference Include="log4net" Version="2.0.8" />
29+
<PackageReference Include="log4net" Version="2.0.11" />
3030
<Reference Include="Microsoft.CSharp" />
3131
</ItemGroup>
3232

Src/StackifyLib/ProfileTracer.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,5 +380,15 @@ private void ExecInternalComplete2(string values)
380380
{
381381

382382
}
383+
384+
[MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
385+
public static void SetEnvironmentName(string environmentName)
386+
{
387+
}
388+
389+
[MethodImpl(MethodImplOptions.PreserveSig | MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
390+
public static void SetApplicationName(string applicationName)
391+
{
392+
}
383393
}
384394
}

Src/StackifyLibCore.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FullFrameworkWebApp", "Full
4242
{03CF7411-65E2-4998-A157-9224ECA6199B} = {03CF7411-65E2-4998-A157-9224ECA6199B}
4343
EndProjectSection
4444
EndProject
45+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StackifyLib.log4net.Tests", "StackifyLib.log4net.Tests\StackifyLib.log4net.Tests.csproj", "{18F96933-468E-4104-961E-0C68A5EF2B29}"
46+
EndProject
4547
Global
4648
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4749
Debug|Any CPU = Debug|Any CPU
@@ -108,6 +110,10 @@ Global
108110
{EC5742DF-C1A8-4A7A-81DC-B6E0A4D3472D}.Debug|Any CPU.Build.0 = Debug|Any CPU
109111
{EC5742DF-C1A8-4A7A-81DC-B6E0A4D3472D}.Release|Any CPU.ActiveCfg = Release|Any CPU
110112
{EC5742DF-C1A8-4A7A-81DC-B6E0A4D3472D}.Release|Any CPU.Build.0 = Release|Any CPU
113+
{18F96933-468E-4104-961E-0C68A5EF2B29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
114+
{18F96933-468E-4104-961E-0C68A5EF2B29}.Debug|Any CPU.Build.0 = Debug|Any CPU
115+
{18F96933-468E-4104-961E-0C68A5EF2B29}.Release|Any CPU.ActiveCfg = Release|Any CPU
116+
{18F96933-468E-4104-961E-0C68A5EF2B29}.Release|Any CPU.Build.0 = Release|Any CPU
111117
EndGlobalSection
112118
GlobalSection(SolutionProperties) = preSolution
113119
HideSolutionNode = FALSE
@@ -127,6 +133,7 @@ Global
127133
{ADBD2138-9DE7-4211-AF58-84C7F0F9BEA5} = {CA786C31-57B0-4FA4-919D-8B24D2FBCDCB}
128134
{99C81723-20FB-4241-862C-32F7ADDB7A9B} = {CA786C31-57B0-4FA4-919D-8B24D2FBCDCB}
129135
{EC5742DF-C1A8-4A7A-81DC-B6E0A4D3472D} = {CA786C31-57B0-4FA4-919D-8B24D2FBCDCB}
136+
{18F96933-468E-4104-961E-0C68A5EF2B29} = {36B13547-8CBC-4985-9495-555500880F1D}
130137
EndGlobalSection
131138
GlobalSection(ExtensibilityGlobals) = postSolution
132139
SolutionGuid = {6AB55A24-BCFF-4641-90E0-7921CAD32F49}

samples/CoreConsoleApp/CoreConsoleApp.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
<PackageReference Include="System.Net.Sockets" Version="4.3.0" />
2929
</ItemGroup>
3030

31+
<ItemGroup>
32+
<None Update="Stackify.json">
33+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
34+
</None>
35+
</ItemGroup>
36+
3137
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
3238
<DefineConstants>NETCORE</DefineConstants>
3339
</PropertyGroup>

samples/CoreConsoleApp/Program.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,38 @@ static void Main(string[] args)
4040
Console.WriteLine($"Stackify Config AppName: {StackifyLib.Config.AppName}");
4141
Console.WriteLine($"Stackify Config EnvironmentName: {StackifyLib.Config.Environment}");
4242
Console.WriteLine($"Stackify Config ApiKey: {StackifyLib.Config.ApiKey}");
43+
44+
StackifyLib.ProfileTracer.SetApplicationName("Test Name 2");
45+
StackifyLib.ProfileTracer.SetEnvironmentName("Test Environment 2");
46+
47+
var tracer = StackifyLib.ProfileTracer.CreateAsOperation("Operation Name", Trace.CorrelationManager.ActivityId.ToString());
48+
tracer.Exec(() => //FYI, async code is also supported via tracer.ExecAsync()
49+
{
50+
//Do some stuff here
51+
Task.Delay(1000).GetAwaiter().GetResult();
52+
Console.WriteLine($"StackifyLib Operation");
53+
});
54+
55+
StackifyLib.ProfileTracer.SetApplicationName("Test Name 3");
56+
StackifyLib.ProfileTracer.SetEnvironmentName("Test Environment 3");
57+
58+
TestInstrument();
4359
StackifyLib.Logger.Shutdown(); //best practice for console apps
60+
Console.ReadLine();
4461
}
4562

63+
private static void TestInstrument()
64+
{
65+
Task.Delay(1000).GetAwaiter().GetResult();
66+
Console.WriteLine($"Custom Operation");
67+
TestInstrumentNested();
68+
}
69+
70+
private static void TestInstrumentNested()
71+
{
72+
Task.Delay(1000).GetAwaiter().GetResult();
73+
Console.WriteLine($"Custom Operation Nested");
74+
}
4675

4776
private static void NLogTest()
4877
{
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"profiles": {
3+
"CoreConsoleApp": {
4+
"commandName": "Project",
5+
"environmentVariables": {
6+
"COR_ENABLE_PROFILING": "1",
7+
"CORECLR_ENABLE_PROFILING": "1"
8+
}
9+
}
10+
}
11+
}

0 commit comments

Comments
 (0)