Git Product home page Git Product logo

Comments (2)

martinjt avatar martinjt commented on June 20, 2024

There's not a huge amount of information to go on there, but I suspect that the ParentIds are from the HTTP outbound span (HTTP Client), not the inbound AspNet core span, which is what you're showing there.

I'm not sure why ServiceC would be in a new Trace, but perhaps you've not enabled the HTTPClient instrumentation in Service B?

from opentelemetry-dotnet.

snake-L avatar snake-L commented on June 20, 2024

There's not a huge amount of information to go on there, but I suspect that the ParentIds are from the HTTP outbound span (HTTP Client), not the inbound AspNet core span, which is what you're showing there.

I'm not sure why ServiceC would be in a new Trace, but perhaps you've not enabled the HTTPClient instrumentation in Service B?

@martinjt hi, this is the sample code. I have checked the source code but cannot find the reason

serviceA

	var builder = WebApplication.CreateBuilder(args);
	builder.WebHost.ConfigureKestrel(b =>
{
	b.ListenAnyIP(5000);
});
	builder.Services.AddHttpClient();
	builder.Services.AddOpenTelemetry()
	.ConfigureResource(resource => resource
		.AddService("ServiceA"))
	.WithTracing(tracing => tracing
		.AddAspNetCoreInstrumentation()
		.AddConsoleExporter()
		.AddZipkinExporter()
		);

	var app = builder.Build();
	app.MapGet("/serviceA", async Task<string> (HttpContext context, IHttpClientFactory factory) =>
	{
		using var httpClient = factory.CreateClient("client");
		httpClient.BaseAddress = new Uri("Http://localhost:5001");
		
		var response = await httpClient.GetAsync("/serviceB");
		response.EnsureSuccessStatusCode();
		return await response.Content.ReadAsStringAsync();
	});
	await app.RunAsync();

serviceB

  var builder = WebApplication.CreateBuilder(args);
	builder.WebHost.ConfigureKestrel(b =>
{
	b.ListenAnyIP(5001);
});
	builder.Services.AddHttpClient();
	builder.Services.AddOpenTelemetry()
	.ConfigureResource(resource => resource
		.AddService("ServiceB"))
	.WithTracing(tracing => tracing
		.AddAspNetCoreInstrumentation()
		.AddConsoleExporter().AddZipkinExporter()
		);
	var app = builder.Build();
	app.MapGet("/serviceB", async Task<string> (HttpContext context, IHttpClientFactory factory) =>
	{
		using var httpClient = factory.CreateClient("serviceC");
		httpClient.BaseAddress = new Uri("Http://localhost:5002");

		var response = await httpClient.GetAsync("/serviceC");
		response.EnsureSuccessStatusCode();
		var result =  await response.Content.ReadAsStringAsync();


	    response = await httpClient.GetAsync("/serviceC");
		response.EnsureSuccessStatusCode();
        return await response.Content.ReadAsStringAsync();
	});
	await app.RunAsync();

ServiceC

	var builder = WebApplication.CreateBuilder(args);
	builder.WebHost.ConfigureKestrel(b =>
{
	b.ListenAnyIP(5002);
});
	builder.Services.AddHttpClient();
	builder.Services.AddOpenTelemetry()
	.ConfigureResource(resource => resource
		.AddService("ServiceC"))
	.WithTracing(tracing => tracing
		.AddAspNetCoreInstrumentation()
				.AddConsoleExporter().AddZipkinExporter()
		);

	var app = builder.Build();
	app.MapGet("/serviceC", ValueTask<string> (HttpContext context) =>
{
	return new ValueTask<string>($"DateTime Now:{DateTime.Now},GUid:{Guid.NewGuid().ToString("N")}");
});
	await app.RunAsync();

from opentelemetry-dotnet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.