Skip to content

[bug] Exporting logs with OtlpExporter and grpc not working. #6143

Open
@pravinpushkar

Description

Package

OpenTelemetry

Package Version

Package Name Version
OpenTelemetry.Api 1.11.1
OpenTelemetry 1.11.1
TBD TBD

Runtime Version

8

Description

This seems still reproducible with 1.11.1.

Related issue - #6067
#6083

Steps to Reproduce

Here is samle code -

string loggingendpoint = Environment.GetEnvironmentVariable("LOGGING_GRPC_ENDPOINT") ?? "localhost";

if (string.IsNullOrEmpty(loggingendpoint))
{
    Console.WriteLine("No logging endpoint provided.");
}
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);

Console.WriteLine($"Logging endpoint: {loggingendpoint}");
using var loggerFactory = LoggerFactory.Create(builder =>
{
    builder.AddOpenTelemetry(options =>
    {
        options.IncludeScopes = true;
        options.IncludeFormattedMessage = true;
        options.AddConsoleExporter();
        options.AddOtlpExporter((exOpt, pOpts) =>
        {
            exOpt.Endpoint = new Uri($"http://{loggingendpoint}");
            exOpt.Protocol = OtlpExportProtocol.Grpc;
        });
    });
});

var logger = loggerFactory.CreateLogger("Log");

using (logger.BeginScope(new List<KeyValuePair<string, object>>{
                    new KeyValuePair<string, object>("category", "OTLPLOGExporter"),
                }))
{
    logger.LogInformationWithDetails($"LOGGING_GRPC_ENDPOINT {loggingendpoint}");

    logger.LogInformationWithDetails("All Done!");
    // to flush the in-memory buffer and ensure all logs are exported.

    loggerFactory.Dispose();
}

Expected Result

Logs successfully exported

Actual Result

Logs not able to get exported. No errors.

Additional Context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

bugSomething isn't workingneeds-triageNew issues which have not been classified or triaged by a community memberpkg:OpenTelemetryIssues related to OpenTelemetry NuGet package

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions