Skip to content

Commit

Permalink
middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
Vishwesh Bankwar committed Dec 13, 2023
1 parent eca8eb3 commit b25f24f
Showing 1 changed file with 4 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
// <copyright file="TelemetryMiddleware.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>
// SPDX-License-Identifier: Apache-2.0

using Microsoft.AspNetCore.Http;

Expand All @@ -27,16 +14,16 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Implementation;
/// <param name="options">trace options.</param>
public class TelemetryMiddleware(AspNetCoreTraceInstrumentationOptions options) : IMiddleware
{
internal readonly HttpInListener InListener = new HttpInListener(options);
internal readonly HttpInListener HttpInListener = new HttpInListener(options);

/// <inheritdoc/>
public async Task InvokeAsync(HttpContext context, RequestDelegate next)
{
try
{
this.InListener.OnEventWritten("Microsoft.AspNetCore.Hosting.HttpRequestIn.Start", context);
this.HttpInListener.OnEventWritten("Microsoft.AspNetCore.Hosting.HttpRequestIn.Start", context);
await next(context).ConfigureAwait(false);
this.InListener.OnEventWritten("Microsoft.AspNetCore.Hosting.HttpRequestIn.Stop", context);
this.HttpInListener.OnEventWritten("Microsoft.AspNetCore.Hosting.HttpRequestIn.Stop", context);
}
catch
{
Expand Down

0 comments on commit b25f24f

Please sign in to comment.