Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Microsoft.AspNet.TelemetryCorrelation -> OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule #2238

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion OpenTelemetry.sln
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "customizing-the-sdk", "docs
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "getting-started", "docs\metrics\getting-started\getting-started.csproj", "{DFB0AD2F-11BE-4BCD-A77B-1018C3344FA8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTelemetry.Exporter.Prometheus", "src\OpenTelemetry.Exporter.Prometheus\OpenTelemetry.Exporter.Prometheus.csproj", "{52158A12-E7EF-45A1-859F-06F9B17410CB}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.Prometheus", "src\OpenTelemetry.Exporter.Prometheus\OpenTelemetry.Exporter.Prometheus.csproj", "{52158A12-E7EF-45A1-859F-06F9B17410CB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule", "src\OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule\OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.csproj", "{F38E511B-1877-4E8A-8051-7879FC7DF8A4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests", "test\OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests\OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests.csproj", "{4D7201BC-7124-4401-AD65-FAB58A053D45}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -411,6 +415,14 @@ Global
{52158A12-E7EF-45A1-859F-06F9B17410CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{52158A12-E7EF-45A1-859F-06F9B17410CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{52158A12-E7EF-45A1-859F-06F9B17410CB}.Release|Any CPU.Build.0 = Release|Any CPU
{F38E511B-1877-4E8A-8051-7879FC7DF8A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F38E511B-1877-4E8A-8051-7879FC7DF8A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F38E511B-1877-4E8A-8051-7879FC7DF8A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F38E511B-1877-4E8A-8051-7879FC7DF8A4}.Release|Any CPU.Build.0 = Release|Any CPU
{4D7201BC-7124-4401-AD65-FAB58A053D45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4D7201BC-7124-4401-AD65-FAB58A053D45}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4D7201BC-7124-4401-AD65-FAB58A053D45}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4D7201BC-7124-4401-AD65-FAB58A053D45}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
1 change: 0 additions & 1 deletion build/Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
<GrpcToolsPkgVer>[2.25.0,3.0)</GrpcToolsPkgVer>
<MicrosoftAspNetCoreHttpAbstractionsPkgVer>[2.1.1,6.0)</MicrosoftAspNetCoreHttpAbstractionsPkgVer>
<MicrosoftAspNetCoreHttpFeaturesPkgVer>[2.1.1,6.0)</MicrosoftAspNetCoreHttpFeaturesPkgVer>
<MicrosoftAspNetTelemetryCorrelationPkgVer>[1.0.7,2.0)</MicrosoftAspNetTelemetryCorrelationPkgVer>
<MicrosoftCodeAnalysisAnalyzersPkgVer>[3.3.1]</MicrosoftCodeAnalysisAnalyzersPkgVer>
<MicrosoftCodeCoveragePkgVer>[16.10.0]</MicrosoftCodeCoveragePkgVer>
<MicrosoftExtensionsHostingAbstractionsPkgVer>[2.1.0,)</MicrosoftExtensionsHostingAbstractionsPkgVer>
Expand Down
2 changes: 1 addition & 1 deletion examples/AspNet/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0"/>
</handlers>
<modules>
<add name="TelemetryCorrelationHttpModule" type="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule, Microsoft.AspNet.TelemetryCorrelation" preCondition="integratedMode,managedHandler"/>
<add name="TelemetryCorrelationHttpModule" type="OpenTelemetry.Instrumentation.AspNet.TelemetryCorrelationHttpModule, OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule" preCondition="integratedMode,managedHandler"/>
</modules>
</system.webServer>
<runtime>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
using System.ComponentModel;
using System.Diagnostics;

