-
Notifications
You must be signed in to change notification settings - Fork 369
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
Automatically trace outgoing requests for traced request #9941
Comments
From your question I'm guessing your setup is as follows:
If I understood your question correctly then no, Google.Cloud.Diagnostics.* configured in app1 has absolutetely no control over what serviceA does. Google.Cloud.Diagnostics.* configured in app1 only makes sure that a trace context is propageted in requests from app1 to serviceA, but what serviceA does with that we have no control over, unless you configure Google.Cloud.Diagnostics.* on serviceA itself. If my understanding is not right, then please share a minimal but complete set of projects that reproduces the behaviour you are seeing vs. the behaviour you expected. |
Hi Amanda, You understand right, sory for my writing skill :) app1 sends req1 -> serviceA sends req2 -> serviceB app1 has services.AddGoogleDiagnosticsForAspNetCore() on startup.cs When I click a button on app1 and send to req1 to ServiceA, trace list only shows req1 (app1 -> serviceA). Waterfall graph not shows chained request like req2. So all project have Google.Cloud.Diagnostics.* and configured with "AddGoogleDiagnosticsForAspNetCore". If you tell me "req2 must be listed on waterfall graph without any other configuration", means that I will create example project :) If I add a line to serviceA startup This means; we must always configure named httpClient with AddOutgoingGoogleTraceHandler and use this to send requests at each service. You can just say "give me the project :)" |
Yes, if you want your trace to propagate (so that all requests on the chain are included on the same trace and shown on the waterfall graph) you need to confgure each relevant HttpClient with AddOutgoingGoogleTraceHandler. What happens when you don't do that is that the trace from app1 is not propagated to serviceA, so when the request reaches serviceA a new trace is created, which is also not propagated to serviceB which itself creates a new trace. You can find this 3 traces if you use HttpClients that have not been configured with Note that Google.Cloud.Diagnostics.* does not require you to use named HTTP clients. The example shows named HTTP clients for clarity, but from Google.Cloud.Diagnostics.* side of things, you can just use the basic HTTP client for all your requests. |
Ok, I understand the way you go and clear for me. AddHttpClient() returns IServiceCollection -> ref : link AddHttpClient("") returns IHttpClientBuilder -> ref: link Do you have a suggestion to apply this to all httpClients in serviceA? Also IHttpClientBuilder interface has Name -> ref: link Docs: link |
You can configure the default client by adding and configuring a named client with the default name (see the Remarks section). That means that your configuration code looks like: services.AddHttpClient(Options.DefaultName).AddOutgoingGoogleTraceHandler(); but the code where you use the HTTP client doesn't need to request any specifically named clients. |
ty, we will go on this way |
Hi,
If request to serviceA is being traced, I would expect the request from serviceA to serviceB should be also tracked without any other configuration.
when I tried and also read both docs and codes, there should be named httpClient to configure AddOutgoingGoogleTraceHandler docs
Was it done on purpose or is there something I missed?
Should we configure all httpClients one by one or do you have any other solution to work service wide and not need httpClient configurations?
I asked this because we have 4 project and each project has 40 services. :)
I thought to write a httpClient wrapper to send all HTTP requests on it. So I can detect that the request is traced add traceContext to header and move on. ref : #9856 (comment)
The text was updated successfully, but these errors were encountered: