Created
June 25, 2024 20:01
-
-
Save szalapski/14b52760da4d8bf1cf8dc430e07b19fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Imports Datadog.Trace | |
Imports System.IO | |
Public Class DatadogSoapRequestModule | |
Implements IHttpModule | |
Public Sub Init(context As HttpApplication) Implements IHttpModule.Init | |
AddHandler context.BeginRequest, AddressOf Application_BeginRequest | |
End Sub | |
Public Sub Dispose() Implements IHttpModule.Dispose | |
End Sub | |
Private Sub Application_BeginRequest(sender As Object, e As EventArgs) | |
Dim context As HttpContext = DirectCast(sender, HttpApplication).Context | |
Dim span As ISpan = Tracer.Instance.ActiveScope?.Span | |
If Tracer.Instance.ActiveScope Is Nothing Then | |
context.Response.Write("No ActiveScope found") | |
ElseIf Tracer.Instance.ActiveScope.Span Is Nothing Then | |
context.Response.Write("No span found") | |
Else | |
Dim requestBody As String = New StreamReader(context.Request.InputStream).ReadToEnd() | |
span.SetTag("http.request_body", requestBody) | |
End If | |
' Reset the input stream position so it can be read again later in the request lifecycle | |
context.Request.InputStream.Position = 0 | |
End Sub | |
End Class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment