From 9fd32aa2ca6a211ec962fb1ff296290df913388f Mon Sep 17 00:00:00 2001 From: Lucas Pimentel Date: Wed, 30 Oct 2024 16:13:17 -0400 Subject: [PATCH] assert baggage header in Samples.ManualInstrumentation --- .../Samples.ManualInstrumentation/Program.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tracer/test/test-applications/integrations/Samples.ManualInstrumentation/Program.cs b/tracer/test/test-applications/integrations/Samples.ManualInstrumentation/Program.cs index 83e781868f19..8955c2c3df49 100644 --- a/tracer/test/test-applications/integrations/Samples.ManualInstrumentation/Program.cs +++ b/tracer/test/test-applications/integrations/Samples.ManualInstrumentation/Program.cs @@ -70,6 +70,10 @@ async Task OtherStuff() // verify instrumentation ThrowIf(string.IsNullOrEmpty(_initialTracer.DefaultServiceName)); + // baggage works without an active span + Baggage.Current["key1"] = "value1"; + Expect(Baggage.Current["key1"] == "value1"); + // Manual + automatic before reconfiguration var firstOperationName = $"Manual-{++count}.Initial"; using (var scope = _initialTracer.StartActive(firstOperationName)) @@ -83,7 +87,10 @@ async Task OtherStuff() Expect(scope.Span.GetTag("Temp") == "TempTest"); scope.Span.SetTag("Temp", null); - await SendHttpRequest("Initial"); + var responseMessage = await SendHttpRequest("Initial"); + + // verify baggage in the request headers + Expect(responseMessage.RequestMessage.Headers.GetValues("baggage").FirstOrDefault() == "key1=value1"); } await _initialTracer.ForceFlushAsync(); @@ -207,12 +214,15 @@ async Task OtherStuff() Environment.Exit(0); return; - async Task SendHttpRequest(string name) + async Task SendHttpRequest(string name) { var q = $"{count}.{name}"; using var scope = Tracer.Instance.StartActive($"Manual-{q}.HttpClient"); - await client.GetAsync(url + $"?q={q}"); + var responseMessage = await client.GetAsync(url + $"?q={q}"); + Console.WriteLine("Received response for client.GetAsync(String)"); + + return responseMessage; } void HandleHttpRequests(HttpListenerContext context)