This message was deleted.
s
This message was deleted.
d
On further testing, I think the problem has something to do with the config in program.cs. The github repo has the old .net way of doing things and I have updated to the new program.cs methods myself. I exoect that I have only configured support for traces and not for direct logging. How would I go about that in the new .net way with only a program.cs and no startup.cs?using OpenTelemetry.Resources;
Copy code
using OpenTelemetry.Trace;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddOpenTelemetryTracing(tracerProviderBuilder =>
{
    tracerProviderBuilder
        
        .AddConsoleExporter()
        .AddSource("TestPOCAPI")
        .SetResourceBuilder(ResourceBuilder.CreateDefault().AddService(builder.Configuration["Otlp:ServiceName"]))
        .AddHttpClientInstrumentation()
        .AddAspNetCoreInstrumentation()
        .AddOtlpExporter(otlpOptions =>
        {
            otlpOptions.Endpoint = new Uri(builder.Configuration["Otlp:Endpoint"]);
        });
});

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at <https://aka.ms/aspnetcore/swashbuckle>
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();

app.Run();
Ok I have updated my program.cs to use latest syntax etc. I have added logging explicity, but I cannot find how to add an otlpexporter to the logging config. Is it not implemented, or do I have something wrong in my understanding of how this works?
Copy code
using OpenTelemetry;               using OpenTelemetry.Resources;
using OpenTelemetry.Trace;
using OpenTelemetry.Logs;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.



var OtlpEndpoint =  builder.Configuration["Otlp:Endpoint"];

builder.Services.AddOpenTelemetry()
    .WithTracing(builder => builder
        .AddAspNetCoreInstrumentation()
        .AddHttpClientInstrumentation()
        .AddSqlClientInstrumentation()
        .AddConsoleExporter()
        .AddOtlpExporter(otlpOptions =>
        {
            otlpOptions.Endpoint = new Uri(OtlpEndpoint);
        })
        .AddSource("NextSignozPOCAPIExample")
        .SetResourceBuilder(
            ResourceBuilder.CreateDefault()
                .AddService(serviceName: "NextSignozPOCAPIExample")))
    .StartWithHost();


builder.Logging
     .AddOpenTelemetry(options =>
    {
        options.IncludeFormattedMessage = true;
        options.SetResourceBuilder(ResourceBuilder
            .CreateDefault().AddService("NextSignozPOCAPIExample"));
        options.AddConsoleExporter();
        
    });

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at <https://aka.ms/aspnetcore/swashbuckle>
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();

app.Run();
p
@Dave Arnoldi How are you planning to send logs to the SigNoz collector? Are you planning to use any log forwarders like Fluentd, Logstash or directly through file? Take a look at this if you are planning to send logs directly via file - https://signoz.io/docs/userguide/collect_logs_from_file/
Also, check this section for logs provider for .NET - https://opentelemetry.io/docs/instrumentation/net/#status-and-releases
d
HI, Thanks so much for the answer. That was the missing piece. For some reason I had the impression that emitting the logs through the standard .Net logging API could push them directly to an otlp endpoint. It makes sense that they would need to go to a log file first. Thanks
p
Awesome! Are you able to see logs in SigNoz now?
d
Hi, no not yet. I am probably going to go with a Fluentd collector. I need to install it on my K8s cluster and implement in my APIs. I'll tackle that on Monday. Thanks again for your help.
p
👍