At work we use BFF in an application that uses Microsoft Application Insights (AppInsights). Since introducing BFF, it's always reported telemetry nested incorrectly. What we'd expect is something like this:
outgoing Ajax request to BFF host (from browser)
incoming request to BFF host (from BFF host)
outgoing request to remote api (from BFF host)
incoming request to remote api (from remote api)
Instead, what we actually get is this (i.e. incoming requests are siblings and there's no outgoing request):
outgoing Ajax request to BFF host
incoming request to BFF host
incoming request to remote api
This has puzzled me, because Yarp docs say that it works out of the box (https://microsoft.github.io/reverse-proxy/articles/distributed-tracing.html). Only recently have I realized that it is dependent on using Yarp's created SocketsHttpHandler (in ForwarderHttpClientFactory) and BFF doesn't do that.
So it turns out that BFF's configuration for SocketsHttpHandler is out of sync with Yarp.
Which version of Duende BFF are you using? 2.2.0
Which version of .NET are you using? net8.0
Describe the bug
At work we use BFF in an application that uses Microsoft Application Insights (AppInsights). Since introducing BFF, it's always reported telemetry nested incorrectly. What we'd expect is something like this:
Instead, what we actually get is this (i.e. incoming requests are siblings and there's no outgoing request):
This has puzzled me, because Yarp docs say that it works out of the box (https://microsoft.github.io/reverse-proxy/articles/distributed-tracing.html). Only recently have I realized that it is dependent on using Yarp's created SocketsHttpHandler (in ForwarderHttpClientFactory) and BFF doesn't do that.
So it turns out that BFF's configuration for SocketsHttpHandler is out of sync with Yarp.
In Yarp 2.1.0 we have additionally
ActivityHeadersPropagator
(which is the missing piece behind correct distributed tracing) andConnectTimeout
. https://github.com/microsoft/reverse-proxy/blob/v2.1.0/src/ReverseProxy/Forwarder/ForwarderHttpClientFactory.cs#L44-L54And in Yarp 2.2.0 (currently preview) there's also
EnableMultipleHttp2Connections
. https://github.com/microsoft/reverse-proxy/blob/v2.2.0-preview1/src/ReverseProxy/Forwarder/ForwarderHttpClientFactory.cs#L44-L55To Reproduce
Steps to reproduce the behavior.
Expected behavior
A clear and concise description of what you expected to happen.
Log output/exception with stacktrace
Additional context
In my opinion BFF should employ Yarp's classes here and not recreate this, but I will create separate issue for that.