namespace Microsoft.AspNet.TelemetryCorrelation
namespace OpenTelemetry.Instrumentation.AspNet
{
/// <summary>
/// Extensions of Activity class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
using System.Diagnostics;
using System.Web;

namespace Microsoft.AspNet.TelemetryCorrelation
namespace OpenTelemetry.Instrumentation.AspNet
{
/// <summary>
/// Activity helper class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
using System.Diagnostics.Tracing;
#pragma warning disable SA1600 // Elements must be documented

namespace Microsoft.AspNet.TelemetryCorrelation
namespace OpenTelemetry.Instrumentation.AspNet
{
/// <summary>
/// ETW EventSource tracing class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,8 @@

[assembly: ComVisible(false)]

[assembly: InternalsVisibleTo("Microsoft.AspNet.TelemetryCorrelation.Tests" + AssemblyInfo.PublicKey)]

#if SIGNED
internal static class AssemblyInfo
{
public const string PublicKey = ", PublicKey=002400000480000094000000060200000024000052534131000400000100010051C1562A090FB0C9F391012A32198B5E5D9A60E9B80FA2D7B434C9E5CCB7259BD606E66F9660676AFC6692B8CDC6793D190904551D2103B7B22FA636DCBB8208839785BA402EA08FC00C8F1500CCEF28BBF599AA64FFB1E1D5DC1BF3420A3777BADFE697856E9D52070A50C3EA5821C80BEF17CA3ACFFA28F89DD413F096F898";
}
[assembly: InternalsVisibleTo("OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051c1562a090fb0c9f391012a32198b5e5d9a60e9b80fa2d7b434c9e5ccb7259bd606e66f9660676afc6692b8cdc6793d190904551d2103b7b22fa636dcbb8208839785ba402ea08fc00c8f1500ccef28bbf599aa64ffb1e1d5dc1bf3420a3777badfe697856e9d52070a50c3ea5821c80bef17ca3acffa28f89dd413f096f898")]
#else
internal static class AssemblyInfo
{
public const string PublicKey = "";
}
[assembly: InternalsVisibleTo("OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests")]
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License.
// </copyright>

namespace Microsoft.AspNet.TelemetryCorrelation
namespace OpenTelemetry.Instrumentation.AspNet
{
// Adoptation of code from https://github.com/aspnet/HttpAbstractions/blob/07d115400e4f8c7a66ba239f230805f03a14ee3d/src/Microsoft.Net.Http.Headers/BaseHeaderParser.cs
internal abstract class BaseHeaderParser<T> : HttpHeaderParser<T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

using System;

namespace Microsoft.AspNet.TelemetryCorrelation
namespace OpenTelemetry.Instrumentation.AspNet
{
// Adoptation of code from https://github.com/aspnet/HttpAbstractions/blob/07d115400e4f8c7a66ba239f230805f03a14ee3d/src/Microsoft.Net.Http.Headers/GenericHeaderParser.cs
internal sealed class GenericHeaderParser<T> : BaseHeaderParser<T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

using System.Diagnostics.Contracts;

namespace Microsoft.AspNet.TelemetryCorrelation
namespace OpenTelemetry.Instrumentation.AspNet
{
// Adoption of the code from https://github.com/aspnet/HttpAbstractions/blob/07d115400e4f8c7a66ba239f230805f03a14ee3d/src/Microsoft.Net.Http.Headers/HeaderUtilities.cs
internal static class HeaderUtilities
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License.
// </copyright>

namespace Microsoft.AspNet.TelemetryCorrelation
namespace OpenTelemetry.Instrumentation.AspNet
{
// Adoptation of code from https://github.com/aspnet/HttpAbstractions/blob/07d115400e4f8c7a66ba239f230805f03a14ee3d/src/Microsoft.Net.Http.Headers/HttpHeaderParser.cs
internal abstract class HttpHeaderParser<T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License.
// </copyright>

namespace Microsoft.AspNet.TelemetryCorrelation
namespace OpenTelemetry.Instrumentation.AspNet
{
// Adoptation of code from https://github.com/aspnet/HttpAbstractions/blob/07d115400e4f8c7a66ba239f230805f03a14ee3d/src/Microsoft.Net.Http.Headers/HttpParseResult.cs
internal enum HttpParseResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

using System.Diagnostics.Contracts;

namespace Microsoft.AspNet.TelemetryCorrelation
namespace OpenTelemetry.Instrumentation.AspNet
{
// Adoptation of code from https://github.com/aspnet/HttpAbstractions/blob/07d115400e4f8c7a66ba239f230805f03a14ee3d/src/Microsoft.Net.Http.Headers/HttpRuleParser.cs
internal static class HttpRuleParser
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

using System.Diagnostics.Contracts;

namespace Microsoft.AspNet.TelemetryCorrelation
namespace OpenTelemetry.Instrumentation.AspNet
{
// Adoptation of code from https://github.com/aspnet/HttpAbstractions/blob/07d115400e4f8c7a66ba239f230805f03a14ee3d/src/Microsoft.Net.Http.Headers/NameValueHeaderValue.cs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFrameworks>net461</TargetFrameworks>
<Description>A module that instruments incoming request with System.Diagnostics.Activity and notifies listeners with DiagnosticsSource.</Description>
<PackageTags>$(PackageTags);distributed-tracing;AspNet;MVC;WebAPI</PackageTags>
<!--
TODO: Disable this exception, and actually do document all public API.
-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
using System.Reflection;
using System.Web;

namespace Microsoft.AspNet.TelemetryCorrelation
namespace OpenTelemetry.Instrumentation.AspNet
{
/// <summary>
/// Http Module sets ambient state using Activity API from DiagnosticsSource package.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@
<Reference Include="System.Web" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNet.TelemetryCorrelation" Version="$(MicrosoftAspNetTelemetryCorrelationPkgVer)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry\OpenTelemetry.csproj" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule\OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.csproj" />
</ItemGroup>

</Project>
54 changes: 28 additions & 26 deletions src/OpenTelemetry.Instrumentation.AspNet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,18 @@ dotnet add package OpenTelemetry.Instrumentation.AspNet

`OpenTelemetry.Instrumentation.AspNet` requires adding an additional HttpModule
to your web server. This additional HttpModule is shipped as part of
[`Microsoft.AspNet.TelemetryCorrelation`](https://www.nuget.org/packages/Microsoft.AspNet.TelemetryCorrelation/)
[`OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule`](https://www.nuget.org/packages/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/)
which is implicitly brought by `OpenTelemetry.Instrumentation.AspNet`. The
following shows changes required to your `Web.config` when using IIS web server.

```xml
<system.webServer>
<modules>
<add name="TelemetryCorrelationHttpModule"
type="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule,
Microsoft.AspNet.TelemetryCorrelation"
preCondition="integratedMode,managedHandler" />
<add
name="TelemetryCorrelationHttpModule"
type="OpenTelemetry.Instrumentation.AspNet.TelemetryCorrelationHttpModule,
OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule"
preCondition="integratedMode,managedHandler" />
</modules>
</system.webServer>
```
Expand All @@ -44,8 +45,8 @@ following shows changes required to your `Web.config` when using IIS web server.
ASP.NET instrumentation must be enabled at application startup. This is
typically done in the `Global.asax.cs` as shown below. This example also sets up
the OpenTelemetry Jaeger exporter, which requires adding the package
[`OpenTelemetry.Exporter.Jaeger`](../OpenTelemetry.Exporter.Jaeger/README.md)
to the application.
[`OpenTelemetry.Exporter.Jaeger`](../OpenTelemetry.Exporter.Jaeger/README.md) to
the application.

```csharp
using OpenTelemetry;
Expand All @@ -71,18 +72,19 @@ public class WebApiApplication : HttpApplication
## Advanced configuration

This instrumentation can be configured to change the default behavior by using
`AspNetInstrumentationOptions`, which allows configuring `Filter` as explained below.
`AspNetInstrumentationOptions`, which allows configuring `Filter` as explained
below.

### Filter

This instrumentation by default collects all the incoming http requests. It allows
filtering of requests by using the `Filter` function in `AspNetInstrumentationOptions`.
This defines the condition for allowable requests. The Filter
receives the `HttpContext` of the incoming request, and does not collect telemetry
about the request if the Filter returns false or throws exception.
This instrumentation by default collects all the incoming http requests. It
allows filtering of requests by using the `Filter` function in
`AspNetInstrumentationOptions`. This defines the condition for allowable
requests. The Filter receives the `HttpContext` of the incoming request, and
does not collect telemetry about the request if the Filter returns false or
throws exception.

The following code snippet shows how to use `Filter` to only allow GET
requests.
The following code snippet shows how to use `Filter` to only allow GET requests.

```csharp
this.tracerProvider = Sdk.CreateTracerProviderBuilder()
Expand All @@ -103,13 +105,13 @@ and the `Filter` option does the filtering *before* the Sampler is invoked.

### Enrich

This option allows one to enrich the activity with additional information
from the raw `HttpRequest`, `HttpResponse` objects. The `Enrich` action is
called only when `activity.IsAllDataRequested` is `true`. It contains the
activity itself (which can be enriched), the name of the event, and the
actual raw object.
For event name "OnStartActivity", the actual object will be `HttpRequest`.
For event name "OnStopActivity", the actual object will be `HttpResponse`
This option allows one to enrich the activity with additional information from
the raw `HttpRequest`, `HttpResponse` objects. The `Enrich` action is called
only when `activity.IsAllDataRequested` is `true`. It contains the activity
itself (which can be enriched), the name of the event, and the actual raw
object. For event name "OnStartActivity", the actual object will be
`HttpRequest`. For event name "OnStopActivity", the actual object will be
`HttpResponse`

The following code snippet shows how to add additional tags using `Enrich`.

Expand All @@ -136,10 +138,10 @@ this.tracerProvider = Sdk.CreateTracerProviderBuilder()
.Build();
```

[Processor](../../docs/trace/extending-the-sdk/README.md#processor),
is the general extensibility point to add additional properties to any activity.
The `Enrich` option is specific to this instrumentation, and is provided to
get access to `HttpRequest` and `HttpResponse`.
[Processor](../../docs/trace/extending-the-sdk/README.md#processor), is the
general extensibility point to add additional properties to any activity. The
`Enrich` option is specific to this instrumentation, and is provided to get
access to `HttpRequest` and `HttpResponse`.

## References

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License.
// </copyright>

namespace Microsoft.AspNet.TelemetryCorrelation.Tests
namespace OpenTelemetry.Instrumentation.AspNet.Tests
{
using System.Collections.Generic;
using System.Collections.Specialized;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License.
// </copyright>

namespace Microsoft.AspNet.TelemetryCorrelation.Tests
namespace OpenTelemetry.Instrumentation.AspNet.Tests
{
using System;
using System.Collections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License.
// </copyright>

namespace Microsoft.AspNet.TelemetryCorrelation.Tests
namespace OpenTelemetry.Instrumentation.AspNet.Tests
{
using System.Collections.Generic;
using System.Globalization;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(RepoRoot)\src\Microsoft.AspNet.TelemetryCorrelation\Microsoft.AspNet.TelemetryCorrelation.csproj" />
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule\OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.csproj" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="$(RepoRoot)\src\Microsoft.AspNet.TelemetryCorrelation\web.config.install.xdt">
<EmbeddedResource Include="$(RepoRoot)\src\OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule\web.config.install.xdt">
<Link>Resources\web.config.install.xdt</Link>
</EmbeddedResource>
<EmbeddedResource Include="$(RepoRoot)\src\Microsoft.AspNet.TelemetryCorrelation\web.config.uninstall.xdt">
<EmbeddedResource Include="$(RepoRoot)\src\OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule\web.config.uninstall.xdt">
<Link>Resources\web.config.uninstall.xdt</Link>
</EmbeddedResource>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License.
// </copyright>

namespace Microsoft.AspNet.TelemetryCorrelation.Tests
namespace OpenTelemetry.Instrumentation.AspNet.Tests
{
using System.Reflection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License.
// </copyright>

namespace Microsoft.AspNet.TelemetryCorrelation.Tests
namespace OpenTelemetry.Instrumentation.AspNet.Tests
{
using System;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License.
// </copyright>

namespace Microsoft.AspNet.TelemetryCorrelation.Tests
namespace OpenTelemetry.Instrumentation.AspNet.Tests
{
using System.IO;
using System.Xml.Linq;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License.
// </copyright>

namespace Microsoft.AspNet.TelemetryCorrelation.Tests
namespace OpenTelemetry.Instrumentation.AspNet.Tests
{
using System.IO;
using System.Xml.Linq;
Expand Down