csharp-netcore icon indicating copy to clipboard operation
csharp-netcore copied to clipboard

Capture SOAP Action

Open bobcat1506 opened this issue 4 years ago • 2 comments

We (unfortunately) are still making SOAP calls using WCF due to the vendor not exposing a REST API. The SOAP calls are properly captured, but they do not capture the SOAP Action which makes it really hard to know which method the code invoked at the vendor. So this ticket is two fold. First, it is a feature request to see the capturing of the SOAP Action incorporated into the tooling.

Second, in the mean time I created a IClientMessageInspector to Tag the "http.action" to the active span. While the code is capturing the action, it is associating it to the parent span, not the span that actually made the SOAP call. How do I fix this?

bobcat1506 avatar Dec 17 '20 16:12 bobcat1506

Hi! If you can get the SOAP action from the outgoing HttpRequestMessage, you can use the OnRequest-property on ConfigureHttpHandler() to set an action that inspects the outgoing HTTP calls and sets tags on its span:

services.AddOpenTracing(builder =>
{
    builder.ConfigureHttpHandler(options =>
    {
        options.OnRequest = (span, request) =>
        {
            if (request.RequestUri.AbsoluteUri == "http://example.com/api/dosomething")
            {
                span.SetTag("my-tag", "my-value");
            }
        };
    });
});

If you can't get the SOAP action from the URL, you could try setting a custom HttpRequestMessage.Properties value when you do the SOAP call (given you have access to the HttpClient) and use that in the OnRequest-logic.

Please let me know if this solves your issue.

cwe1ss avatar Dec 17 '20 20:12 cwe1ss

As described by @bobcat1506 in #85, the SOAP standard has a header named "SOAPAction". I don't think this should be added to this library right now as it can easily be done via the options.OnRequest-code provided above, but I'll leave this issue open for further feedback.

cwe1ss avatar Dec 21 '20 06:12 cwe1ss