├── EnlistmentRoot.marker
├── LOGGING
├── .gitattributes
├── .gitignore
├── 35MSSharedLib1024.snk
├── AddXmlLanguage.targets
├── ApplicationInsightsSDKRules.ruleset
├── CHANGELOG.md
├── CodeCov.ps1
├── Common.props
├── Common.targets
├── Directory.Build.props
├── GenerateReleaseMetadata.ps1
├── GlobalStaticVersion.props
├── HelloWorldTest
│ ├── HelloWorld.Tests.csproj
│ ├── README.md
│ ├── UnitTest1.cs
│ └── packages.config
├── LICENSE
├── Logging.sln
├── Microsoft-Security-Recommended.ruleset
├── NuGet.Config
├── NuGet.exe
├── NugetAudit.ps1
├── Nupkg.props
├── PushNugetPackages.cmd
├── README.md
├── SDL
│ ├── BinSkimSetup.ps1
│ └── FxCopSetup.ps1
├── Signing.targets
├── SourceRoot.marker
├── Test.props
├── ThirdPartyNotices.txt
├── VSOPushNugetPackages.cmd
├── buildDebug.cmd
├── buildRelease.cmd
├── clean.cmd
├── dirs.proj
├── disablestrongnamevalidation.ps1
├── enablestrongnamevalidation.ps1
├── src
│ ├── CommonShared
│ │ ├── CommonShared.projitems
│ │ ├── CommonShared.shproj
│ │ └── SdkVersionUtils.cs
│ ├── DiagnosticSourceListener
│ │ ├── ApplicationInsights.config.install.xdt
│ │ ├── ApplicationInsights.config.uninstall.xdt
│ │ ├── DeclaredPropertiesCache.cs
│ │ ├── DiagnosticSourceListener.csproj
│ │ ├── DiagnosticSourceListenerSubscription.cs
│ │ ├── DiagnosticSourceListeningRequest.cs
│ │ └── DiagnosticSourceTelemetryModule.cs
│ ├── EtwCollector
│ │ ├── AITraceEventSession.cs
│ │ ├── ApplicationInsights.config.install.xdt
│ │ ├── ApplicationInsights.config.uninstall.xdt
│ │ ├── EtwCollector.csproj
│ │ ├── EtwListeningRequest.cs
│ │ ├── EtwTelemetryModule.cs
│ │ ├── ITraceEventSession.cs
│ │ ├── Implemenetation
│ │ │ └── TraceEventExtensions.cs
│ │ └── Properties
│ │ │ └── AssemblyInfo.cs
│ ├── EventSource.Shared
│ │ └── EventSource.Shared
│ │ │ ├── EventSource.Shared.projitems
│ │ │ ├── EventSource.Shared.shproj
│ │ │ ├── Implementation
│ │ │ └── EventSourceListenerEventSource.cs
│ │ │ └── Utilities
│ │ │ ├── ActivityPathDecoder.cs
│ │ │ ├── StringBuilderCache.cs
│ │ │ └── TplActivities.cs
│ ├── EventSourceListener
│ │ ├── ApplicationInsights.config.install.xdt
│ │ ├── ApplicationInsights.config.uninstall.xdt
│ │ ├── DisableEventSourceRequest.cs
│ │ ├── EventSourceListener.csproj
│ │ ├── EventSourceListeningRequest.cs
│ │ ├── EventSourceListeningRequestBase.cs
│ │ ├── EventSourceTelemetryModule.cs
│ │ ├── Implementation
│ │ │ └── EventDataExtensions.cs
│ │ └── Properties
│ │ │ └── AssemblyInfo.cs
│ ├── ILogger
│ │ ├── ApplicationInsightsLogger.cs
│ │ ├── ApplicationInsightsLoggerOptions.cs
│ │ ├── ApplicationInsightsLoggerProvider.cs
│ │ ├── ApplicationInsightsLoggingBuilderExtensions.cs
│ │ ├── ILogger.csproj
│ │ ├── NullScope.cs
│ │ └── Readme.md
│ ├── Log4NetAppender
│ │ ├── ApplicationInsightsAppender.cs
│ │ ├── AssemblyInfo.cs
│ │ ├── GlobalSuppressions.cs
│ │ ├── Log4NetAppender.csproj
│ │ ├── app.config.install.xdt
│ │ ├── app.config.uninstall.xdt
│ │ ├── web.config.install.xdt
│ │ └── web.config.uninstall.xdt
│ ├── NLogTarget
│ │ ├── ApplicationInsightsTarget.cs
│ │ ├── AssemblyInfo.cs
│ │ ├── NLogTarget.csproj
│ │ ├── TargetPropertyWithContext.cs
│ │ ├── app.config.install.xdt
│ │ ├── app.config.uninstall.xdt
│ │ ├── web.config.install.xdt
│ │ └── web.config.uninstall.xdt
│ ├── Product.props
│ └── TraceListener
│ │ ├── ApplicationInsightsTraceListener.cs
│ │ ├── AssemblyInfo.cs
│ │ ├── TraceListener.csproj
│ │ ├── app.config.install.xdt
│ │ ├── app.config.uninstall.xdt
│ │ ├── web.config.install.xdt
│ │ └── web.config.uninstall.xdt
└── test
│ ├── CommonTestShared
│ ├── CommonTestShared.projitems
│ ├── CommonTestShared.shproj
│ ├── SdkVersionHelper.cs
│ └── TelemetrySender.cs
│ ├── DiagnosticSourceListener.netcoreapp10.Tests
│ ├── DiagnosticSourceListener.netcoreapp1.Tests.csproj
│ ├── DiagnosticSourceTelemetryModuleTests.cs
│ └── TestDiagnosticSource.cs
│ ├── EtwCollector.Net451.Tests
│ ├── EtwCollector.Net451.Tests.csproj
│ ├── EtwTelemetryModuleTests.cs
│ ├── EventSourceModuleDiagnosticListener.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── TestProvider.cs
│ ├── TraceEventSessionMock.cs
│ └── TraceTelemetryComparer.cs
│ ├── EventSourceListener.netcoreapp10.Tests
│ ├── EventSourceListener.netcoreapp10.Tests.csproj
│ ├── EventSourceModuleDiagnosticListener.cs
│ ├── EventSourceTelemetryModuleTests.cs
│ ├── OtherTestEventSource.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── TestEventSource.cs
│ └── TraceTelemetryComparer.cs
│ ├── ILogger.NetStandard.Tests
│ ├── ILogger.NetStandard.Tests.csproj
│ ├── ILoggerIntegrationTests.cs
│ └── TestTelemetryProcessor.cs
│ ├── Log4NetAppender.Net45.Tests
│ ├── ApplicationInsightsAppenderTests.cs
│ ├── GlobalSuppressions.cs
│ ├── Log4NetAppender.Net45.Tests.csproj
│ └── Properties
│ │ └── AssemblyInfo.cs
│ ├── Log4NetAppender.NetCoreApp10.Tests
│ └── Log4NetAppender.NetCoreApp10.Tests.csproj
│ ├── NLogTarget.Net45.Tests
│ ├── NLogTarget.Net45.Tests.csproj
│ ├── NLogTargetTests.cs
│ └── Properties
│ │ └── AssemblyInfo.cs
│ ├── NLogTarget.NetCoreApp10.Tests
│ └── NLogTarget.NetCoreApp10.Tests.csproj
│ ├── Shared
│ ├── AdapterHelper.cs
│ ├── Adapters.Shared.Tests.projitems
│ ├── Adapters.Shared.Tests.shproj
│ ├── ApplicationInsightsTraceFilterTests.cs
│ ├── ApplicationInsightsTraceListenerTests.cs
│ ├── CustomTelemetryChannel.cs
│ └── ExceptionAssert.cs
│ ├── TraceListener.Net45.Tests
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── TraceEventOptionsMatrix.xml
│ ├── TraceFilterMatrix.xml
│ └── TraceListener.Net45.Tests.csproj
│ ├── TraceListener.netcoreapp10.Tests
│ └── TraceListener.netcoreapp10.Tests.csproj
│ └── Xdt.Tests
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── Resources
│ ├── DiagnosticSourceListener
│ │ └── TestDataSet.xml
│ ├── EtwCollector
│ │ └── TestDataSet.xml
│ ├── EventSourceListener
│ │ └── TestDataSet.xml
│ ├── Log4Net
│ │ └── TestDataSet.xml
│ ├── NLog
│ │ └── TestDataSet.xml
│ └── TraceListener
│ │ └── TestDataSet.xml
│ ├── Xdt.Tests.csproj
│ └── XdtTests.cs
└── README.md
/EnlistmentRoot.marker:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/ApplicationInsights-dotnet-logging/d19b91b607b490fb61648d719c45859bf5eb5489/EnlistmentRoot.marker
--------------------------------------------------------------------------------
/LOGGING/.gitattributes:
--------------------------------------------------------------------------------
1 | # Set the default behavior, in case people don't have core.autocrlf set.
2 | * text=auto
--------------------------------------------------------------------------------
/LOGGING/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.sln.docstates
8 | .vs
9 |
10 | # Build results
11 | [Dd]ebug/
12 | [Rr]elease/
13 | [Bb]in/
14 | [Oo]bj/
15 | [Oo]bj//Core/Javascript/ai*.[tj]s*
16 |
17 | # Telemetry output
18 | *.onesipkg
19 |
20 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
21 | !packages/*/build/
22 |
23 | # Project lock files in Visual Studio 2015
24 | project.lock.json
25 |
26 | # MSTest test Results
27 | [Tt]est[Rr]esult*/
28 | [Bb]uild[Ll]og.*
29 |
30 | *_i.c
31 | *_p.c
32 | *.ilk
33 | *.meta
34 | *.obj
35 | *.pch
36 | *.pdb
37 | *.pgc
38 | *.pgd
39 | *.rsp
40 | *.sbr
41 | *.tlb
42 | *.tli
43 | *.tlh
44 | *.tmp
45 | *.tmp_proj
46 | *.log
47 | *.vspscc
48 | *.vssscc
49 | .builds
50 | *.pidb
51 | *.log
52 | *.scc
53 |
54 | # Visual C++ cache files
55 | ipch/
56 | *.aps
57 | *.ncb
58 | *.opensdf
59 | *.sdf
60 | *.cachefile
61 |
62 | # Visual Studio profiler
63 | *.psess
64 | *.vsp
65 | *.vspx
66 |
67 | # Guidance Automation Toolkit
68 | *.gpState
69 |
70 | # ReSharper is a .NET coding add-in
71 | _ReSharper*/
72 | *.[Rr]e[Ss]harper
73 |
74 | # TeamCity is a build add-in
75 | _TeamCity*
76 |
77 | # DotCover is a Code Coverage Tool
78 | *.dotCover
79 |
80 | # NCrunch
81 | *.ncrunch*
82 | .*crunch*.local.xml
83 |
84 | # Installshield output folder
85 | [Ee]xpress/
86 |
87 | # DocProject is a documentation generator add-in
88 | DocProject/buildhelp/
89 | DocProject/Help/*.HxT
90 | DocProject/Help/*.HxC
91 | DocProject/Help/*.hhc
92 | DocProject/Help/*.hhk
93 | DocProject/Help/*.hhp
94 | DocProject/Help/Html2
95 | DocProject/Help/html
96 |
97 | # Click-Once directory
98 | publish/
99 |
100 | # Publish Web Output
101 | *.Publish.xml
102 |
103 | # NuGet binaries downloaded automatically
104 | packages/
105 |
106 | # Windows Azure Build Output
107 | csx
108 | *.build.csdef
109 |
110 | # Windows Store app package directory
111 | AppPackages/
112 |
113 | # Others
114 | sql/
115 | *.Cache
116 | ClientBin/
117 | [Ss]tyle[Cc]op.*
118 | ~$*
119 | *~
120 | *.dbmdl
121 | *.[Pp]ublish.xml
122 | *.publishsettings
123 |
124 | # RIA/Silverlight projects
125 | Generated_Code/
126 |
127 | # Backup & report files from converting an old project file to a newer
128 | # Visual Studio version. Backup files are not needed, because we have git ;-)
129 | _UpgradeReport_Files/
130 | Backup*/
131 | UpgradeLog*.XML
132 | UpgradeLog*.htm
133 |
134 | # SQL Server files
135 | App_Data/*.mdf
136 | App_Data/*.ldf
137 |
138 |
139 | #LightSwitch generated files
140 | GeneratedArtifacts/
141 | _Pvt_Extensions/
142 | ModelManifest.xml
143 |
144 | # =========================
145 | # Windows detritus
146 | # =========================
147 |
148 | # Windows image file caches
149 | Thumbs.db
150 | ehthumbs.db
151 |
152 | # Folder config file
153 | Desktop.ini
154 |
155 | # Recycle Bin used on file shares
156 | $RECYCLE.BIN/
157 |
158 | # Mac desktop service store files
159 | .DS_Store
160 |
161 | # Build log files
162 | *.err
163 | *.prf
164 | *.wrn
165 | *.vsix
166 | Web/PerformanceTests_Instrumented/
167 | .PreReleaseVersion
168 |
--------------------------------------------------------------------------------
/LOGGING/35MSSharedLib1024.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/ApplicationInsights-dotnet-logging/d19b91b607b490fb61648d719c45859bf5eb5489/LOGGING/35MSSharedLib1024.snk
--------------------------------------------------------------------------------
/LOGGING/AddXmlLanguage.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | f.ItemSpec))
15 | {
16 | Log.LogMessage("Fixing {0}", inputFilePath);
17 | string filePath = inputFilePath;
18 | if (filePath.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
19 | {
20 | filePath = filePath.Substring(0, filePath.Length - 3) + "xml";
21 | }
22 |
23 | if (filePath.EndsWith(".xml", StringComparison.OrdinalIgnoreCase))
24 | {
25 | string[] files = null;
26 | int starIndex = filePath.IndexOf('*');
27 | if (starIndex >= 0)
28 | {
29 | string dir = filePath.Substring(0, starIndex);
30 | if (string.IsNullOrEmpty(dir))
31 | {
32 | dir = ".";
33 | }
34 |
35 | string file = Path.GetFileName(filePath.Substring(starIndex));
36 | files = Directory.GetFiles(dir, file, SearchOption.AllDirectories);
37 | }
38 | else
39 | {
40 | files = new[] { filePath };
41 | }
42 |
43 | foreach (string fileName in files)
44 | {
45 | if (File.Exists(fileName))
46 | {
47 | Log.LogMessage("Processing XML: {0}", fileName);
48 | string text = File.ReadAllText(fileName);
49 | text = text.Replace("", "");
50 | File.WriteAllText(fileName, text);
51 | }
52 | }
53 | }
54 | }
55 | ]]>
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/LOGGING/CodeCov.ps1:
--------------------------------------------------------------------------------
1 | Param([String]$binRoot='..\bin', [String]$configuration='Release')
2 |
3 | #Run code coverage tests to generate report
4 | ..\packages\OpenCover.4.6.519\tools\OpenCover.Console.exe -register:user "-target:C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" "-targetargs:$binRoot\$configuration\src\Adapters.Tests\Log4NetAppender.Net45.Tests\Microsoft.ApplicationInsights.Log4NetAppender.Net45.Tests.dll $binRoot\$configuration\src\Adapters.Tests\NLogTarget.Net45.Tests\Microsoft.ApplicationInsights.NLogTarget.Net45.Tests.dll $binRoot\$configuration\src\Adapters.Tests\TraceListener.Net45.Tests\Microsoft.ApplicationInsights.TraceListener.Net45.Tests.dll $binRoot\$configuration\src\NuGet.Tests\Xdt.Tests\Xdt.Tests.dll /logger:trx" "-filter:+[Microsoft.ApplicationInsights*]* -[*Tests]*" -hideskipped:All -output:.\coverage.xml
5 |
6 | #Download report uploader
7 | (New-Object System.Net.WebClient).DownloadFile("https://codecov.io/bash", ".\CodecovUploader.sh")
8 |
9 | #On the Agent box repo is in a detached state. So get branchName by commit hash
10 | $lastCommit = $(git rev-parse HEAD)
11 | Write-Host "Last commit:" $lastCommit
12 |
13 | $branchNames = $(git branch --all --contains $lastCommit)
14 | Write-Host "All branches that have this commit:" $branchNames
15 |
16 | $i=0
17 | Foreach ($branchName in $branchNames)
18 | {
19 | $i++
20 | # First element in the array is trash because repo is detached
21 | if ($i -gt 1)
22 | {
23 | $branchName = $branchName.Trim()
24 | # Check for what branches current commit (for which we have coverage) is the last commit
25 | $lastCommitOnBranch = $(git rev-parse $branchName)
26 | if ($lastCommitOnBranch -eq $lastCommit)
27 | {
28 | #Cut the prefix that CodeCov does not handle well
29 | if ($branchName.StartsWith("remotes/origin/"))
30 | {
31 | $branchName = $branchName.Substring("remotes/origin/".Length)
32 | }
33 | Write-Host "We will upload report to:" $branchName
34 |
35 | #Upload report
36 | .\CodecovUploader.sh -f coverage.xml -t $env:CODECOVACCESSKEY -X gcov -B $branchName
37 | }
38 | }
39 | }
40 |
41 |
--------------------------------------------------------------------------------
/LOGGING/Common.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | prompt
5 | 4
6 |
7 |
8 |
9 | $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'ApplicationInsightsSDKRules.ruleset'))\ApplicationInsightsSDKRules.ruleset
10 |
11 |
12 |
13 | true
14 | full
15 | false
16 | $(DefineConstants);DEBUG;TRACE
17 |
18 |
19 |
20 | pdbonly
21 | true
22 | true
23 | true
24 | $(DefineConstants);TRACE
25 |
26 |
27 |
28 | $(TargetsForTfmSpecificBuildOutput);AddXmlDocToNugetPackage
29 |
30 |
--------------------------------------------------------------------------------
/LOGGING/Common.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/LOGGING/GlobalStaticVersion.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 | 2
9 | 12
10 | 0
11 | beta1
12 |
16 | 2019-09-23
17 |
18 | .PreReleaseVersion
19 | $(MSBuildThisFileDirectory)$(PreReleaseVersionFileName)
20 |
24 | $([MSBuild]::Divide($([System.DateTime]::Now.Subtract($([System.DateTime]::Parse($(SemanticVersionDate)))).TotalMinutes), 5).ToString('F0'))
25 |
26 |
27 |
28 | $(SemanticVersionMajor).$(SemanticVersionMinor).$(SemanticVersionPatch)
29 | $(PackageVersion)-$(PreReleaseMilestone)
30 | $(PackageVersion)-build$(PreReleaseVersion)
31 |
32 |
33 |
--------------------------------------------------------------------------------
/LOGGING/HelloWorldTest/HelloWorld.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {7AAF876A-43B5-4F47-B402-DC5C94948F3F}
8 | Library
9 | Properties
10 | HelloWorldTest
11 | HelloWorldTest
12 | v4.6.1
13 | 512
14 | {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
15 | 15.0
16 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
17 | $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages
18 | False
19 | UnitTest
20 |
21 |
22 |
23 |
24 | true
25 | full
26 | false
27 | bin\Debug\
28 | DEBUG;TRACE
29 | prompt
30 | 4
31 |
32 |
33 | pdbonly
34 | true
35 | bin\Release\
36 | TRACE
37 | prompt
38 | 4
39 |
40 |
41 |
42 | ..\..\..\packages\MSTest.TestFramework.1.4.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll
43 |
44 |
45 | ..\..\..\packages\MSTest.TestFramework.1.4.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | Designer
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | 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}.
66 |
67 |
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/LOGGING/HelloWorldTest/README.md:
--------------------------------------------------------------------------------
1 | Our build server wouldn't discover unit tests.
2 | For an unknown reason, including this project was the only way to have tests discovered.
3 | PRs had been accepted for over a month without any test validation and it was blocking a release so I needed the quick fix.
--------------------------------------------------------------------------------
/LOGGING/HelloWorldTest/UnitTest1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace HelloWorldTest
5 | {
6 | [TestClass]
7 | public class UnitTest1
8 | {
9 | [TestMethod]
10 | public void TestMethod_NewProjectNetFwFormat()
11 | {
12 | Assert.IsTrue(true);
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/LOGGING/HelloWorldTest/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/LOGGING/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Microsoft
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/LOGGING/Microsoft-Security-Recommended.ruleset:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/LOGGING/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/LOGGING/NuGet.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/ApplicationInsights-dotnet-logging/d19b91b607b490fb61648d719c45859bf5eb5489/LOGGING/NuGet.exe
--------------------------------------------------------------------------------
/LOGGING/Nupkg.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | True
7 | True
8 | snupkg
9 |
10 |
11 |
12 |
13 |
14 | Microsoft
15 | © Microsoft Corporation. All rights reserved.
16 |
17 | Microsoft
18 | Microsoft,AppInsightsSdk
19 | true
20 | MIT
21 | https://go.microsoft.com/fwlink/?LinkId=392727
22 | http://appanacdn.blob.core.windows.net/cdn/icons/aic.png
23 | https://github.com/Microsoft/ApplicationInsights-dotnet-logging
24 | Git
25 | Dependency
26 | content
27 | For the release notes please follow http://go.microsoft.com/fwlink/?LinkId=535037
28 |
29 | Azure Monitoring Analytics ApplicationInsights Telemetry
30 |
31 |
32 |
33 |
34 | UNDEFINED
35 | UNDEFINED
36 | UNDEFINED
37 |
38 |
39 |
40 |
41 |
43 | false
44 | false
45 | false
46 | false
47 | false
48 | false
49 |
50 |
--------------------------------------------------------------------------------
/LOGGING/PushNugetPackages.cmd:
--------------------------------------------------------------------------------
1 | setlocal
2 |
3 | if "%NUGET_KEY%"=="" SET NUGET_KEY=%1
4 |
5 | echo "key: '%NUGET_KEY%'"
6 |
7 | set BINROOT=%TF_BUILD_BINARIESDIRECTORY%\Release\NuGet
8 | if not exist %BINROOT% echo "Error: '%BINROOT%' does not exist."&goto :eof
9 |
10 | set NUGET=%TF_BUILD_SOURCESDIRECTORY%\NuGet.exe
11 | if not exist %NUGET% echo "Error: '%NUGET%' does not exist."&goto :eof
12 |
13 | set NUGET_GALLERY=https://www.myget.org/F/applicationinsights/api/v2/package
14 |
15 | for /r "%BINROOT%" %%P in (*.nupkg) do call :push %%P
16 | goto :eof
17 |
18 | :push
19 | set PACKAGE=%1
20 | if %PACKAGE:.symbols.=% == %PACKAGE% (
21 | %NUGET% push "%PACKAGE%" %NUGET_KEY% -source %NUGET_GALLERY%
22 | )
23 | goto :eof
24 |
25 | endlocal
26 |
--------------------------------------------------------------------------------
/LOGGING/SDL/BinSkimSetup.ps1:
--------------------------------------------------------------------------------
1 | [CmdletBinding()]
2 | Param(
3 | # C:\Repos\bin\Debug\Src
4 | [string]$buildDirectory = (Join-Path -Path (Split-Path -parent (Split-Path -parent (Split-Path -parent $PSCommandPath))) -ChildPath "bin\Debug\Src") ,
5 |
6 | # C:\Repos\binSkim
7 | [string]$binSkimDirectory = (Join-Path -Path (Split-Path -parent (Split-Path -parent (Split-Path -parent $PSCommandPath))) -ChildPath "binSkim")
8 | )
9 |
10 | # these are dlls that end up in the bin, but do not belong to us and don't need to be scanned.
11 | $excludedFiles = @("KernelTraceControl.dll", "msdia140.dll")
12 |
13 | Write-Host "`nPARAMETERS:";
14 | Write-Host "`tbuildDirectory:" $buildDirectory;
15 | Write-Host "`tbinSkimDirectory:" $binSkimDirectory;
16 |
17 | # don't need to clean folder on build server, but is needed for local dev
18 | Write-Host "`nCreate BinSkim Directory...";
19 | if (Test-Path $binSkimDirectory) { Remove-Item $binSkimDirectory -Recurse; }
20 |
21 | # copy all
22 | Write-Host "`nCopy all files...";
23 | Copy-Item -Path $buildDirectory -Filter "*.dll" -Destination $binSkimDirectory -Recurse;
24 |
25 | # delete test directories
26 | Write-Host "`nDelete any 'Test' directories...";
27 | Get-ChildItem -Path $binSkimDirectory -Recurse -Directory |
28 | Where-Object {$_ -match "Test"} |
29 | Remove-Item -Recurse;
30 |
31 | # delete excluded files
32 | if ($excludedFiles.Count -gt 0) {
33 | Write-Host "`nDelete excluded files...";
34 | Get-ChildItem -Path $binSkimDirectory -Recurse -File |
35 | ForEach-Object {
36 | if ($excludedFiles.Contains($_.Name)) {
37 | Write-Host "Excluded File:" $_.FullName;
38 | Remove-Item $_.FullName;
39 | }
40 | }
41 | }
42 |
43 | # summary for log output (file list and count)
44 | Write-Host "`nCopied Files:";
45 |
46 | $count = 0;
47 | Get-ChildItem -Path $binSkimDirectory -Recurse -File |
48 | ForEach-Object {
49 | Write-Host "`t"$_.FullName;
50 | $count++;
51 | }
52 |
53 | Write-Host "`nTOTAL FILES:" $count;
--------------------------------------------------------------------------------
/LOGGING/SDL/FxCopSetup.ps1:
--------------------------------------------------------------------------------
1 | [CmdletBinding()]
2 | Param(
3 | # C:\Repos\bin\Debug\Src
4 | [string]$buildDirectory = (Join-Path -Path (Split-Path -parent (Split-Path -parent (Split-Path -parent $PSCommandPath))) -ChildPath "bin\Debug") ,
5 |
6 | # C:\Repos\fxCop
7 | [string]$fxCopDirectory = (Join-Path -Path (Split-Path -parent (Split-Path -parent (Split-Path -parent $PSCommandPath))) -ChildPath "fxCop")
8 | )
9 |
10 | function IsFileDependency {
11 | [CmdletBinding()]
12 | param
13 | (
14 | $file
15 | )
16 | $dependencyFiles | ForEach-Object {
17 | if($file.Name -eq $_) {
18 | return $true;
19 | }
20 | }
21 |
22 | return $false;
23 | }
24 |
25 | # these are dlls that end up in the bin, but do not belong to us and don't need to be scanned.
26 | $excludedFiles = @(
27 | "KernelTraceControl.dll",
28 | "msdia140.dll");
29 | $dependencyFiles = @(
30 | "Microsoft.ApplicationInsights.dll",
31 | "log4net.dll",
32 | "NLog.dll",
33 | "Microsoft.Diagnostics.Tracing.TraceEvent.dll",
34 | "System.Diagnostics.DiagnosticSource.dll");
35 |
36 | Write-Host "`nPARAMETERS:";
37 | Write-Host "`tbuildDirectory:" $buildDirectory;
38 | Write-Host "`tfxCopDirectory:" $fxCopDirectory;
39 |
40 | $fxCopTargetDir = Join-Path -Path $fxCopDirectory -ChildPath "target";
41 | $fxCopDependenciesDir = Join-Path -Path $fxCopDirectory -ChildPath "dependencies";
42 |
43 |
44 | $frameworks = @("net45", "net451", "netstandard1.3");
45 |
46 | # don't need to clean folder on build server, but is needed for local dev
47 | Write-Host "`nCreate FxCop Directory...";
48 | if (Test-Path $fxCopDirectory) { Remove-Item $fxCopDirectory -Recurse; }
49 |
50 | # copy all
51 | Write-Host "`nCopy all files (excluding 'Test' directories)...";
52 | Get-ChildItem -Path $buildDirectory -Recurse -File -Include *.dll, *.pdb |
53 | ForEach-Object {
54 | $file = $_;
55 |
56 | # exclude test files
57 | if ($file.Directory -match "Test") {
58 | return;
59 | }
60 |
61 | #find matching framework
62 | $frameworks | ForEach-Object {
63 | if($file.Directory -match $_) {
64 | $framework = $_;
65 |
66 | #is this file a dependency
67 | if (IsFileDependency($file)) {
68 | Copy-Item $file.FullName -Destination (New-Item (Join-Path -Path $fxCopDependenciesDir -ChildPath $framework) -Type container -Force) -Force;
69 | } else {
70 | Copy-Item $file.FullName -Destination (New-Item (Join-Path -Path $fxCopTargetDir -ChildPath $framework) -Type container -Force) -Force;
71 | }
72 | }
73 | }
74 | }
75 |
76 | # delete excluded files
77 | if ($excludedFiles.Count -gt 0) {
78 | Write-Host "`nDelete excluded files...";
79 | Get-ChildItem -Path $fxCopDirectory -Recurse -File |
80 | ForEach-Object {
81 | if ($excludedFiles.Contains($_.Name)) {
82 | Write-Host "Excluded File:" $_.FullName;
83 | Remove-Item $_.FullName;
84 | }
85 | }
86 | }
87 |
88 | # summary for log output (file list and count)
89 | Write-Host "`nCopied Files:";
90 |
91 | $count = 0;
92 | Get-ChildItem -Path $fxCopDirectory -Recurse -File |
93 | ForEach-Object {
94 | Write-Host "`t"$_.FullName;
95 | $count++;
96 | }
97 |
98 | Write-Host "`nTOTAL FILES:" $count;
99 |
100 |
--------------------------------------------------------------------------------
/LOGGING/Signing.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
10 |
11 | Microsoft400
12 |
13 | MsSharedLib72
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | Microsoft400
27 |
28 |
29 |
30 |
31 |
32 |
33 | $(PackagesDir)\Microsoft.DotNet.BuildTools.1.0.16-prerelease\lib\
34 |
35 |
36 |
37 |
38 |
39 | $(MSBuildThisFileDirectory)\35MSSharedLib1024.snk
40 |
41 |
42 |
43 | true
44 | true
45 |
46 |
47 |
--------------------------------------------------------------------------------
/LOGGING/SourceRoot.marker:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/microsoft/ApplicationInsights-dotnet-logging/d19b91b607b490fb61648d719c45859bf5eb5489/LOGGING/SourceRoot.marker
--------------------------------------------------------------------------------
/LOGGING/Test.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | false
6 |
7 |
8 |
--------------------------------------------------------------------------------
/LOGGING/VSOPushNugetPackages.cmd:
--------------------------------------------------------------------------------
1 | setlocal
2 |
3 | if "%NUGET_KEY%"=="" SET NUGET_KEY=%1
4 |
5 | echo "key: '%NUGET_KEY%'"
6 |
7 | set BINROOT=%AGENT_BUILDDIRECTORY%\bin\Release\NuGet
8 | if not exist %BINROOT% echo "Error: '%BINROOT%' does not exist."&goto :eof
9 |
10 | set NUGET=%BUILD_SOURCESDIRECTORY%\NuGet.exe
11 | if not exist %NUGET% echo "Error: '%NUGET%' does not exist."&goto :eof
12 |
13 | set NUGET_GALLERY=https://www.myget.org/F/applicationinsights/api/v2/package
14 |
15 | for /r "%BINROOT%" %%P in (*.nupkg) do call :push %%P
16 | goto :eof
17 |
18 | :push
19 | set PACKAGE=%1
20 | if %PACKAGE:.symbols.=% == %PACKAGE% (
21 | %NUGET% push "%PACKAGE%" %NUGET_KEY% -source %NUGET_GALLERY%
22 | )
23 | goto :eof
24 |
25 | endlocal
26 |
--------------------------------------------------------------------------------
/LOGGING/buildDebug.cmd:
--------------------------------------------------------------------------------
1 | @echo off
2 |
3 | SET ProjectName=Msbuild.All
4 |
5 | SET Configuration=Debug
6 |
7 | SET Platform="Mixed Platforms"
8 | msbuild dirs.proj /nologo /m:1 /fl /flp:logfile=%ProjectName%.%Platform%.log;v=d /flp1:logfile=%ProjectName%.%Platform%.wrn;warningsonly /flp2:logfile=%ProjectName%.%Platform%.err;errorsonly /p:Configuration=%Configuration% /p:Platform=%Platform% /p:RunCodeAnalysis="False" /flp3:logfile=%ProjectName%.%Platform%.prf;performancesummary /flp4:logfile=%ProjectName%.%Platform%.exec.log;showcommandline /p:BuildSingleFilePackage=true
9 |
10 | PAUSE
11 |
12 |
13 |
--------------------------------------------------------------------------------
/LOGGING/buildRelease.cmd:
--------------------------------------------------------------------------------
1 | @echo off
2 |
3 | SET ProjectName=Msbuild.All
4 |
5 | SET Configuration=Release
6 |
7 | SET Platform="Mixed Platforms"
8 | msbuild dirs.proj /nologo /m:1 /fl /flp:logfile=%ProjectName%.%Platform%.log;v=d /flp1:logfile=%ProjectName%.%Platform%.wrn;warningsonly /flp2:logfile=%ProjectName%.%Platform%.err;errorsonly /p:Configuration=%Configuration% /p:Platform=%Platform% /p:RunCodeAnalysis="False" /flp3:logfile=%ProjectName%.%Platform%.prf;performancesummary /flp4:logfile=%ProjectName%.%Platform%.exec.log;showcommandline /p:BuildSingleFilePackage=true
9 |
10 | PAUSE
11 |
12 |
13 |
--------------------------------------------------------------------------------
/LOGGING/clean.cmd:
--------------------------------------------------------------------------------
1 | rmdir /S /Q ..\bin
2 | rmdir /S /Q ..\obj
--------------------------------------------------------------------------------
/LOGGING/dirs.proj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/LOGGING/disablestrongnamevalidation.ps1:
--------------------------------------------------------------------------------
1 | & "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools\x64\sn.exe" -Vr *,31bf3856ad364e35
2 | & "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools\sn.exe" -Vr *,31bf3856ad364e35
3 | # running both the above as a hack which is known to work. Its not clear why both are needed.
4 |
--------------------------------------------------------------------------------
/LOGGING/enablestrongnamevalidation.ps1:
--------------------------------------------------------------------------------
1 | & "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools\x64\sn.exe" -Vu *,31bf3856ad364e35
2 | & "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools\sn.exe" -Vu *,31bf3856ad364e35
3 | # running both the above as a hack which is known to work. Its not clear why both are needed.
--------------------------------------------------------------------------------
/LOGGING/src/CommonShared/CommonShared.projitems:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 | true
6 | 587b624b-8c64-498e-93d7-a2d2abc17eab
7 |
8 |
9 | CommonShared
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/LOGGING/src/CommonShared/CommonShared.shproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 587b624b-8c64-498e-93d7-a2d2abc17eab
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/LOGGING/src/CommonShared/SdkVersionUtils.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation.
4 | // All rights reserved. 2013
5 | //
6 | // -----------------------------------------------------------------------
7 |
8 | namespace Microsoft.ApplicationInsights.Implementation
9 | {
10 | using System;
11 | using System.Linq;
12 | using System.Reflection;
13 |
14 | internal class SdkVersionUtils
15 | {
16 | internal static string GetSdkVersion(string versionPrefix)
17 | {
18 | #if NET45 || NET46
19 | string versionStr = typeof(SdkVersionUtils).Assembly.GetCustomAttributes(false).OfType().First().Version;
20 | #else
21 | string versionStr = typeof(SdkVersionUtils).GetTypeInfo().Assembly.GetCustomAttributes().First().Version;
22 | #endif
23 |
24 | Version version = new Version(versionStr);
25 | return (versionPrefix ?? string.Empty) + version.ToString(3) + "-" + version.Revision;
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/LOGGING/src/DiagnosticSourceListener/ApplicationInsights.config.install.xdt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/LOGGING/src/DiagnosticSourceListener/ApplicationInsights.config.uninstall.xdt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/LOGGING/src/DiagnosticSourceListener/DeclaredPropertiesCache.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All rights reserved.
4 | //
5 | //-----------------------------------------------------------------------
6 |
7 | namespace Microsoft.ApplicationInsights.DiagnosticSourceListener
8 | {
9 | using System;
10 | using System.Collections.Concurrent;
11 | using System.Collections.Generic;
12 | using System.Reflection;
13 |
14 | internal static class DeclaredPropertiesCache
15 | {
16 | private const int MaxCacheSize = 100;
17 | private static ConcurrentDictionary> cache = new ConcurrentDictionary>();
18 |
19 | public static IEnumerable GetDeclaredProperties(object obj)
20 | {
21 | if (cache.Count > MaxCacheSize)
22 | {
23 | cache.Clear();
24 | }
25 |
26 | return cache.GetOrAdd(obj.GetType(), t => t.GetTypeInfo().DeclaredProperties);
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/LOGGING/src/DiagnosticSourceListener/DiagnosticSourceListener.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard1.3;net45
4 | Microsoft.ApplicationInsights.DiagnosticSourceListener
5 | Microsoft.ApplicationInsights.DiagnosticSourceListener
6 |
7 |
8 |
9 |
10 |
11 |
12 | false
13 |
14 |
15 |
16 |
17 | Microsoft.ApplicationInsights.DiagnosticSourceListener
18 | Application Insights DiagnosticSourceListener
19 | Application Insights DiagnosticSourceListener allows forwarding events from DiagnosticSource to Application Insights. Application Insights will collect your logs from multiple sources and provide rich powerful search capabilities. Privacy statement: https://go.microsoft.com/fwlink/?LinkId=512156
20 | $(PackageTags) DiagnosticsSource
21 |
22 |
23 |
24 | full
25 | true
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 | All
37 |
38 |
39 | All
40 |
41 |
42 | All
43 |
44 |
45 |
46 |
47 |
48 |
49 | All
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/LOGGING/src/DiagnosticSourceListener/DiagnosticSourceListenerSubscription.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All rights reserved.
4 | //
5 | //-----------------------------------------------------------------------
6 |
7 | namespace Microsoft.ApplicationInsights.DiagnosticSourceListener
8 | {
9 | using System;
10 | using System.Collections.Generic;
11 |
12 | internal class DiagnosticSourceListenerSubscription : IObserver>
13 | {
14 | private readonly string listenerName;
15 | private readonly TelemetryClient telemetryClient;
16 | private readonly OnEventWrittenHandler onEventWrittenHandler;
17 |
18 | public DiagnosticSourceListenerSubscription(string listenerName, TelemetryClient telemetryClient, OnEventWrittenHandler onEventWrittenHandler)
19 | {
20 | if (listenerName == null)
21 | {
22 | throw new ArgumentNullException(nameof(listenerName));
23 | }
24 |
25 | if (telemetryClient == null)
26 | {
27 | throw new ArgumentNullException(nameof(telemetryClient));
28 | }
29 |
30 | if (onEventWrittenHandler == null)
31 | {
32 | throw new ArgumentNullException(nameof(onEventWrittenHandler));
33 | }
34 |
35 | this.listenerName = listenerName;
36 | this.telemetryClient = telemetryClient;
37 | this.onEventWrittenHandler = onEventWrittenHandler;
38 | }
39 |
40 | public void OnCompleted()
41 | {
42 | }
43 |
44 | public void OnError(Exception error)
45 | {
46 | }
47 |
48 | ///
49 | /// Observes an event from the diagnostic source and logs it as a message to Application Insights.
50 | ///
51 | /// The event (message and payload) from the diagnostic source.
52 | public void OnNext(KeyValuePair @event)
53 | {
54 | try
55 | {
56 | this.onEventWrittenHandler(this.listenerName, @event.Key, @event.Value, this.telemetryClient);
57 | }
58 | catch (Exception ex)
59 | {
60 | this.telemetryClient.TrackException(ex);
61 | }
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/LOGGING/src/DiagnosticSourceListener/DiagnosticSourceListeningRequest.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All rights reserved.
4 | //
5 | //-----------------------------------------------------------------------
6 |
7 | namespace Microsoft.ApplicationInsights.DiagnosticSourceListener
8 | {
9 | ///
10 | /// Represents a request to listen to a specific DiagnosticSource.
11 | ///
12 | public class DiagnosticSourceListeningRequest
13 | {
14 | ///
15 | /// Initializes a new instance of the class.
16 | ///
17 | public DiagnosticSourceListeningRequest()
18 | {
19 | }
20 |
21 | ///
22 | /// Initializes a new instance of the class.
23 | ///
24 | /// The name of the diagnostic source to listen to.
25 | public DiagnosticSourceListeningRequest(string name)
26 | {
27 | this.Name = name;
28 | }
29 |
30 | ///
31 | /// Gets or sets the name of the diagnostic source to listen to.
32 | ///
33 | public string Name { get; set; }
34 |
35 | ///
36 | /// Tests for equality.
37 | ///
38 | /// Object to compare with.
39 | /// True if the supplied object is equal to "this", otherwise false.
40 | public override bool Equals(object obj)
41 | {
42 | var other = obj as DiagnosticSourceListeningRequest;
43 | if (other == null)
44 | {
45 | return false;
46 | }
47 |
48 | return string.Equals(this.Name, other.Name, System.StringComparison.Ordinal);
49 | }
50 |
51 | ///
52 | /// Gets the hash code for the current listening request.
53 | ///
54 | /// Hash code.
55 | public override int GetHashCode()
56 | {
57 | return this.Name.GetHashCode();
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/LOGGING/src/EtwCollector/AITraceEventSession.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All rights reserved.
4 | //
5 | //-----------------------------------------------------------------------
6 |
7 | namespace Microsoft.ApplicationInsights.EtwCollector
8 | {
9 | using System;
10 | using Microsoft.Diagnostics.Tracing;
11 | using Microsoft.Diagnostics.Tracing.Session;
12 |
13 | ///
14 | /// A wrapper of .
15 | ///
16 | internal sealed class AITraceEventSession : ITraceEventSession, IDisposable
17 | {
18 | private TraceEventSession session;
19 |
20 | public AITraceEventSession(TraceEventSession traceEventSession)
21 | {
22 | if (traceEventSession == null)
23 | {
24 | throw new ArgumentNullException(nameof(traceEventSession));
25 | }
26 |
27 | this.session = traceEventSession;
28 | }
29 |
30 | public TraceEventDispatcher Source
31 | {
32 | get
33 | {
34 | return this.session.Source;
35 | }
36 | }
37 |
38 | public void DisableProvider(Guid providerGuid)
39 | {
40 | this.session.DisableProvider(providerGuid);
41 | }
42 |
43 | public void DisableProvider(string providerName)
44 | {
45 | this.session.DisableProvider(providerName);
46 | }
47 |
48 | public void Dispose()
49 | {
50 | this.session.Dispose();
51 | }
52 |
53 | public bool EnableProvider(Guid providerGuid, TraceEventLevel providerLevel = TraceEventLevel.Verbose, ulong matchAnyKeywords = ulong.MaxValue, TraceEventProviderOptions options = null)
54 | {
55 | return this.session.EnableProvider(providerGuid, providerLevel, matchAnyKeywords, options);
56 | }
57 |
58 | public bool EnableProvider(string providerName, TraceEventLevel providerLevel = TraceEventLevel.Verbose, ulong matchAnyKeywords = ulong.MaxValue, TraceEventProviderOptions options = null)
59 | {
60 | return this.session.EnableProvider(providerName, providerLevel, matchAnyKeywords, options);
61 | }
62 |
63 | public bool? IsElevated()
64 | {
65 | return TraceEventSession.IsElevated();
66 | }
67 |
68 | public bool Stop(bool noThrow = false)
69 | {
70 | return this.session.Stop(noThrow);
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/LOGGING/src/EtwCollector/ApplicationInsights.config.install.xdt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/LOGGING/src/EtwCollector/ApplicationInsights.config.uninstall.xdt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/LOGGING/src/EtwCollector/EtwCollector.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net451
4 | Microsoft.ApplicationInsights.EtwCollector
5 | Microsoft.ApplicationInsights.EtwCollector
6 |
7 |
8 |
9 |
10 |
11 |
12 | true
13 | true
14 |
15 |
16 |
17 |
18 | Microsoft.ApplicationInsights.EtwCollector
19 | Application Insights EtwCollector
20 | Application Insights EtwCollector allows sending data from Event Tracing for Windows (ETW) to Application Insights. Application Insights will collect your logs from multiple sources and provide rich powerful search capabilities. Privacy statement: https://go.microsoft.com/fwlink/?LinkId=512156.
21 | $(PackageTags) ASP.NET ASMX Web Azure Server Services ASPX Websites Role Logging Log Tracing ETW EtwCollector Tracing
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | All
33 |
34 |
35 | All
36 |
37 |
38 | All
39 |
40 |
41 |
42 |
43 |
44 |
45 | All
46 |
47 |
48 |
49 |
50 |
51 | All
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/LOGGING/src/EtwCollector/EtwListeningRequest.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All rights reserved.
4 | //
5 | //-----------------------------------------------------------------------
6 |
7 | namespace Microsoft.ApplicationInsights.EtwCollector
8 | {
9 | using System;
10 | using Microsoft.Diagnostics.Tracing;
11 |
12 | ///
13 | /// Represents a request to listen to specific ETW provider.
14 | ///
15 | public class EtwListeningRequest
16 | {
17 | ///
18 | /// Gets or sets the provider name to listen to.
19 | ///
20 | public string ProviderName { get; set; }
21 |
22 | ///
23 | /// Gets or sets the guid of the provider to listen to.
24 | ///
25 | public Guid ProviderGuid { get; set; }
26 |
27 | ///
28 | /// Gets or sets the minimum level of an event that will be traced.
29 | ///
30 | ///
31 | /// Events with level lower than the specified level will be silently discarded.
32 | ///
33 | public TraceEventLevel Level { get; set; }
34 |
35 | ///
36 | /// Gets or sets the keywords that must be set on an event to be included in tracing.
37 | ///
38 | public ulong Keywords { get; set; }
39 |
40 | ///
41 | /// Verify this request is valid.
42 | ///
43 | /// Error message to display in case the request is invalid.
44 | /// True if the request is valid, otherwise false.
45 | /// Throws when the object is not valid.
46 | public bool Validate(out string errorMessage)
47 | {
48 | if (this.ProviderGuid == Guid.Empty && string.IsNullOrEmpty(this.ProviderName))
49 | {
50 | errorMessage = "ProviderGuid and ProviderName can't be null at the same time.";
51 | return false;
52 | }
53 |
54 | errorMessage = null;
55 | return true;
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/LOGGING/src/EtwCollector/ITraceEventSession.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All rights reserved.
4 | //
5 | //-----------------------------------------------------------------------
6 |
7 | namespace Microsoft.ApplicationInsights.EtwCollector
8 | {
9 | using System;
10 | using Microsoft.Diagnostics.Tracing;
11 | using Microsoft.Diagnostics.Tracing.Session;
12 |
13 | ///
14 | /// Abstracts properties and methods of to provide better test ability.
15 | ///
16 | internal interface ITraceEventSession : IDisposable
17 | {
18 | ///
19 | /// Gets the TraceEventDispatcher for the session.
20 | ///
21 | ///
22 | /// If this is a real time session you can fetch the source associated with the session
23 | /// to start receiving events. Currently does not work on file based sources (we
24 | /// expect you to wait until the file is complete).
25 | ///
26 | TraceEventDispatcher Source { get; }
27 |
28 | ///
29 | /// Enables a provider by its name, level and keywords.
30 | ///
31 | ///
32 | /// The name of the provider.
33 | ///
34 | ///
35 | /// The verbosity to turn on.
36 | ///
37 | ///
38 | /// A bit vector representing the areas to turn on. Only the low 32 bits are used
39 | /// by classic providers and passed as the 'flags' value. Zero is a special value
40 | /// which is a provider defined default, which is usually 'everything'.
41 | ///
42 | ///
43 | /// Additional options for the provider (e.g. taking a stack trace), arguments ...
44 | ///
45 | /// true if the session already existed and needed to be restarted.
46 | bool EnableProvider(string providerName, TraceEventLevel providerLevel = TraceEventLevel.Verbose, ulong matchAnyKeywords = ulong.MaxValue, TraceEventProviderOptions options = null);
47 |
48 | ///
49 | /// Enable a provider which has a given provider Guid.
50 | ///
51 | /// The Guid that represents the event provider enable.
52 | /// The verbosity to turn on.
53 | ///
54 | /// A bit vector representing the areas to turn on. Only the low 32 bits are used
55 | /// by classic providers and passed as the 'flags' value. Zero is a special value
56 | /// which is a provider defined default, which is usually 'everything'.
57 | ///
58 | /// Additional options for the provider (e.g. taking a stack trace), arguments ...
59 | /// true if the session already existed and needed to be restarted.
60 | bool EnableProvider(Guid providerGuid, TraceEventLevel providerLevel = TraceEventLevel.Verbose, ulong matchAnyKeywords = ulong.MaxValue, TraceEventProviderOptions options = null);
61 |
62 | ///
63 | /// Disables a provider with the given name completely.
64 | ///
65 | /// Name of the provider to disable.
66 | void DisableProvider(string providerName);
67 |
68 | ///
69 | /// Disables a provider with the given provider ID completely.
70 | ///
71 | /// GUID of the provider to disable.
72 | void DisableProvider(Guid providerGuid);
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/LOGGING/src/EtwCollector/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All rights reserved.
4 | //
5 | //-----------------------------------------------------------------------
6 |
7 | using System.Reflection;
8 | using System.Resources;
9 | using System.Runtime.CompilerServices;
10 | using System.Runtime.InteropServices;
11 |
12 | // General Information about an assembly is controlled through the following
13 | // set of attributes. Change these attribute values to modify the information
14 | // associated with an assembly.
15 | [assembly: AssemblyTitle("Microsoft.ApplicationInsights.EtwCollector")]
16 | [assembly: AssemblyDescription("")]
17 |
18 | [assembly: NeutralResourcesLanguageAttribute("en-US")]
19 |
20 | // Setting ComVisible to false makes the types in this assembly not visible
21 | // to COM components. If you need to access a type in this assembly from
22 | // COM, set the ComVisible attribute to true on that type.
23 | [assembly: ComVisible(false)]
24 |
25 | // The following GUID is for the ID of the typelib if this project is exposed to COM
26 | [assembly: Guid("9becfb0f-4f6d-4a84-931f-70da3e4e2813")]
27 |
28 | [assembly: InternalsVisibleTo("Microsoft.ApplicationInsights.EtwCollector.Net451.Tests, PublicKey=" + AssemblyInfo.PublicKey)]
29 |
30 | internal static class AssemblyInfo
31 | {
32 | // Public key; assemblies are delay signed or OSS signed
33 | public const string PublicKey = "0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9";
34 | }
--------------------------------------------------------------------------------
/LOGGING/src/EventSource.Shared/EventSource.Shared/EventSource.Shared.projitems:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 | true
6 | a964de6d-9750-4013-8be2-79c2afc056e5
7 |
8 |
9 | EventSource.Shared
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/LOGGING/src/EventSource.Shared/EventSource.Shared/EventSource.Shared.shproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | a964de6d-9750-4013-8be2-79c2afc056e5
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/LOGGING/src/EventSource.Shared/EventSource.Shared/Implementation/EventSourceListenerEventSource.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All rights reserved.
4 | //
5 | //-----------------------------------------------------------------------
6 |
7 | namespace Microsoft.ApplicationInsights.TraceEvent.Shared.Implementation
8 | {
9 | using System;
10 | using System.Diagnostics.Tracing;
11 | using System.Reflection;
12 |
13 | ///
14 | /// EventSource for reporting errors and warnings from the EventSourceListener telemetry module.
15 | ///
16 | [EventSource(Name = ProviderName)]
17 | internal sealed class EventSourceListenerEventSource : EventSource
18 | {
19 | public const string ProviderName = "Microsoft-ApplicationInsights-Extensibility-EventSourceListener";
20 | public static readonly EventSourceListenerEventSource Log = new EventSourceListenerEventSource();
21 |
22 | public readonly string ApplicationName;
23 |
24 | private const int NoEventSourcesConfiguredEventId = 1;
25 | private const int FailedToEnableProvidersEventId = 2;
26 | private const int ModuleInitializationFailedEventId = 3;
27 | private const int UnauthorizedAccessEventId = 4;
28 | private const int OnEventWrittenHandlerFailure = 5;
29 |
30 | private EventSourceListenerEventSource()
31 | {
32 | this.ApplicationName = GetApplicationName();
33 | }
34 |
35 | [Event(NoEventSourcesConfiguredEventId, Level = EventLevel.Warning, Keywords = Keywords.Configuration, Message = "No Sources configured for the {1}")]
36 | public void NoSourcesConfigured(string moduleName, string applicationName = null)
37 | {
38 | this.WriteEvent(NoEventSourcesConfiguredEventId, applicationName ?? this.ApplicationName, moduleName);
39 | }
40 |
41 | [Event(FailedToEnableProvidersEventId, Level = EventLevel.Error, Keywords = Keywords.Configuration, Message = "Failed to enable provider {1} for the {0}.")]
42 | public void FailedToEnableProviders(string moduleName, string providerName, string details, string applicationName = null)
43 | {
44 | this.WriteEvent(FailedToEnableProvidersEventId, moduleName, providerName, details, applicationName ?? this.ApplicationName);
45 | }
46 |
47 | [Event(ModuleInitializationFailedEventId, Level = EventLevel.Error, Keywords = Keywords.Configuration, Message = "Initialization failed for the {0}.")]
48 | public void ModuleInitializationFailed(string moduleName, string details, string applicationName = null)
49 | {
50 | this.WriteEvent(ModuleInitializationFailedEventId, moduleName, details, applicationName ?? this.ApplicationName);
51 | }
52 |
53 | [Event(UnauthorizedAccessEventId, Level = EventLevel.Error, Keywords = Keywords.Configuration, Message = "Failed to enable provider for the {0}. Access Denied.")]
54 | public void AccessDenied(string moduleName, string details, string applicationName = null)
55 | {
56 | this.WriteEvent(UnauthorizedAccessEventId, moduleName, details, applicationName ?? this.ApplicationName);
57 | }
58 |
59 | [Event(OnEventWrittenHandlerFailure, Level = EventLevel.Error, Message = "{0}: Failure while handling event")]
60 | public void OnEventWrittenHandlerFailed(string moduleName, string details, string applicationName = null)
61 | {
62 | this.WriteEvent(OnEventWrittenHandlerFailure, moduleName, details, applicationName ?? this.ApplicationName);
63 | }
64 |
65 | [NonEvent]
66 | private static string GetApplicationName()
67 | {
68 | string name;
69 | try
70 | {
71 | #if NET45 || NET46
72 | name = AppDomain.CurrentDomain.FriendlyName;
73 | #else
74 | name = string.Empty;
75 | #endif
76 | }
77 | catch
78 | {
79 | name = "(unknown)";
80 | }
81 |
82 | return name;
83 | }
84 |
85 | public sealed class Keywords
86 | {
87 | public const EventKeywords Configuration = (EventKeywords)0x01;
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/LOGGING/src/EventSource.Shared/EventSource.Shared/Utilities/StringBuilderCache.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All rights reserved.
4 | //
5 | //-----------------------------------------------------------------------
6 |
7 | namespace Microsoft.ApplicationInsights.TraceEvent.Shared.Utilities
8 | {
9 | using System;
10 | using System.Text;
11 |
12 | ///
13 | /// Provides a cached reusable instance of a StringBuilder per thread. It is an optimization that reduces the number of instances constructed and collected.
14 | ///
15 | internal static class StringBuilderCache
16 | {
17 | // The value 360 was chosen in discussion with performance experts as a compromise between using
18 | // as litle memory (per thread) as possible and still covering a large part of short-lived
19 | // StringBuilder creations.
20 | private const int MaxBuilderSize = 360;
21 |
22 | [ThreadStatic]
23 | private static StringBuilder cachedInstance;
24 |
25 | ///
26 | /// Gets a string builder to use of a particular size.
27 | ///
28 | /// Initial capacity of the requested StringBuilder.
29 | /// An instance of a StringBuilder.
30 | ///
31 | /// It can be called any number of times. If a StringBuilder is in the cache then it will be returned and the cache emptied.
32 | /// A StringBuilder instance is cached in Thread Local Storage and so there is one per thread.
33 | /// Subsequent calls will return a new StringBuilder.
34 | ///
35 | public static StringBuilder Acquire(int capacity = 16 /*StringBuilder.DefaultCapacity*/)
36 | {
37 | if (capacity <= MaxBuilderSize)
38 | {
39 | StringBuilder sb = StringBuilderCache.cachedInstance;
40 | if (sb != null)
41 | {
42 | // Avoid stringbuilder block fragmentation by getting a new StringBuilder
43 | // when the requested size is larger than the current capacity
44 | if (capacity <= sb.Capacity)
45 | {
46 | StringBuilderCache.cachedInstance = null;
47 | sb.Clear();
48 | return sb;
49 | }
50 | }
51 | }
52 |
53 | return new StringBuilder(capacity);
54 | }
55 |
56 | ///
57 | /// Place the specified builder in the cache if it is not too big.
58 | ///
59 | /// StringBuilder that is no longer used.
60 | ///
61 | /// The StringBuilder should not be used after it has been released. Unbalanced Releases are perfectly acceptable.
62 | /// It will merely cause the runtime to create a new StringBuilder next time Acquire is called.
63 | ///
64 | public static void Release(StringBuilder sb)
65 | {
66 | if (sb.Capacity <= MaxBuilderSize)
67 | {
68 | StringBuilderCache.cachedInstance = sb;
69 | }
70 | }
71 |
72 | ///
73 | /// Gets the resulting string and releases a StringBuilder instance.
74 | ///
75 | /// StringBuilder to be released.
76 | /// The output of the StringBuilder.
77 | public static string GetStringAndRelease(StringBuilder sb)
78 | {
79 | string result = sb.ToString();
80 | Release(sb);
81 | return result;
82 | }
83 | }
84 | }
--------------------------------------------------------------------------------
/LOGGING/src/EventSource.Shared/EventSource.Shared/Utilities/TplActivities.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All rights reserved.
4 | //
5 | //-----------------------------------------------------------------------
6 |
7 | namespace Microsoft.ApplicationInsights.TraceEvent.Shared.Utilities
8 | {
9 | using System;
10 |
11 | ///
12 | /// Provides well-known values for working with Task Parallel Library (TPL) EventSource.
13 | ///
14 | public static class TplActivities
15 | {
16 | ///
17 | /// Gets the GUID of the TPL EventSource.
18 | ///
19 | public static readonly Guid TplEventSourceGuid = new Guid("2e5dba47-a3d2-4d16-8ee0-6671ffdcd7b5");
20 |
21 | ///
22 | /// Gets the keyword that enables hierarchical activity IDs.
23 | ///
24 | public static readonly ulong TaskFlowActivityIdsKeyword = 0x80;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/LOGGING/src/EventSourceListener/ApplicationInsights.config.install.xdt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/LOGGING/src/EventSourceListener/ApplicationInsights.config.uninstall.xdt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/LOGGING/src/EventSourceListener/DisableEventSourceRequest.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All rights reserved.
4 | //
5 | //-----------------------------------------------------------------------
6 |
7 | namespace Microsoft.ApplicationInsights.EventSourceListener
8 | {
9 | ///
10 | /// Represents a request to disable listening to a specific EventSource.
11 | ///
12 | public class DisableEventSourceRequest : EventSourceListeningRequestBase
13 | {
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/LOGGING/src/EventSourceListener/EventSourceListener.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard1.3
4 | Microsoft.ApplicationInsights.EventSourceListener
5 | Microsoft.ApplicationInsights.EventSourceListener
6 |
7 |
8 |
9 |
10 |
11 |
12 | true
13 | true
14 |
15 |
16 |
17 |
18 | Microsoft.ApplicationInsights.EventSourceListener
19 | Application Insights EventSourceListener
20 | Application Insights EventSourceListener allows sending data from EventSource events to Application Insights. Application Insights will collect your logs from multiple sources and provide rich powerful search capabilities. Privacy statement: https://go.microsoft.com/fwlink/?LinkId=512156
21 | $(PackageTags) ASP.NET ASMX Web Azure Server Services ASPX Websites Role Logging Log Tracing EventSource EventSourceListener
22 |
23 |
24 |
25 | full
26 | true
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | All
38 |
39 |
40 | All
41 |
42 |
43 | All
44 |
45 |
46 |
47 |
48 |
49 |
50 | All
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/LOGGING/src/EventSourceListener/EventSourceListeningRequest.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All rights reserved.
4 | //
5 | //-----------------------------------------------------------------------
6 |
7 | namespace Microsoft.ApplicationInsights.EventSourceListener
8 | {
9 | using System.Diagnostics.Tracing;
10 |
11 | ///
12 | /// Represents a request to listen to specific EventSource.
13 | ///
14 | public class EventSourceListeningRequest : EventSourceListeningRequestBase
15 | {
16 | ///
17 | /// Initializes a new instance of the class.
18 | ///
19 | ///
20 | /// By default all events from an EventSource are traced. The set of events can be restricted using and properties.
21 | ///
22 | public EventSourceListeningRequest()
23 | {
24 | this.Level = EventLevel.LogAlways;
25 | this.Keywords = (EventKeywords)~0;
26 | }
27 |
28 | ///
29 | /// Gets or sets the minimum level of an event that will be traced.
30 | ///
31 | ///
32 | /// Events with level lower than the specified level will be silently discarded.
33 | ///
34 | public EventLevel Level { get; set; }
35 |
36 | ///
37 | /// Gets or sets the keywords that must be set on an event to be included in tracing.
38 | ///
39 | public EventKeywords Keywords { get; set; }
40 |
41 | ///
42 | /// Tests for equality.
43 | ///
44 | /// Object to compare with.
45 | /// True if the supplied object is equal to "this", otherwise false.
46 | public override bool Equals(object obj)
47 | {
48 | var other = obj as EventSourceListeningRequest;
49 | if (other == null)
50 | {
51 | return false;
52 | }
53 |
54 | return base.Equals(obj) && this.Level == other.Level && this.Keywords == other.Keywords;
55 | }
56 |
57 | ///
58 | /// Gets the hash code for the current listening request.
59 | ///
60 | /// Hash code.
61 | public override int GetHashCode()
62 | {
63 | return base.GetHashCode() ^ (int)this.Level ^ this.Keywords.GetHashCode();
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/LOGGING/src/EventSourceListener/EventSourceListeningRequestBase.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All rights reserved.
4 | //
5 | //-----------------------------------------------------------------------
6 |
7 | namespace Microsoft.ApplicationInsights.EventSourceListener
8 | {
9 | ///
10 | /// Abstraction of a match rule for event source. To be inherited by either an enabling rule or a disabling rule, etc.
11 | ///
12 | public abstract class EventSourceListeningRequestBase
13 | {
14 | ///
15 | /// Gets or sets the name of the EventSource to listen to.
16 | ///
17 | public string Name { get; set; }
18 |
19 | ///
20 | /// Gets or sets a value indicating whether the value of the property should match the name of an EventSource exactly, or should the value be treated as EventSource name prefix.
21 | ///
22 | public bool PrefixMatch { get; set; }
23 |
24 | ///
25 | /// Tests for equality.
26 | ///
27 | /// Object to compare with.
28 | /// True if the supplied object is equal to "this", otherwise false.
29 | public override bool Equals(object obj)
30 | {
31 | var other = obj as EventSourceListeningRequestBase;
32 | if (other == null)
33 | {
34 | return false;
35 | }
36 |
37 | return string.Equals(this.Name, other.Name, System.StringComparison.Ordinal) && this.PrefixMatch == other.PrefixMatch;
38 | }
39 |
40 | ///
41 | /// Gets the hash code for the event source name matching rule.
42 | ///
43 | /// Hash code.
44 | public override int GetHashCode()
45 | {
46 | return this.Name.GetHashCode() ^ this.PrefixMatch.GetHashCode();
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/LOGGING/src/EventSourceListener/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All rights reserved.
4 | //
5 | //-----------------------------------------------------------------------
6 |
7 | using System;
8 | using System.Reflection;
9 | using System.Resources;
10 | using System.Runtime.CompilerServices;
11 | using System.Runtime.InteropServices;
12 |
13 | // General Information about an assembly is controlled through the following
14 | // set of attributes. Change these attribute values to modify the information
15 | // associated with an assembly.
16 | [assembly: AssemblyTitle("Microsoft.ApplicationInsights.EventSourceListener")]
17 | [assembly: AssemblyDescription("EventSourceListener is an Application Insights telemetry module that collects data from EventSource class instances.")]
18 |
19 | [assembly: NeutralResourcesLanguageAttribute("en-US")]
20 |
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 | [assembly: Guid("a539bb1d-29ff-48e8-8d6e-dfcc543dc2b4")]
25 |
26 | [assembly: InternalsVisibleTo("Microsoft.ApplicationInsights.EventSourceListener.NetCoreApp10.Tests, PublicKey=" + AssemblyInfo.PublicKey)]
27 |
28 | internal static class AssemblyInfo
29 | {
30 | // Public key; assemblies are delay signed or OSS signed
31 | public const string PublicKey = "0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9";
32 | }
33 |
--------------------------------------------------------------------------------
/LOGGING/src/ILogger/ApplicationInsightsLoggerOptions.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation.
4 | // All rights reserved. 2013
5 | //
6 | // -----------------------------------------------------------------------
7 |
8 | namespace Microsoft.Extensions.Logging.ApplicationInsights
9 | {
10 | using Microsoft.ApplicationInsights.DataContracts;
11 | using Microsoft.Extensions.Logging;
12 |
13 | ///
14 | /// defines the custom behavior of the tracing information sent to Application Insights.
15 | ///
16 | public class ApplicationInsightsLoggerOptions
17 | {
18 | ///
19 | /// Gets or sets a value indicating whether to track exceptions as .
20 | /// Defaults to true.
21 | ///
22 | public bool TrackExceptionsAsExceptionTelemetry { get; set; } = true;
23 |
24 | ///
25 | /// Gets or sets a value indicating whether the Scope information is included from telemetry or not.
26 | /// Defaults to true.
27 | ///
28 | public bool IncludeScopes { get; set; } = true;
29 | }
30 | }
--------------------------------------------------------------------------------
/LOGGING/src/ILogger/ILogger.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard2.0
4 | Microsoft.Extensions.Logging.ApplicationInsights
5 | Microsoft.Extensions.Logging.ApplicationInsights
6 |
7 |
8 |
9 |
10 |
11 |
12 | false
13 |
14 | true
15 |
16 |
17 | true
18 |
19 |
20 | $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb
21 |
22 |
23 |
24 |
25 | Microsoft.Extensions.Logging.ApplicationInsights
26 | Microsoft Logging Extensions for ApplicationInsights
27 | Application Insights ILogger allows forwarding events from ILogger to Application Insights. Application Insights will collect your logs from multiple sources and provide rich powerful search capabilities. Privacy statement: https://go.microsoft.com/fwlink/?LinkId=512156
28 | $(PackageTags) ILogger ILoggerBuilder ILoggerProvider
29 |
30 |
31 |
32 | full
33 | true
34 |
35 |
36 |
37 |
38 |
39 | All
40 |
41 |
42 | All
43 |
44 |
45 | All
46 |
47 |
48 |
49 |
50 |
51 |
52 | All
53 |
54 |
55 |
56 |
57 |
58 |
59 | all
60 | runtime; build; native; contentfiles; analyzers
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/LOGGING/src/ILogger/NullScope.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation.
4 | // All rights reserved. 2013
5 | //
6 | // -----------------------------------------------------------------------
7 |
8 | namespace Microsoft.Extensions.Logging.ApplicationInsights
9 | {
10 | using System;
11 |
12 | ///
13 | /// An empty scope without any logic.
14 | ///
15 | internal class NullScope : IDisposable
16 | {
17 | private NullScope()
18 | {
19 | }
20 |
21 | public static NullScope Instance { get; } = new NullScope();
22 |
23 | #pragma warning disable CA1063 // Implement IDisposable Correctly - Nothing at all to dispose.
24 | ///
25 | /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
26 | ///
27 | public void Dispose()
28 | #pragma warning restore CA1063 // Implement IDisposable Correctly - Nothing at all to dispose.
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/LOGGING/src/Log4NetAppender/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation.
4 | // All rights reserved. 2013
5 | //
6 | // -----------------------------------------------------------------------
7 |
8 | using System;
9 | using System.Reflection;
10 | using System.Resources;
11 | using System.Runtime.CompilerServices;
12 | using System.Runtime.InteropServices;
13 |
14 | // General Information about an assembly is controlled through the following
15 | // set of attributes. Change these attribute values to modify the information
16 | // associated with an assembly.
17 | [assembly: AssemblyTitle("Microsoft.ApplicationInsights.Log4NetAppender")]
18 | [assembly: AssemblyDescription("Application Insights Log4Net Appender is a customer appender allowing you to send Log4Net log messages to Application Insights. Application Insights will collect your logs from multiple sources and provide rich powerful search capabilities. This functionality depends on Microsoft Monitoring Agent being installed onto your machine, http://go.microsoft.com/fwlink/?LinkID=328052.")]
19 | [assembly: AssemblyTrademark("")]
20 | [assembly: AssemblyCulture("")]
21 |
22 | [assembly: NeutralResourcesLanguageAttribute("en-US")]
23 |
24 | // Setting ComVisible to false makes the types in this assembly not visible
25 | // to COM components. If you need to access a type in this assembly from
26 | // COM, set the ComVisible attribute to true on that type.
27 | [assembly: ComVisible(false)]
28 | [assembly: CLSCompliant(true)]
29 |
30 | // The following GUID is for the ID of the typelib if this project is exposed to COM
31 | [assembly: Guid("599daa99-7d0b-4cae-81b8-3a73509f2efa")]
32 |
33 | [assembly: InternalsVisibleTo("Microsoft.ApplicationInsights.Log4NetAppender.Net45.Tests, PublicKey=" + AssemblyInfo.PublicKey)]
34 | [assembly: InternalsVisibleTo("Microsoft.ApplicationInsights.Log4NetAppender.NetCoreApp10.Tests, PublicKey=" + AssemblyInfo.PublicKey)]
35 |
36 | internal static class AssemblyInfo
37 | {
38 | // Public key; assemblies are delay signed or OSS signed
39 | public const string PublicKey = "0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9";
40 | }
41 |
--------------------------------------------------------------------------------
/LOGGING/src/Log4NetAppender/GlobalSuppressions.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation.
4 | // All rights reserved. 2013
5 | //
6 | // -----------------------------------------------------------------------
7 |
8 | using System.Diagnostics.CodeAnalysis;
9 |
10 | [assembly: SuppressMessage("Microsoft.Naming", "CA1703:ResourceStringsShouldBeSpelledCorrectly", MessageId = "Appender", Scope = "resource", Target = "Microsoft.ApplicationInsights.Log4NetAppender.ApplicationInsightsAppenderResource.resources", Justification = "Appender is a well known name in Log4Net.")]
--------------------------------------------------------------------------------
/LOGGING/src/Log4NetAppender/Log4NetAppender.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net45;netstandard1.3
4 | Microsoft.ApplicationInsights.Log4NetAppender
5 | Microsoft.ApplicationInsights.Log4NetAppender
6 |
7 |
8 |
9 |
10 |
11 |
12 | true
13 |
14 |
15 |
16 |
17 | Microsoft.ApplicationInsights.Log4NetAppender
18 | Application Insights Log4Net Appender
19 | Application Insights Log4Net Appender is a customer appender allowing you to send Log4Net log messages to Application Insights. Application Insights will collect your logs from multiple sources and provide rich powerful search capabilities. Privacy statement: https://go.microsoft.com/fwlink/?LinkId=512156
20 | $(PackageTags) Log4Net
21 |
22 |
23 |
24 |
25 |
26 | All
27 |
28 |
29 | All
30 |
31 |
32 | All
33 |
34 |
35 |
36 |
37 |
38 |
39 | All
40 |
41 |
42 |
43 |
44 |
45 | All
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/LOGGING/src/Log4NetAppender/app.config.install.xdt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/LOGGING/src/Log4NetAppender/app.config.uninstall.xdt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/LOGGING/src/Log4NetAppender/web.config.install.xdt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/LOGGING/src/Log4NetAppender/web.config.uninstall.xdt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/LOGGING/src/NLogTarget/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation.
4 | // All rights reserved. 2013
5 | //
6 | // -----------------------------------------------------------------------
7 |
8 | using System;
9 | using System.Reflection;
10 | using System.Resources;
11 | using System.Runtime.CompilerServices;
12 | using System.Runtime.InteropServices;
13 |
14 | // General Information about an assembly is controlled through the following
15 | // set of attributes. Change these attribute values to modify the information
16 | // associated with an assembly.
17 | [assembly: AssemblyTitle("Microsoft.ApplicationInsights.NLogTarget")]
18 | [assembly: AssemblyDescription("Application Insights NLog Target is a custom target allowing you to send NLog log messages to Application Insights. Application Insights will collect your logs from multiple sources and provide rich powerful search capabilities. This functionality depends on Microsoft Monitoring Agent being installed onto your machine, http://go.microsoft.com/fwlink/?LinkID=328052.")]
19 | [assembly: AssemblyTrademark("")]
20 | [assembly: AssemblyCulture("")]
21 |
22 | [assembly: NeutralResourcesLanguageAttribute("en-US")]
23 |
24 | // Setting ComVisible to false makes the types in this assembly not visible
25 | // to COM components. If you need to access a type in this assembly from
26 | // COM, set the ComVisible attribute to true on that type.
27 | [assembly: ComVisible(false)]
28 | [assembly: CLSCompliant(true)]
29 |
30 | // The following GUID is for the ID of the typelib if this project is exposed to COM
31 | [assembly: Guid("44abc834-bd19-449f-ad64-f8c83ca078ed")]
32 |
33 | [assembly: InternalsVisibleTo("Microsoft.ApplicationInsights.NLogTarget.Net45.Tests, PublicKey=" + AssemblyInfo.PublicKey)]
34 | [assembly: InternalsVisibleTo("Microsoft.ApplicationInsights.NLogTarget.NetCoreApp10.Tests, PublicKey=" + AssemblyInfo.PublicKey)]
35 |
36 | internal static class AssemblyInfo
37 | {
38 | // Public key; assemblies are delay signed or OSS signed
39 | public const string PublicKey = "0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9";
40 | }
41 |
--------------------------------------------------------------------------------
/LOGGING/src/NLogTarget/NLogTarget.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net45;netstandard1.3
4 | Microsoft.ApplicationInsights.NLogTarget
5 | Microsoft.ApplicationInsights.NLogTarget
6 |
7 |
8 |
9 |
10 |
11 |
12 | true
13 |
14 |
15 |
16 |
17 | Microsoft.ApplicationInsights.NLogTarget
18 | Application Insights NLog Target
19 | Application Insights NLog Target is a custom target allowing you to send NLog log messages to Application Insights. Application Insights will collect your logs from multiple sources and provide rich powerful search capabilities. Privacy statement: https://go.microsoft.com/fwlink/?LinkId=512156
20 | $(PackageTags) NLog
21 |
22 |
23 |
24 |
25 |
26 | All
27 |
28 |
29 | All
30 |
31 |
32 | All
33 |
34 |
35 |
36 |
37 |
38 |
39 | All
40 |
41 |
42 |
43 |
44 |
45 | All
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/LOGGING/src/NLogTarget/TargetPropertyWithContext.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation.
4 | // All rights reserved. 2013
5 | //
6 | // -----------------------------------------------------------------------
7 |
8 | namespace Microsoft.ApplicationInsights.NLogTarget
9 | {
10 | using NLog.Config;
11 | using NLog.Layouts;
12 |
13 | ///
14 | /// NLog Target Context Property that allows capture of context information for all logevents (Ex. Layout=${threadid}).
15 | ///
16 | [NLogConfigurationItem]
17 | [ThreadAgnostic]
18 | public class TargetPropertyWithContext
19 | {
20 | ///
21 | /// Initializes a new instance of the class.
22 | ///
23 | public TargetPropertyWithContext() : this(null, null)
24 | {
25 | }
26 |
27 | ///
28 | /// Initializes a new instance of the class.
29 | ///
30 | /// The name of the attribute.
31 | /// The layout of the attribute's value.
32 | public TargetPropertyWithContext(string name, Layout layout)
33 | {
34 | this.Name = name;
35 | this.Layout = layout;
36 | }
37 |
38 | ///
39 | /// Gets or sets the name of the attribute.
40 | ///
41 | ///
42 | [RequiredParameter]
43 | public string Name { get; set; }
44 |
45 | ///
46 | /// Gets or sets the layout that will be rendered as the attribute's value.
47 | ///
48 | ///
49 | [RequiredParameter]
50 | public Layout Layout { get; set; }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/LOGGING/src/NLogTarget/app.config.install.xdt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/LOGGING/src/NLogTarget/app.config.uninstall.xdt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/LOGGING/src/NLogTarget/web.config.install.xdt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/LOGGING/src/NLogTarget/web.config.uninstall.xdt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/LOGGING/src/Product.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | $(RelativeOutputPathBase)
7 | $(BinRoot)\$(Configuration)\$(CorePath)
8 | $([System.IO.Path]::GetFullPath( $(OutputPath) ))\
9 |
10 |
11 |
12 | $(OutputPath)\$(TargetFramework)\$(AssemblyName).XML
13 | true
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/LOGGING/src/TraceListener/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation.
4 | // All rights reserved. 2013
5 | //
6 | // -----------------------------------------------------------------------
7 |
8 | using System;
9 | using System.Reflection;
10 | using System.Resources;
11 | using System.Runtime.CompilerServices;
12 | using System.Runtime.InteropServices;
13 |
14 | // General Information about an assembly is controlled through the following
15 | // set of attributes. Change these attribute values to modify the information
16 | // associated with an assembly.
17 | [assembly: AssemblyTitle("Microsoft.ApplicationInsights.TraceListener")]
18 | [assembly: AssemblyDescription("Application Insights Trace Listener is a customer trace listener allowing you to send trace log messages to Application Insights. Application Insights will collect your logs from multiple sources and provide rich powerful search capabilities. This functionality depends on Microsoft Monitoring Agent being installed onto your machine, http://go.microsoft.com/fwlink/?LinkID=328052.")]
19 | [assembly: AssemblyTrademark("")]
20 | [assembly: AssemblyCulture("")]
21 |
22 | [assembly: NeutralResourcesLanguageAttribute("en-US")]
23 |
24 | // Setting ComVisible to false makes the types in this assembly not visible
25 | // to COM components. If you need to access a type in this assembly from
26 | // COM, set the ComVisible attribute to true on that type.
27 | [assembly: ComVisible(false)]
28 | [assembly: CLSCompliant(true)]
29 |
30 | // The following GUID is for the ID of the typelib if this project is exposed to COM
31 | [assembly: Guid("3aada9bf-fc15-42fd-ace5-4cb2f11c1f2a")]
32 |
33 | [assembly: InternalsVisibleTo("Microsoft.ApplicationInsights.TraceListener.Net45.Tests, PublicKey=" + AssemblyInfo.PublicKey)]
34 | [assembly: InternalsVisibleTo("Microsoft.ApplicationInsights.TraceListener.NetCoreApp10.Tests, PublicKey=" + AssemblyInfo.PublicKey)]
35 |
36 | internal static class AssemblyInfo
37 | {
38 | // Public key; assemblies are delay signed or OSS signed
39 | public const string PublicKey = "0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9";
40 | }
41 |
--------------------------------------------------------------------------------
/LOGGING/src/TraceListener/TraceListener.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net45;netstandard1.3
4 | Microsoft.ApplicationInsights.TraceListener
5 | Microsoft.ApplicationInsights.TraceListener
6 |
7 |
8 |
9 |
10 |
11 |
12 | true
13 |
14 |
15 |
16 |
17 | Microsoft.ApplicationInsights.TraceListener
18 | Application Insights TraceListener
19 | Application Insights Trace Listener is a custom TraceListener allowing you to send trace log messages to Application Insights. Application Insights will collect your logs from multiple sources and provide rich powerful search capabilities. Privacy statement: https://go.microsoft.com/fwlink/?LinkId=512156
20 | $(PackageTags) TraceListener
21 |
22 |
23 |
24 |
25 |
26 | All
27 |
28 |
29 | All
30 |
31 |
32 | All
33 |
34 |
35 |
36 |
37 |
38 |
39 | All
40 |
41 |
42 |
43 |
44 |
45 | All
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/LOGGING/src/TraceListener/app.config.install.xdt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/LOGGING/src/TraceListener/app.config.uninstall.xdt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/LOGGING/src/TraceListener/web.config.install.xdt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/LOGGING/src/TraceListener/web.config.uninstall.xdt:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/LOGGING/test/CommonTestShared/CommonTestShared.projitems:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 | true
6 | 3b9ab7fa-562d-4e4e-86e3-3348426bc0d9
7 |
8 |
9 | CommonTestShared
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/LOGGING/test/CommonTestShared/CommonTestShared.shproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 3b9ab7fa-562d-4e4e-86e3-3348426bc0d9
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/LOGGING/test/CommonTestShared/SdkVersionHelper.cs:
--------------------------------------------------------------------------------
1 | namespace Microsoft.ApplicationInsights.CommonTestShared
2 | {
3 | using System;
4 | using System.Linq;
5 | using System.Reflection;
6 |
7 | public static class SdkVersionHelper
8 | {
9 | public static string GetExpectedSdkVersion(string prefix, Type loggerType)
10 | {
11 | #if NET45 || NET46
12 | string versionStr = loggerType.Assembly.GetCustomAttributes(false).OfType().First().Version;
13 | #else
14 | string versionStr = loggerType.GetTypeInfo().Assembly.GetCustomAttributes().First().Version;
15 | #endif
16 | string[] versionParts = new Version(versionStr).ToString().Split('.');
17 |
18 | return prefix + string.Join(".", versionParts[0], versionParts[1], versionParts[2]) + "-" + versionParts[3];
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/LOGGING/test/CommonTestShared/TelemetrySender.cs:
--------------------------------------------------------------------------------
1 | namespace Microsoft.ApplicationInsights.CommonTestShared
2 | {
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Diagnostics;
6 | using System.Net;
7 | using System.Net.Http;
8 | using System.Text;
9 | using Microsoft.ApplicationInsights.Channel;
10 | using Microsoft.ApplicationInsights.Extensibility.Implementation;
11 |
12 | internal static class TelemetrySender
13 | {
14 | ///
15 | /// Upload item to Validate endpoint.
16 | ///
17 | /// Telemetry item to validate.
18 | /// Empty string if no errors found. Response if validation failed.
19 | public static string ValidateEndpointSend(ITelemetry telemetryItem)
20 | {
21 | telemetryItem.Context.InstrumentationKey = "fafa4b10-03d3-4bb0-98f4-364f0bdf5df8";
22 |
23 | string response = null;
24 |
25 | string json = Encoding.UTF8.GetString(JsonSerializer.Serialize(new List { telemetryItem }, false));
26 |
27 | HttpClient client = new HttpClient();
28 | var result = client.PostAsync(
29 | new Uri("https://dc.services.visualstudio.com/v2/validate"),
30 | new ByteArrayContent(Encoding.UTF8.GetBytes(json))).GetAwaiter().GetResult();
31 |
32 | if (result.StatusCode != HttpStatusCode.OK)
33 | {
34 | response = result.Content.ReadAsStringAsync().GetAwaiter().GetResult();
35 | Trace.WriteLine(response);
36 | }
37 |
38 | return response;
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/LOGGING/test/DiagnosticSourceListener.netcoreapp10.Tests/DiagnosticSourceListener.netcoreapp1.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Microsoft.ApplicationInsights.DiagnosticSourceListener.Tests
5 | Microsoft.ApplicationInsights.DiagnosticSourceListener.NetCoreApp10.Tests
6 | netcoreapp1.0
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/LOGGING/test/DiagnosticSourceListener.netcoreapp10.Tests/TestDiagnosticSource.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All rights reserved.
4 | //
5 | //-----------------------------------------------------------------------
6 |
7 | namespace Microsoft.ApplicationInsights.DiagnosticSourceListener.Tests
8 | {
9 | using System.Diagnostics;
10 |
11 | internal class TestDiagnosticSource : DiagnosticListener
12 | {
13 | public const string ListenerName = nameof(TestDiagnosticSource);
14 |
15 | public TestDiagnosticSource(string listenerName = ListenerName) : base(listenerName)
16 | {
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/LOGGING/test/EtwCollector.Net451.Tests/EtwCollector.Net451.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Microsoft.ApplicationInsights.EtwCollector.Tests
5 | Microsoft.ApplicationInsights.EtwCollector.Net451.Tests
6 | net46
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/LOGGING/test/EtwCollector.Net451.Tests/EventSourceModuleDiagnosticListener.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All rights reserved.
4 | //
5 | //-----------------------------------------------------------------------
6 |
7 | namespace Microsoft.ApplicationInsights.EtwTelemetryCollector.Tests
8 | {
9 | using System.Collections.Generic;
10 | using System.Diagnostics.Tracing;
11 |
12 | internal class EventSourceModuleDiagnosticListener : EventListener
13 | {
14 | public EventSourceModuleDiagnosticListener()
15 | {
16 | this.EventsReceived = new List();
17 | }
18 |
19 | public IList EventsReceived { get; private set; }
20 |
21 | protected override void OnEventWritten(EventWrittenEventArgs eventData)
22 | {
23 | this.EventsReceived.Add(eventData);
24 | }
25 |
26 | protected override void OnEventSourceCreated(EventSource eventSource)
27 | {
28 | if (string.Equals(eventSource.Name, "Microsoft-ApplicationInsights-Extensibility-EventSourceListener", System.StringComparison.Ordinal))
29 | {
30 | EnableEvents(eventSource, EventLevel.LogAlways);
31 | }
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/LOGGING/test/EtwCollector.Net451.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Etw.Net451.Tests")]
9 | [assembly: AssemblyProduct("Etw.Net451.Tests")]
10 | [assembly: AssemblyCopyright("Copyright © 2017")]
11 |
12 | // Setting ComVisible to false makes the types in this assembly not visible
13 | // to COM components. If you need to access a type in this assembly from
14 | // COM, set the ComVisible attribute to true on that type.
15 | [assembly: ComVisible(false)]
16 |
17 | // The following GUID is for the ID of the typelib if this project is exposed to COM
18 | [assembly: Guid("15fa58d1-f397-4808-831c-7ae65ee640af")]
19 |
20 | // Version information for an assembly consists of the following four values:
21 | //
22 | // Major Version
23 | // Minor Version
24 | // Build Number
25 | // Revision
26 | //
27 | // You can specify all the values or you can default the Build and Revision Numbers
28 | // by using the '*' as shown below:
29 | // [assembly: AssemblyVersion("1.0.*")]
30 | // [assembly: AssemblyVersion("1.0.0.0")]
31 | // [assembly: AssemblyFileVersion("1.0.0.0")]
32 |
--------------------------------------------------------------------------------
/LOGGING/test/EtwCollector.Net451.Tests/TestProvider.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All rights reserved.
4 | //
5 | //-----------------------------------------------------------------------
6 |
7 | namespace Microsoft.ApplicationInsights.EtwTelemetryCollector.Tests
8 | {
9 | using System;
10 | using System.Diagnostics.Tracing;
11 |
12 | [EventSource(Name = TestProvider.ProviderName)]
13 | internal class TestProvider : EventSource
14 | {
15 | public const string ProviderName = "Microsoft-ApplicationInsights-Extensibility-Etw-Provider-Tests";
16 | public const int InfoEventId = 1;
17 | public const int WarningEventId = 2;
18 | public const int ComplexEventId = 4;
19 | public const int RequestStartEventId = 5;
20 | public const int RequestStopEventId = 6;
21 | public const int TrickyEventId = 7;
22 |
23 | public static readonly TestProvider Log = new TestProvider();
24 |
25 | [Event(InfoEventId, Level = EventLevel.Informational, Message = "{0}", Keywords = Keywords.Routine)]
26 | public void Info(string information)
27 | {
28 | WriteEvent(InfoEventId, information);
29 | }
30 |
31 | [Event(WarningEventId, Level = EventLevel.Warning, Message = "Warning!", Keywords = Keywords.NonRoutine)]
32 | public void Warning(int i1, int i2)
33 | {
34 | WriteEvent(WarningEventId, i1, i2);
35 | }
36 |
37 | [Event(ComplexEventId, Level = EventLevel.Verbose, Message = "Blah blah", Keywords = Keywords.Routine,
38 | Channel = EventChannel.Debug, Opcode = EventOpcode.Extension, Tags = (EventTags)17, Task = (EventTask)32)]
39 | public void Complex(Guid uniqueId)
40 | {
41 | WriteEvent(ComplexEventId, uniqueId);
42 | }
43 |
44 | [Event(TrickyEventId, Level = EventLevel.Informational, Message = "Manifest message")]
45 | public void Tricky(int EventId, string EventName, string Message)
46 | {
47 | WriteEvent(TrickyEventId, EventId, EventName, Message);
48 | }
49 |
50 | [Event(RequestStartEventId, Level = EventLevel.Informational, ActivityOptions = EventActivityOptions.Recursive)]
51 | public void RequestStart(int requestId)
52 | {
53 | WriteEvent(RequestStartEventId, requestId);
54 | }
55 |
56 | [Event(RequestStopEventId, Level = EventLevel.Informational, ActivityOptions = EventActivityOptions.Recursive)]
57 | public void RequestStop(int requestId)
58 | {
59 | WriteEvent(RequestStopEventId, requestId);
60 | }
61 |
62 | public class Keywords
63 | {
64 | public const EventKeywords Routine = (EventKeywords)0x01;
65 | public const EventKeywords NonRoutine = (EventKeywords)0x2;
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/LOGGING/test/EtwCollector.Net451.Tests/TraceEventSessionMock.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All rights reserved.
4 | //
5 | //-----------------------------------------------------------------------
6 |
7 | namespace Microsoft.ApplicationInsights.EtwTelemetryCollector.Tests
8 | {
9 | using System;
10 | using System.Collections.Generic;
11 | using Diagnostics.Tracing;
12 | using Diagnostics.Tracing.Session;
13 | using Microsoft.ApplicationInsights.EtwCollector;
14 |
15 | internal sealed class TraceEventSessionMock : ITraceEventSession
16 | {
17 | private bool isFakeAccessDenied;
18 |
19 | public List EnabledProviderNames { get; private set; }
20 |
21 | public List EnabledProviderGuids { get; private set; }
22 |
23 |
24 | public TraceEventSessionMock()
25 | : this(false)
26 | {
27 | }
28 |
29 | public TraceEventSessionMock(bool fakeAccessDeniedOnEnablingProvider)
30 | {
31 | this.EnabledProviderNames = new List();
32 | this.EnabledProviderGuids = new List();
33 | this.isFakeAccessDenied = fakeAccessDeniedOnEnablingProvider;
34 | }
35 |
36 | public TraceEventDispatcher Source { get; private set; }
37 |
38 | public void DisableProvider(Guid providerGuid)
39 | {
40 | if (this.isFakeAccessDenied)
41 | {
42 | throw new UnauthorizedAccessException("Access Denied.");
43 | }
44 |
45 | EnabledProviderGuids.Remove(providerGuid);
46 | }
47 |
48 | public void DisableProvider(string providerName)
49 | {
50 | if (this.isFakeAccessDenied)
51 | {
52 | throw new UnauthorizedAccessException("Access Denied.");
53 | }
54 |
55 | EnabledProviderNames.Remove(providerName);
56 | }
57 |
58 | public void Dispose()
59 | {
60 | }
61 |
62 | public bool EnableProvider(Guid providerGuid, TraceEventLevel providerLevel = TraceEventLevel.Verbose, ulong matchAnyKeywords = ulong.MaxValue, TraceEventProviderOptions options = null)
63 | {
64 | if (this.isFakeAccessDenied)
65 | {
66 | throw new UnauthorizedAccessException("Access Denied.");
67 | }
68 |
69 | this.EnabledProviderGuids.Add(providerGuid);
70 | return true;
71 | }
72 |
73 | public bool EnableProvider(string providerName, TraceEventLevel providerLevel = TraceEventLevel.Verbose, ulong matchAnyKeywords = ulong.MaxValue, TraceEventProviderOptions options = null)
74 | {
75 | if (this.isFakeAccessDenied)
76 | {
77 | throw new UnauthorizedAccessException("Access Denied.");
78 | }
79 |
80 | this.EnabledProviderNames.Add(providerName);
81 | return true;
82 | }
83 |
84 | #pragma warning disable CA1801 // Review unused parameters
85 | public bool Stop(bool noThrow = false)
86 | #pragma warning restore CA1801 // Review unused parameters
87 | {
88 | throw new NotImplementedException();
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/LOGGING/test/EtwCollector.Net451.Tests/TraceTelemetryComparer.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All rights reserved.
4 | //
5 | //-----------------------------------------------------------------------
6 |
7 | namespace Microsoft.ApplicationInsights.EtwTelemetryCollector.Tests
8 | {
9 | using System.Collections;
10 | using System.Collections.Generic;
11 | using Microsoft.ApplicationInsights.DataContracts;
12 |
13 | internal class TraceTelemetryComparer : IComparer
14 | {
15 | public int Compare(object x, object y)
16 | {
17 | TraceTelemetry template = x as TraceTelemetry;
18 | TraceTelemetry actual = y as TraceTelemetry;
19 |
20 | if (template == null || actual == null)
21 | {
22 | return Comparer.DefaultInvariant.Compare(x, y);
23 | }
24 |
25 | bool equal = string.Equals(template.Message, actual.Message, System.StringComparison.Ordinal)
26 | && template.SeverityLevel == actual.SeverityLevel
27 | && HaveProperties(template.Properties, actual.Properties);
28 | if (equal)
29 | {
30 | return 0;
31 | }
32 |
33 | return template.GetHashCode() < actual.GetHashCode() ? -1 : 1;
34 | }
35 |
36 | private bool HaveProperties(IDictionary template, IDictionary actual)
37 | {
38 | if (template.Count > actual.Count)
39 | {
40 | return false;
41 | }
42 |
43 | foreach (var kvp in template)
44 | {
45 | string actualValue;
46 | if (!actual.TryGetValue(kvp.Key, out actualValue))
47 | {
48 | return false;
49 | }
50 |
51 | if (!string.Equals(kvp.Value, actualValue, System.StringComparison.Ordinal))
52 | {
53 | return false;
54 | }
55 | }
56 |
57 | return true;
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/LOGGING/test/EventSourceListener.netcoreapp10.Tests/EventSourceListener.netcoreapp10.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | Properties
8 | Microsoft.ApplicationInsights.EventSourceListener.Tests
9 | Microsoft.ApplicationInsights.EventSourceListener.NetCoreApp10.Tests
10 | netcoreapp1.0
11 | 512
12 | false
13 | pdbonly
14 | true
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/LOGGING/test/EventSourceListener.netcoreapp10.Tests/EventSourceModuleDiagnosticListener.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All rights reserved.
4 | //
5 | //-----------------------------------------------------------------------
6 |
7 | namespace Microsoft.ApplicationInsights.EventSourceListener.Tests
8 | {
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Diagnostics.Tracing;
12 |
13 | internal class EventSourceModuleDiagnosticListener : EventListener
14 | {
15 | public EventSourceModuleDiagnosticListener()
16 | {
17 | this.EventsReceived = new List();
18 | }
19 |
20 | public IList EventsReceived { get; private set; }
21 |
22 | protected override void OnEventWritten(EventWrittenEventArgs eventData)
23 | {
24 | this.EventsReceived.Add(eventData.EventName);
25 | }
26 |
27 | protected override void OnEventSourceCreated(EventSource eventSource)
28 | {
29 | if (string.Equals(eventSource.Name, "Microsoft-ApplicationInsights-Extensibility-EventSourceListener", StringComparison.Ordinal))
30 | {
31 | EnableEvents(eventSource, EventLevel.LogAlways);
32 | }
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/LOGGING/test/EventSourceListener.netcoreapp10.Tests/OtherTestEventSource.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All rights reserved.
4 | //
5 | //-----------------------------------------------------------------------
6 |
7 | namespace Microsoft.ApplicationInsights.EventSourceListener.Tests
8 | {
9 | using System.Diagnostics.Tracing;
10 |
11 | [EventSource(Name = OtherTestEventSource.ProviderName)]
12 | internal class OtherTestEventSource : EventSource
13 | {
14 | public const string ProviderName = "Microsoft-ApplicationInsights-Extensibility-EventSourceListener-Tests-Other";
15 |
16 | [Event(3, Level = EventLevel.Informational, Message = "{0}")]
17 | public void Message(string message)
18 | {
19 | WriteEvent(3, message);
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/LOGGING/test/EventSourceListener.netcoreapp10.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation.
4 | // All rights reserved.
5 | //
6 | // -----------------------------------------------------------------------
7 |
8 | using System.Reflection;
9 | using System.Runtime.InteropServices;
10 |
11 | // General Information about an assembly is controlled through the following
12 | // set of attributes. Change these attribute values to modify the information
13 | // associated with an assembly.
14 | [assembly: AssemblyTitle("EventSource.Net46.Tests")]
15 | [assembly: AssemblyProduct("EventSource.Net46.Tests")]
16 | [assembly: AssemblyCopyright("Copyright © 2017")]
17 |
18 | // Setting ComVisible to false makes the types in this assembly not visible
19 | // to COM components. If you need to access a type in this assembly from
20 | // COM, set the ComVisible attribute to true on that type.
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 | [assembly: Guid("5d68573b-41f5-41e9-96e5-54c6a70a52ba")]
25 |
26 | // Version information for an assembly consists of the following four values:
27 | //
28 | // Major Version
29 | // Minor Version
30 | // Build Number
31 | // Revision
32 | //
33 | // You can specify all the values or you can default the Build and Revision Numbers
34 | // by using the '*' as shown below:
35 | // [assembly: AssemblyVersion("1.0.*")]
36 | // [assembly: AssemblyVersion("1.0.0.0")]
37 | // [assembly: AssemblyFileVersion("1.0.0.0")]
38 |
--------------------------------------------------------------------------------
/LOGGING/test/EventSourceListener.netcoreapp10.Tests/TestEventSource.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All rights reserved.
4 | //
5 | //-----------------------------------------------------------------------
6 |
7 | namespace Microsoft.ApplicationInsights.EventSourceListener.Tests
8 | {
9 | using System;
10 | using System.Diagnostics.Tracing;
11 |
12 | [EventSource(Name = TestEventSource.ProviderName)]
13 | internal class TestEventSource: EventSource
14 | {
15 | public const string ProviderName = "Microsoft-ApplicationInsights-Extensibility-EventSourceListener-Tests";
16 |
17 | public static readonly TestEventSource Default = new TestEventSource();
18 |
19 | public const int InfoEventId = 1;
20 |
21 | [Event(InfoEventId, Level = EventLevel.Informational, Message = "{0}", Keywords = Keywords.Routine)]
22 | public void InfoEvent(string information)
23 | {
24 | WriteEvent(InfoEventId, information);
25 | }
26 |
27 | public const int WarningEventId = 2;
28 |
29 | [Event(WarningEventId, Level = EventLevel.Warning, Message = "Warning!", Keywords = Keywords.NonRoutine)]
30 | public void WarningEvent(int i1, int i2)
31 | {
32 | WriteEvent(WarningEventId, i1, i2);
33 | }
34 |
35 | public const int ErrorEventId = 3;
36 |
37 | [Event(ErrorEventId, Level = EventLevel.Error, Message = "Error!", Keywords = Keywords.NonRoutine)]
38 | public void ErrorEvent(double value, string context)
39 | {
40 | WriteEvent(ErrorEventId, value, context);
41 | }
42 |
43 | public const int ComplexEventId = 4;
44 |
45 | [Event(ComplexEventId, Level = EventLevel.Verbose, Message = "Blah blah", Keywords = Keywords.Routine,
46 | Channel = EventChannel.Debug, Opcode = EventOpcode.Extension, Tags = (EventTags)17, Task = (EventTask)32)]
47 | public void ComplexEvent(Guid uniqueId)
48 | {
49 | WriteEvent(ComplexEventId, uniqueId);
50 | }
51 |
52 | public const int RequestStartEventId = 5;
53 |
54 | [Event(RequestStartEventId, Level = EventLevel.Informational, ActivityOptions = EventActivityOptions.Recursive)]
55 | public void RequestStart(int requestId)
56 | {
57 | WriteEvent(RequestStartEventId, requestId);
58 | }
59 |
60 | public const int RequestStopEventId = 6;
61 |
62 | [Event(RequestStopEventId, Level = EventLevel.Informational, ActivityOptions = EventActivityOptions.Recursive)]
63 | public void RequestStop(int requestId)
64 | {
65 | WriteEvent(RequestStopEventId, requestId);
66 | }
67 |
68 | public const int TrickyEventId = 7;
69 |
70 | [Event(TrickyEventId, Level = EventLevel.Informational, Message = "Manifest message")]
71 | public void Tricky(int EventId, string EventName, string Message)
72 | {
73 | WriteEvent(TrickyEventId, EventId, EventName, Message);
74 | }
75 |
76 | public class Keywords
77 | {
78 | public const EventKeywords Routine = (EventKeywords)0x01;
79 | public const EventKeywords NonRoutine = (EventKeywords)0x2;
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/LOGGING/test/EventSourceListener.netcoreapp10.Tests/TraceTelemetryComparer.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All rights reserved.
4 | //
5 | //-----------------------------------------------------------------------
6 |
7 | namespace Microsoft.ApplicationInsights.EventSourceListener.Tests
8 | {
9 | using System;
10 | using System.Collections;
11 | using System.Collections.Generic;
12 | using Microsoft.ApplicationInsights.DataContracts;
13 |
14 | internal class TraceTelemetryComparer : IComparer
15 | {
16 | public int Compare(object x, object y)
17 | {
18 | TraceTelemetry template = x as TraceTelemetry;
19 | TraceTelemetry actual = y as TraceTelemetry;
20 |
21 | if (template == null || actual == null)
22 | {
23 | return Comparer.DefaultInvariant.Compare(x, y);
24 | }
25 |
26 | bool equal = string.Equals(template.Message, actual.Message, StringComparison.Ordinal)
27 | && template.SeverityLevel == actual.SeverityLevel
28 | && HaveProperties(template.Properties, actual.Properties);
29 | if (equal)
30 | {
31 | return 0;
32 | }
33 |
34 | return template.GetHashCode() < actual.GetHashCode() ? -1 : 1;
35 | }
36 |
37 | private bool HaveProperties(IDictionary template, IDictionary actual)
38 | {
39 | if (template.Count > actual.Count)
40 | {
41 | return false;
42 | }
43 |
44 | foreach (var kvp in template)
45 | {
46 | string actualValue;
47 | if (!actual.TryGetValue(kvp.Key, out actualValue))
48 | {
49 | return false;
50 | }
51 |
52 | if (!string.Equals(kvp.Value, actualValue, StringComparison.Ordinal))
53 | {
54 | return false;
55 | }
56 | }
57 |
58 | return true;
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/LOGGING/test/ILogger.NetStandard.Tests/ILogger.NetStandard.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.1
5 | false
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/LOGGING/test/ILogger.NetStandard.Tests/TestTelemetryProcessor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using Microsoft.ApplicationInsights.Channel;
5 | using Microsoft.ApplicationInsights.Extensibility;
6 |
7 | namespace Microsoft.ApplicationInsights
8 | {
9 | ///
10 | /// Test telemetry processor which gives access to the telemetry items as it passes through the pipeline.
11 | ///
12 | internal class TestTelemetryProcessor : ITelemetryProcessor
13 | {
14 | private readonly ITelemetryProcessor nextTelemetryProcessor;
15 | private readonly Action telemetryActionCallback;
16 |
17 | ///
18 | /// Initializes a new instances of the class.
19 | ///
20 | /// Next telemetry processor to invoke.
21 | /// Action to invoke when the telemetry item is received.
22 | public TestTelemetryProcessor(ITelemetryProcessor nextTelemetryProcessor, Action telemetryActionCallback)
23 | {
24 | this.nextTelemetryProcessor = nextTelemetryProcessor;
25 | this.telemetryActionCallback = telemetryActionCallback;
26 | }
27 |
28 | ///
29 | /// Invokes the callback registered by the user.
30 | ///
31 | /// Telemetry item.
32 | public void Process(ITelemetry item)
33 | {
34 | telemetryActionCallback.Invoke(item, this.nextTelemetryProcessor);
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/LOGGING/test/Log4NetAppender.Net45.Tests/GlobalSuppressions.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation.
4 | // All rights reserved. 2013
5 | //
6 | // -----------------------------------------------------------------------
7 |
8 | using System.Diagnostics.CodeAnalysis;
9 |
10 | [assembly: SuppressMessage("Microsoft.Naming", "CA1703:ResourceStringsShouldBeSpelledCorrectly", MessageId = "Appender", Scope = "resource", Target = "Microsoft.ApplicationInsights.Log4NetAppender.ApplicationInsightsAppenderResource.resources", Justification = "Appender is a well known name in Log4Net.")]
--------------------------------------------------------------------------------
/LOGGING/test/Log4NetAppender.Net45.Tests/Log4NetAppender.Net45.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Microsoft.ApplicationInsights.Log4NetAppender.Tests
5 | Microsoft.ApplicationInsights.Log4NetAppender.Net45.Tests
6 | net45
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/LOGGING/test/Log4NetAppender.Net45.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation.
4 | // All rights reserved. 2013
5 | //
6 | // -----------------------------------------------------------------------
7 |
8 | using System.Reflection;
9 | using System.Runtime.CompilerServices;
10 | using System.Runtime.InteropServices;
11 |
12 | // General Information about an assembly is controlled through the following
13 | // set of attributes. Change these attribute values to modify the information
14 | // associated with an assembly.
15 | [assembly: AssemblyTitle("Log4NetAppender.Net45.Tests")]
16 | [assembly: AssemblyDescription("")]
17 | [assembly: AssemblyConfiguration("")]
18 | [assembly: AssemblyCompany("")]
19 | [assembly: AssemblyProduct("Log4NetAppender.Net45.Tests")]
20 | [assembly: AssemblyCopyright("Copyright © 2015")]
21 | [assembly: AssemblyTrademark("")]
22 | [assembly: AssemblyCulture("")]
23 |
24 | // Setting ComVisible to false makes the types in this assembly not visible
25 | // to COM components. If you need to access a type in this assembly from
26 | // COM, set the ComVisible attribute to true on that type.
27 | [assembly: ComVisible(false)]
28 |
29 | // The following GUID is for the ID of the typelib if this project is exposed to COM
30 | [assembly: Guid("8e16d10d-0483-429c-bbf1-3627e8ccc43b")]
31 |
32 | // Version information for an assembly consists of the following four values:
33 | //
34 | // Major Version
35 | // Minor Version
36 | // Build Number
37 | // Revision
38 | //
39 | // You can specify all the values or you can default the Build and Revision Numbers
40 | // by using the '*' as shown below:
41 | // [assembly: AssemblyVersion("1.0.*")]
42 | // [assembly: AssemblyVersion("1.0.0.0")]
43 | // [assembly: AssemblyFileVersion("1.0.0.0")]
44 |
--------------------------------------------------------------------------------
/LOGGING/test/Log4NetAppender.NetCoreApp10.Tests/Log4NetAppender.NetCoreApp10.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Microsoft.ApplicationInsights.Log4NetAppender.Tests
5 | Microsoft.ApplicationInsights.Log4NetAppender.NetCoreApp10.Tests
6 | netcoreapp1.0
7 | false
8 | false
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/LOGGING/test/NLogTarget.Net45.Tests/NLogTarget.Net45.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Microsoft.ApplicationInsights.NLogTarget.Tests
5 | Microsoft.ApplicationInsights.NLogTarget.Net45.Tests
6 | net45
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/LOGGING/test/NLogTarget.Net45.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation.
4 | // All rights reserved. 2013
5 | //
6 | // -----------------------------------------------------------------------
7 |
8 | using System.Reflection;
9 | using System.Runtime.CompilerServices;
10 | using System.Runtime.InteropServices;
11 |
12 | // General Information about an assembly is controlled through the following
13 | // set of attributes. Change these attribute values to modify the information
14 | // associated with an assembly.
15 | [assembly: AssemblyTitle("NLogTarget.Net45.Tests")]
16 | [assembly: AssemblyDescription("")]
17 | [assembly: AssemblyConfiguration("")]
18 | [assembly: AssemblyCompany("")]
19 | [assembly: AssemblyProduct("NLogTarget.Net45.Tests")]
20 | [assembly: AssemblyCopyright("Copyright © 2015")]
21 | [assembly: AssemblyTrademark("")]
22 | [assembly: AssemblyCulture("")]
23 |
24 | // Setting ComVisible to false makes the types in this assembly not visible
25 | // to COM components. If you need to access a type in this assembly from
26 | // COM, set the ComVisible attribute to true on that type.
27 | [assembly: ComVisible(false)]
28 |
29 | // The following GUID is for the ID of the typelib if this project is exposed to COM
30 | [assembly: Guid("0c3e416a-f95b-4c89-89d0-a8587c410aa2")]
31 |
32 | // Version information for an assembly consists of the following four values:
33 | //
34 | // Major Version
35 | // Minor Version
36 | // Build Number
37 | // Revision
38 | //
39 | // You can specify all the values or you can default the Build and Revision Numbers
40 | // by using the '*' as shown below:
41 | // [assembly: AssemblyVersion("1.0.*")]
42 | // [assembly: AssemblyVersion("1.0.0.0")]
43 | // [assembly: AssemblyFileVersion("1.0.0.0")]
44 |
--------------------------------------------------------------------------------
/LOGGING/test/NLogTarget.NetCoreApp10.Tests/NLogTarget.NetCoreApp10.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Microsoft.ApplicationInsights.NLogTarget.Tests
5 | Microsoft.ApplicationInsights.NLogTarget.NetCoreApp10.Tests
6 | netcoreapp1.0
7 | false
8 | false
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/LOGGING/test/Shared/AdapterHelper.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright © Microsoft. All Rights Reserved.
3 | //
4 |
5 | namespace Microsoft.ApplicationInsights.Tracing.Tests
6 | {
7 | using System;
8 | using System.Diagnostics;
9 | using System.IO;
10 | using System.Linq;
11 | using System.Reflection;
12 | using System.Threading;
13 | using Microsoft.ApplicationInsights.Channel;
14 | using Microsoft.VisualStudio.TestTools.UnitTesting;
15 |
16 | using static System.Globalization.CultureInfo;
17 |
18 | public class AdapterHelper : IDisposable
19 | {
20 | public string InstrumentationKey { get; }
21 |
22 | #if NET45 || NET46
23 | private static readonly string ApplicationInsightsConfigFilePath =
24 | Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ApplicationInsights.config");
25 | #else
26 | private static readonly string ApplicationInsightsConfigFilePath =
27 | Path.Combine(Path.GetDirectoryName(typeof(AdapterHelper).GetTypeInfo().Assembly.Location), "ApplicationInsights.config");
28 | #endif
29 |
30 | public AdapterHelper(string instrumentationKey = "F8474271-D231-45B6-8DD4-D344C309AE69")
31 | {
32 | this.InstrumentationKey = instrumentationKey;
33 |
34 | string configuration = string.Format(InvariantCulture,
35 | @"
36 |
37 | {0}
38 | ",
39 | instrumentationKey);
40 |
41 | File.WriteAllText(ApplicationInsightsConfigFilePath, configuration);
42 | this.Channel = new CustomTelemetryChannel();
43 | }
44 |
45 | internal CustomTelemetryChannel Channel { get; private set; }
46 |
47 | public static void ValidateChannel(AdapterHelper adapterHelper, string instrumentationKey, int expectedTraceCount)
48 | {
49 | // Validate that the channel received traces
50 | ITelemetry[] sentItems = null;
51 | int totalMillisecondsToWait = (int)TimeSpan.FromMinutes(1).TotalMilliseconds;
52 | const int IterationMilliseconds = 250;
53 |
54 | while (totalMillisecondsToWait > 0)
55 | {
56 | sentItems = adapterHelper.Channel.SentItems;
57 | if (sentItems.Length > 0)
58 | {
59 | ITelemetry telemetry = sentItems.FirstOrDefault();
60 |
61 | Assert.AreEqual(expectedTraceCount, sentItems.Length, "All messages are received by the channel");
62 | Assert.IsNotNull(telemetry, "telemetry collection is not null");
63 | Assert.AreEqual(instrumentationKey, telemetry.Context.InstrumentationKey, "The correct instrumentation key was used");
64 | break;
65 | }
66 |
67 | Thread.Sleep(IterationMilliseconds);
68 | totalMillisecondsToWait -= IterationMilliseconds;
69 | }
70 |
71 | Assert.IsNotNull(sentItems);
72 | Assert.IsTrue(sentItems.Length > 0);
73 | }
74 |
75 | public void Dispose()
76 | {
77 | this.Dispose(true);
78 | GC.SuppressFinalize(this);
79 | }
80 |
81 | protected virtual void Dispose(bool disposing)
82 | {
83 | if (disposing)
84 | {
85 | this.Channel.Dispose();
86 |
87 | if (File.Exists(ApplicationInsightsConfigFilePath))
88 | {
89 | File.Delete(ApplicationInsightsConfigFilePath);
90 | }
91 | }
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/LOGGING/test/Shared/Adapters.Shared.Tests.projitems:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {f98378a4-637d-4285-92f2-911f9ff82291}
5 |
6 |
7 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
8 | true
9 | fa775630-7917-4a99-a78c-fba46edf685c
10 |
11 |
12 | Microsoft.ApplicationInsights
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/LOGGING/test/Shared/Adapters.Shared.Tests.shproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | fa775630-7917-4a99-a78c-fba46edf685c
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/LOGGING/test/Shared/ApplicationInsightsTraceFilterTests.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation.
4 | // All rights reserved. 2013
5 | //
6 | // -----------------------------------------------------------------------
7 |
8 | namespace Microsoft.ApplicationInsights.TraceListener.Tests
9 | {
10 | using System;
11 | using System.Diagnostics;
12 | using Microsoft.ApplicationInsights.Extensibility;
13 | using Microsoft.ApplicationInsights.Tracing.Tests;
14 | using Microsoft.VisualStudio.TestTools.UnitTesting;
15 |
16 | [TestClass]
17 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable", Justification = "Disposing the object on the TestCleanup method")]
18 | public class ApplicationInsightsTraceFilterTests
19 | {
20 | private AdapterHelper adapterHelper;
21 |
22 | public TestContext TestContext { get; set; }
23 |
24 | [TestInitialize]
25 | public void Initialize()
26 | {
27 | this.adapterHelper = new AdapterHelper();
28 | }
29 |
30 | [TestCleanup]
31 | public void Cleanup()
32 | {
33 | this.adapterHelper.Dispose();
34 | }
35 |
36 | [TestMethod]
37 | [TestCategory("TraceListener")]
38 | public void RespectFilterForWrite()
39 | {
40 | this.TraceFilterTestHelper(
41 | (ApplicationInsightsTraceListener traceListener, TraceEventCache shimTraceEventCache) =>
42 | traceListener.Write("message"),
43 | false,
44 | SourceLevels.Warning);
45 | }
46 |
47 | [TestMethod]
48 | [TestCategory("TraceListener")]
49 | public void TreatWriteAsVerbose()
50 | {
51 | this.TraceFilterTestHelper(
52 | (ApplicationInsightsTraceListener traceListener, TraceEventCache shimTraceEventCache) =>
53 | traceListener.Write("message"),
54 | true,
55 | SourceLevels.Verbose);
56 | }
57 |
58 | [TestMethod]
59 | [TestCategory("TraceListener")]
60 | public void RespectFilterForWriteLine()
61 | {
62 | this.TraceFilterTestHelper(
63 | (ApplicationInsightsTraceListener traceListener, TraceEventCache shimTraceEventCache) =>
64 | traceListener.WriteLine("message"),
65 | false,
66 | SourceLevels.Warning);
67 | }
68 |
69 | [TestMethod]
70 | [TestCategory("TraceListener")]
71 | public void TreatWriteLineAsVerbose()
72 | {
73 | this.TraceFilterTestHelper(
74 | (ApplicationInsightsTraceListener traceListener, TraceEventCache shimTraceEventCache) =>
75 | traceListener.WriteLine("message"),
76 | true,
77 | SourceLevels.Verbose);
78 | }
79 |
80 | private void TraceFilterTestHelper(
81 | Action callTraceEent,
82 | bool shouldTrace,
83 | SourceLevels filterLevel = SourceLevels.Warning)
84 | {
85 | TraceEventCache shimTraceEventCache = new TraceEventCache();
86 |
87 | using (var traceListener = new ApplicationInsightsTraceListener(this.adapterHelper.InstrumentationKey))
88 | {
89 | var telemetryConfiguration = new TelemetryConfiguration
90 | {
91 | InstrumentationKey = Guid.NewGuid().ToString(),
92 | TelemetryChannel = this.adapterHelper.Channel
93 | };
94 |
95 | traceListener.TelemetryClient = new TelemetryClient(telemetryConfiguration);
96 |
97 | var traceFilter = new EventTypeFilter(filterLevel);
98 | traceListener.Filter = traceFilter;
99 |
100 | callTraceEent(traceListener, shimTraceEventCache);
101 |
102 | Assert.AreEqual(shouldTrace, this.adapterHelper.Channel.SentItems.Length == 1);
103 | }
104 | }
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/LOGGING/test/Shared/CustomTelemetryChannel.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All Rights Reserved.
4 | // Information Contained Herein is Proprietary and Confidential.
5 | //
6 | //-----------------------------------------------------------------------------------
7 |
8 | namespace Microsoft.ApplicationInsights
9 | {
10 | using System;
11 | using System.Collections.Generic;
12 | using System.Threading;
13 | using System.Threading.Tasks;
14 | using Microsoft.ApplicationInsights.Channel;
15 | using Microsoft.ApplicationInsights.DataContracts;
16 |
17 | internal sealed class CustomTelemetryChannel : ITelemetryChannel
18 | {
19 | private EventWaitHandle waitHandle;
20 |
21 | public CustomTelemetryChannel()
22 | {
23 | this.waitHandle = new AutoResetEvent(false);
24 | #if NET45
25 | this.SentItems = new ITelemetry[0];
26 | #else
27 | this.SentItems = Array.Empty();
28 | #endif
29 | }
30 |
31 | public bool? DeveloperMode { get; set; }
32 |
33 | public string EndpointAddress { get; set; }
34 |
35 | public ITelemetry[] SentItems { get; private set; }
36 |
37 | public void Send(ITelemetry item)
38 | {
39 | lock (this)
40 | {
41 | ITelemetry[] current = this.SentItems;
42 | List temp = new List(current);
43 | temp.Add(item);
44 | this.SentItems = temp.ToArray();
45 | this.waitHandle.Set();
46 | }
47 | }
48 |
49 | public Task WaitForItemsCaptured(TimeSpan timeout)
50 | {
51 | // Pattern for Wait Handles from: https://msdn.microsoft.com/en-us/library/hh873178%28v=vs.110%29.aspx#WaitHandles
52 | var tcs = new TaskCompletionSource();
53 |
54 | var rwh = ThreadPool.RegisterWaitForSingleObject(
55 | this.waitHandle,
56 | (state, timedOut) =>
57 | {
58 | if (timedOut)
59 | {
60 | tcs.SetResult(null);
61 | }
62 | else
63 | {
64 | lock (this)
65 | {
66 | tcs.SetResult(this.SentItems.Length);
67 | }
68 | }
69 | },
70 | state: null,
71 | millisecondsTimeOutInterval: Convert.ToUInt32(timeout.TotalMilliseconds),
72 | executeOnlyOnce: true);
73 |
74 | var t = tcs.Task;
75 | t.ContinueWith((previousTask) => rwh.Unregister(null));
76 | return t;
77 | }
78 |
79 | public void Flush()
80 | {
81 | throw new Exception("Flush called");
82 | }
83 |
84 | public void Dispose()
85 | {
86 | }
87 |
88 | public CustomTelemetryChannel Reset()
89 | {
90 | lock (this)
91 | {
92 | #if NET45
93 | this.SentItems = new ITelemetry[0];
94 | #else
95 | this.SentItems = Array.Empty();
96 | #endif
97 | }
98 |
99 | return this;
100 | }
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/LOGGING/test/Shared/ExceptionAssert.cs:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation. All rights reserved.
4 | //
5 | //-----------------------------------------------------------------------
6 |
7 | namespace Microsoft.ApplicationInsights.Tests
8 | {
9 | using System;
10 | using VisualStudio.TestTools.UnitTesting;
11 |
12 | public static class ExceptionAssert
13 | {
14 | public static void Throws(Action action, Action notifyException = null) where TException : Exception
15 | {
16 | try
17 | {
18 | action();
19 | throw new AssertFailedException($"An exception of type {typeof(TException)} was expected, but was not thrown");
20 | }
21 | catch (TException ex)
22 | {
23 | if (notifyException != null)
24 | {
25 | notifyException(ex);
26 | }
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/LOGGING/test/TraceListener.Net45.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation.
4 | // All rights reserved. 2013
5 | //
6 | // -----------------------------------------------------------------------
7 |
8 | using System.Reflection;
9 | using System.Runtime.CompilerServices;
10 | using System.Runtime.InteropServices;
11 |
12 | // General Information about an assembly is controlled through the following
13 | // set of attributes. Change these attribute values to modify the information
14 | // associated with an assembly.
15 | [assembly: AssemblyTitle("TraceListener.Net45.Tests")]
16 | [assembly: AssemblyDescription("")]
17 | [assembly: AssemblyConfiguration("")]
18 | [assembly: AssemblyCompany("")]
19 | [assembly: AssemblyProduct("TraceListener.Net45.Tests")]
20 | [assembly: AssemblyCopyright("Copyright © 2015")]
21 | [assembly: AssemblyTrademark("")]
22 | [assembly: AssemblyCulture("")]
23 |
24 | // Setting ComVisible to false makes the types in this assembly not visible
25 | // to COM components. If you need to access a type in this assembly from
26 | // COM, set the ComVisible attribute to true on that type.
27 | [assembly: ComVisible(false)]
28 |
29 | // The following GUID is for the ID of the typelib if this project is exposed to COM
30 | [assembly: Guid("11c52509-71a7-49a9-9af1-3ba86071015c")]
31 |
32 | // Version information for an assembly consists of the following four values:
33 | //
34 | // Major Version
35 | // Minor Version
36 | // Build Number
37 | // Revision
38 | //
39 | // You can specify all the values or you can default the Build and Revision Numbers
40 | // by using the '*' as shown below:
41 | // [assembly: AssemblyVersion("1.0.*")]
42 | // [assembly: AssemblyVersion("1.0.0.0")]
43 | // [assembly: AssemblyFileVersion("1.0.0.0")]
44 |
--------------------------------------------------------------------------------
/LOGGING/test/TraceListener.Net45.Tests/TraceEventOptionsMatrix.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Callstack,Timestamp,LogicalOperationStack
5 |
6 |
7 | Callstack
8 |
9 |
10 | Timestamp
11 |
12 |
13 | LogicalOperationStack
14 |
15 |
16 | None
17 |
18 |
19 |
--------------------------------------------------------------------------------
/LOGGING/test/TraceListener.Net45.Tests/TraceFilterMatrix.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Warning
5 | true
6 |
7 |
8 | Verbose
9 | false
10 |
11 |
12 |
--------------------------------------------------------------------------------
/LOGGING/test/TraceListener.Net45.Tests/TraceListener.Net45.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Microsoft.ApplicationInsights.TraceListener.Tests
5 | Microsoft.ApplicationInsights.TraceListener.Net45.Tests
6 | net45
7 | false
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/LOGGING/test/TraceListener.netcoreapp10.Tests/TraceListener.netcoreapp10.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Microsoft.ApplicationInsights.TraceListener.Tests
5 | Microsoft.ApplicationInsights.TraceListener.NetCoreApp10.Tests
6 | netcoreapp1.0
7 | false
8 | false
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/LOGGING/test/Xdt.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // Copyright (c) Microsoft Corporation.
4 | // All rights reserved. 2014
5 | //
6 | // -----------------------------------------------------------------------
7 |
8 | using System.Reflection;
9 | using System.Runtime.CompilerServices;
10 | using System.Runtime.InteropServices;
11 |
12 | // General Information about an assembly is controlled through the following
13 | // set of attributes. Change these attribute values to modify the information
14 | // associated with an assembly.
15 | [assembly: AssemblyTitle("Xdt.Tests")]
16 | [assembly: AssemblyDescription("")]
17 | [assembly: AssemblyConfiguration("")]
18 | [assembly: AssemblyCompany("")]
19 | [assembly: AssemblyProduct("Xdt.Tests")]
20 | [assembly: AssemblyCopyright("Copyright © 2014")]
21 | [assembly: AssemblyTrademark("")]
22 | [assembly: AssemblyCulture("")]
23 |
24 | // Setting ComVisible to false makes the types in this assembly not visible
25 | // to COM components. If you need to access a type in this assembly from
26 | // COM, set the ComVisible attribute to true on that type.
27 | [assembly: ComVisible(false)]
28 |
29 | // The following GUID is for the ID of the typelib if this project is exposed to COM
30 | [assembly: Guid("0cde476e-a4fb-4c0c-8dea-d8e65a753274")]
31 |
--------------------------------------------------------------------------------
/LOGGING/test/Xdt.Tests/Resources/DiagnosticSourceListener/TestDataSet.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 | 4f563a32-8ceb-4481-a987-1b2e9ea91aab
8 |
9 |
10 |
11 |
12 |
13 | 4f563a32-8ceb-4481-a987-1b2e9ea91aab
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | -
26 |
27 |
28 |
29 | 4f563a32-8ceb-4481-a987-1b2e9ea91aab
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | 4f563a32-8ceb-4481-a987-1b2e9ea91aab
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/LOGGING/test/Xdt.Tests/Resources/EtwCollector/TestDataSet.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 | 4f563a32-8ceb-4481-a987-1b2e9ea91aab
8 |
9 |
10 |
11 |
12 |
13 | 4f563a32-8ceb-4481-a987-1b2e9ea91aab
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | -
26 |
27 |
28 |
29 | 4f563a32-8ceb-4481-a987-1b2e9ea91aab
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | 4f563a32-8ceb-4481-a987-1b2e9ea91aab
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/LOGGING/test/Xdt.Tests/Resources/EventSourceListener/TestDataSet.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 | 4f563a32-8ceb-4481-a987-1b2e9ea91aab
8 |
9 |
10 |
11 |
12 |
13 | 4f563a32-8ceb-4481-a987-1b2e9ea91aab
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | -
26 |
27 |
28 |
29 | 4f563a32-8ceb-4481-a987-1b2e9ea91aab
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | 4f563a32-8ceb-4481-a987-1b2e9ea91aab
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/LOGGING/test/Xdt.Tests/Resources/TraceListener/TestDataSet.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 | -
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 | -
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------