Skip to content

Commit d8d6617

Browse files
add minimal web forms sample application (#381)
* add new simpler web forms sample application * don't throw exception if Datadog.Trace.ClrProfiler.Native.dll is not found
1 parent c65ec17 commit d8d6617

15 files changed

+424
-0
lines changed

Datadog.Trace.sln

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ EndProject
138138
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.Shared", "sample-libs\Samples.Shared\Samples.Shared.csproj", "{B4AE8B0F-C2B2-41DF-88BB-D97E267D8964}"
139139
EndProject
140140
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples.WebForms", "samples-aspnet\Samples.WebForms\Samples.WebForms.csproj", "{99A62CCF-8E7F-4D57-8383-D38C371C8087}"
141+
ProjectSection(ProjectDependencies) = postProject
142+
{C0C8D381-D6B9-4C76-9428-F40F2FA93A9A} = {C0C8D381-D6B9-4C76-9428-F40F2FA93A9A}
143+
EndProjectSection
141144
EndProject
142145
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "reproductions", "reproductions", "{550AE553-2BBB-4021-B55A-137EF31A6B1F}"
143146
ProjectSection(SolutionItems) = preProject
@@ -164,6 +167,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.ServiceStack.Redis"
164167
EndProject
165168
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.StackExchange.Redis", "samples\Samples.StackExchange.Redis\Samples.StackExchange.Redis.csproj", "{DC7D131A-AF99-46AB-9AA6-463443E3B992}"
166169
EndProject
170+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples.WebForms.Empty", "samples-aspnet\Samples.WebForms.Empty\Samples.WebForms.Empty.csproj", "{673826CD-9219-4231-8FCF-4F9C8BE61F76}"
171+
ProjectSection(ProjectDependencies) = postProject
172+
{C0C8D381-D6B9-4C76-9428-F40F2FA93A9A} = {C0C8D381-D6B9-4C76-9428-F40F2FA93A9A}
173+
EndProjectSection
174+
EndProject
167175
Global
168176
GlobalSection(SolutionConfigurationPlatforms) = preSolution
169177
Debug|Any CPU = Debug|Any CPU
@@ -546,6 +554,18 @@ Global
546554
{DC7D131A-AF99-46AB-9AA6-463443E3B992}.Release|x64.Build.0 = Release|x64
547555
{DC7D131A-AF99-46AB-9AA6-463443E3B992}.Release|x86.ActiveCfg = Release|x86
548556
{DC7D131A-AF99-46AB-9AA6-463443E3B992}.Release|x86.Build.0 = Release|x86
557+
{673826CD-9219-4231-8FCF-4F9C8BE61F76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
558+
{673826CD-9219-4231-8FCF-4F9C8BE61F76}.Debug|Any CPU.Build.0 = Debug|Any CPU
559+
{673826CD-9219-4231-8FCF-4F9C8BE61F76}.Debug|x64.ActiveCfg = Debug|Any CPU
560+
{673826CD-9219-4231-8FCF-4F9C8BE61F76}.Debug|x64.Build.0 = Debug|Any CPU
561+
{673826CD-9219-4231-8FCF-4F9C8BE61F76}.Debug|x86.ActiveCfg = Debug|Any CPU
562+
{673826CD-9219-4231-8FCF-4F9C8BE61F76}.Debug|x86.Build.0 = Debug|Any CPU
563+
{673826CD-9219-4231-8FCF-4F9C8BE61F76}.Release|Any CPU.ActiveCfg = Release|Any CPU
564+
{673826CD-9219-4231-8FCF-4F9C8BE61F76}.Release|Any CPU.Build.0 = Release|Any CPU
565+
{673826CD-9219-4231-8FCF-4F9C8BE61F76}.Release|x64.ActiveCfg = Release|Any CPU
566+
{673826CD-9219-4231-8FCF-4F9C8BE61F76}.Release|x64.Build.0 = Release|Any CPU
567+
{673826CD-9219-4231-8FCF-4F9C8BE61F76}.Release|x86.ActiveCfg = Release|Any CPU
568+
{673826CD-9219-4231-8FCF-4F9C8BE61F76}.Release|x86.Build.0 = Release|Any CPU
549569
EndGlobalSection
550570
GlobalSection(SolutionProperties) = preSolution
551571
HideSolutionNode = FALSE
@@ -585,6 +605,7 @@ Global
585605
{24B0357D-B0C8-46C7-96F6-006E3F66662A} = {5D8E1F81-B820-4736-B797-271B0FE787EE}
586606
{8E1555D1-13D5-4DBF-9631-117D840C3158} = {AA6F5582-3B71-49AC-AA39-8F7815AC46BE}
587607
{DC7D131A-AF99-46AB-9AA6-463443E3B992} = {AA6F5582-3B71-49AC-AA39-8F7815AC46BE}
608+
{673826CD-9219-4231-8FCF-4F9C8BE61F76} = {65DF5743-B7B5-4BC8-8AB5-9DE596AF3FB8}
588609
EndGlobalSection
589610
GlobalSection(ExtensibilityGlobals) = postSolution
590611
SolutionGuid = {160A1D00-1F5B-40F8-A155-621B4459D78F}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Runtime.InteropServices;
3+
4+
namespace Samples.WebForms.Empty
5+
{
6+
public static class Profiler
7+
{
8+
public static bool IsAttached
9+
{
10+
get
11+
{
12+
try
13+
{
14+
return IsProfilerAttached();
15+
}
16+
catch (DllNotFoundException)
17+
{
18+
return false;
19+
}
20+
}
21+
}
22+
23+
[DllImport("Datadog.Trace.ClrProfiler.Native.dll")]
24+
private static extern bool IsProfilerAttached();
25+
}
26+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Samples.WebForms.Empty.Default" %>
2+
3+
<!DOCTYPE html>
4+
5+
<html xmlns="http://www.w3.org/1999/xhtml">
6+
<head runat="server">
7+
<title>Home</title>
8+
</head>
9+
<body>
10+
<form id="form1" runat="server">
11+
<h2>Home</h2>
12+
<div><%: DateTime.Now %></div>
13+
<div>Profiler attached: <%: Samples.WebForms.Empty.Profiler.IsAttached %></div>
14+
</form>
15+
</body>
16+
</html>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
3+
namespace Samples.WebForms.Empty
4+
{
5+
public partial class Default : System.Web.UI.Page
6+
{
7+
protected void Page_Load(object sender, EventArgs e)
8+
{
9+
10+
}
11+
}
12+
}

samples-aspnet/Samples.WebForms.Empty/Default.aspx.designer.cs

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Elasticsearch.aspx.cs" Inherits="Samples.WebForms.Empty.Elasticsearch" %>
2+
3+
<!DOCTYPE html>
4+
5+
<html xmlns="http://www.w3.org/1999/xhtml">
6+
<head runat="server">
7+
<title>Elasticsearch</title>
8+
</head>
9+
<body>
10+
<form id="form1" runat="server">
11+
<h2>Elasticsearch</h2>
12+
<div><%: DateTime.Now %></div>
13+
<div>Profiler attached: <%: Samples.WebForms.Empty.Profiler.IsAttached %></div>
14+
</form>
15+
</body>
16+
</html>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using Nest;
3+
4+
namespace Samples.WebForms.Empty
5+
{
6+
public partial class Elasticsearch : System.Web.UI.Page
7+
{
8+
protected void Page_Load(object sender, EventArgs e)
9+
{
10+
var host = Environment.GetEnvironmentVariable("ELASTICSEARCH_HOST") ?? "localhost";
11+
var uri = new Uri($"http://{host}:9200");
12+
var settings = new ConnectionSettings(uri).DefaultIndex("elastic-net-example");
13+
var elastic = new ElasticClient(settings);
14+
elastic.ClusterHealth(new ClusterHealthRequest());
15+
}
16+
}
17+
}

samples-aspnet/Samples.WebForms.Empty/Elasticsearch.aspx.designer.cs

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<Import Project="..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProductVersion>
8+
</ProductVersion>
9+
<SchemaVersion>2.0</SchemaVersion>
10+
<ProjectGuid>{673826CD-9219-4231-8FCF-4F9C8BE61F76}</ProjectGuid>
11+
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
12+
<OutputType>Library</OutputType>
13+
<AppDesignerFolder>Properties</AppDesignerFolder>
14+
<RootNamespace>Samples.WebForms.Empty</RootNamespace>
15+
<AssemblyName>Samples.WebForms.Empty</AssemblyName>
16+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
17+
<UseIISExpress>true</UseIISExpress>
18+
<Use64BitIISExpress>true</Use64BitIISExpress>
19+
<IISExpressSSLPort>44371</IISExpressSSLPort>
20+
<IISExpressAnonymousAuthentication />
21+
<IISExpressWindowsAuthentication />
22+
<IISExpressUseClassicPipelineMode />
23+
<UseGlobalApplicationHostFile />
24+
<NuGetPackageImportStamp>
25+
</NuGetPackageImportStamp>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
28+
<DebugSymbols>true</DebugSymbols>
29+
<DebugType>full</DebugType>
30+
<Optimize>false</Optimize>
31+
<OutputPath>bin\</OutputPath>
32+
<DefineConstants>DEBUG;TRACE</DefineConstants>
33+
<ErrorReport>prompt</ErrorReport>
34+
<WarningLevel>4</WarningLevel>
35+
</PropertyGroup>
36+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
37+
<DebugSymbols>true</DebugSymbols>
38+
<DebugType>pdbonly</DebugType>
39+
<Optimize>true</Optimize>
40+
<OutputPath>bin\</OutputPath>
41+
<DefineConstants>TRACE</DefineConstants>
42+
<ErrorReport>prompt</ErrorReport>
43+
<WarningLevel>4</WarningLevel>
44+
</PropertyGroup>
45+
<ItemGroup>
46+
<Reference Include="Elasticsearch.Net, Version=6.0.0.0, Culture=neutral, PublicKeyToken=96c599bbe3e70f5d, processorArchitecture=MSIL">
47+
<HintPath>..\..\packages\Elasticsearch.Net.6.1.0\lib\net45\Elasticsearch.Net.dll</HintPath>
48+
</Reference>
49+
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
50+
<HintPath>..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
51+
</Reference>
52+
<Reference Include="Microsoft.CSharp" />
53+
<Reference Include="Nest, Version=6.0.0.0, Culture=neutral, PublicKeyToken=96c599bbe3e70f5d, processorArchitecture=MSIL">
54+
<HintPath>..\..\packages\NEST.6.1.0\lib\net45\Nest.dll</HintPath>
55+
</Reference>
56+
<Reference Include="System.Web.DynamicData" />
57+
<Reference Include="System.Web.Entity" />
58+
<Reference Include="System.Web.ApplicationServices" />
59+
<Reference Include="System.ComponentModel.DataAnnotations" />
60+
<Reference Include="System" />
61+
<Reference Include="System.Data" />
62+
<Reference Include="System.Core" />
63+
<Reference Include="System.Data.DataSetExtensions" />
64+
<Reference Include="System.Web.Extensions" />
65+
<Reference Include="System.Xml.Linq" />
66+
<Reference Include="System.Drawing" />
67+
<Reference Include="System.Web" />
68+
<Reference Include="System.Xml" />
69+
<Reference Include="System.Configuration" />
70+
<Reference Include="System.Web.Services" />
71+
<Reference Include="System.EnterpriseServices" />
72+
</ItemGroup>
73+
<ItemGroup>
74+
<Content Include="Default.aspx" />
75+
<Content Include="Elasticsearch.aspx" />
76+
<Content Include="SqlServer.aspx" />
77+
<Content Include="Web.config" />
78+
</ItemGroup>
79+
<ItemGroup>
80+
<Compile Include="SqlServer.aspx.cs">
81+
<DependentUpon>SqlServer.aspx</DependentUpon>
82+
<SubType>ASPXCodeBehind</SubType>
83+
</Compile>
84+
<Compile Include="SqlServer.aspx.designer.cs">
85+
<DependentUpon>SqlServer.aspx</DependentUpon>
86+
</Compile>
87+
<Content Include="App_Code\Profiler.cs" />
88+
<Compile Include="Default.aspx.cs">
89+
<DependentUpon>Default.aspx</DependentUpon>
90+
<SubType>ASPXCodeBehind</SubType>
91+
</Compile>
92+
<Compile Include="Default.aspx.designer.cs">
93+
<DependentUpon>Default.aspx</DependentUpon>
94+
</Compile>
95+
<Compile Include="Elasticsearch.aspx.cs">
96+
<DependentUpon>Elasticsearch.aspx</DependentUpon>
97+
<SubType>ASPXCodeBehind</SubType>
98+
</Compile>
99+
<Compile Include="Elasticsearch.aspx.designer.cs">
100+
<DependentUpon>Elasticsearch.aspx</DependentUpon>
101+
</Compile>
102+
</ItemGroup>
103+
<ItemGroup>
104+
<None Include="packages.config" />
105+
<None Include="Web.Release.config">
106+
<DependentUpon>Web.config</DependentUpon>
107+
</None>
108+
</ItemGroup>
109+
<ItemGroup>
110+
<ProjectReference Include="..\..\src\Datadog.Trace.ClrProfiler.Managed\Datadog.Trace.ClrProfiler.Managed.csproj">
111+
<Project>{85f35aaf-d102-4960-8b41-3bd9cbd0e77f}</Project>
112+
<Name>Datadog.Trace.ClrProfiler.Managed</Name>
113+
</ProjectReference>
114+
</ItemGroup>
115+
<ItemGroup>
116+
<Folder Include="Properties\" />
117+
</ItemGroup>
118+
<PropertyGroup>
119+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
120+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
121+
</PropertyGroup>
122+
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
123+
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
124+
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
125+
<ProjectExtensions>
126+
<VisualStudio>
127+
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
128+
<WebProjectProperties>
129+
<UseIIS>True</UseIIS>
130+
<AutoAssignPort>True</AutoAssignPort>
131+
<DevelopmentServerPort>58847</DevelopmentServerPort>
132+
<DevelopmentServerVPath>/</DevelopmentServerVPath>
133+
<IISUrl>https://localhost:44371/</IISUrl>
134+
<NTLMAuthentication>False</NTLMAuthentication>
135+
<UseCustomServer>False</UseCustomServer>
136+
<CustomServerUrl>
137+
</CustomServerUrl>
138+
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
139+
</WebProjectProperties>
140+
</FlavorProperties>
141+
</VisualStudio>
142+
</ProjectExtensions>
143+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
144+
<PropertyGroup>
145+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
146+
</PropertyGroup>
147+
<Error Condition="!Exists('..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
148+
</Target>
149+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
150+
Other similar extension points exist, see Microsoft.Common.targets.
151+
<Target Name="BeforeBuild">
152+
</Target>
153+
<Target Name="AfterBuild">
154+
</Target>
155+
-->
156+
</Project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SqlServer.aspx.cs" Inherits="Samples.WebForms.Empty.SqlServer" %>
2+
3+
<!DOCTYPE html>
4+
5+
<html xmlns="http://www.w3.org/1999/xhtml">
6+
<head runat="server">
7+
<title>SqlServer</title>
8+
</head>
9+
<body>
10+
<form id="form1" runat="server">
11+
<h2>SqlServer</h2>
12+
<div><%: DateTime.Now %></div>
13+
<div>Profiler attached: <%: Samples.WebForms.Empty.Profiler.IsAttached %></div>
14+
</form>
15+
</body>
16+
</html>

0 commit comments

Comments
 (0)