Skip to content
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

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

Open
pravinpushkar opened this issue Feb 19, 2025 · 6 comments
Open

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

pravinpushkar opened this issue Feb 19, 2025 · 6 comments
Assignees
Labels
bug Something isn't working needs-triage New issues which have not been classified or triaged by a community member pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package

Comments

@pravinpushkar
Copy link

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

@pravinpushkar pravinpushkar added bug Something isn't working needs-triage New issues which have not been classified or triaged by a community member labels Feb 19, 2025
@github-actions github-actions bot added the pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package label Feb 19, 2025
@Kielek
Copy link
Contributor

Kielek commented Feb 19, 2025

To make it your example working I need to change LogInformationWithDetails to LogInformation and I changed localhost to localhost:4317.

Results (same for .NET8 and .NET9):

splunk-collector-1  | 2025-02-19T11:38:16.318Z  info    ResourceLog #0
splunk-collector-1  | Resource SchemaURL:
splunk-collector-1  | Resource attributes:
splunk-collector-1  |      -> telemetry.sdk.name: Str(opentelemetry)
splunk-collector-1  |      -> telemetry.sdk.language: Str(dotnet)
splunk-collector-1  |      -> telemetry.sdk.version: Str(1.11.1)
splunk-collector-1  |      -> service.name: Str(unknown_service:dotnet-6142)
splunk-collector-1  | ScopeLogs #0
splunk-collector-1  | ScopeLogs SchemaURL:
splunk-collector-1  | InstrumentationScope Log
splunk-collector-1  | LogRecord #0
splunk-collector-1  | ObservedTimestamp: 2025-02-19 11:38:16.1039371 +0000 UTC
splunk-collector-1  | Timestamp: 2025-02-19 11:38:16.1039371 +0000 UTC
splunk-collector-1  | SeverityText: Information
splunk-collector-1  | SeverityNumber: Info(9)
splunk-collector-1  | Body: Str(LOGGING_GRPC_ENDPOINT localhost:4317)
splunk-collector-1  | Attributes:
splunk-collector-1  |      -> {OriginalFormat}: Str(LOGGING_GRPC_ENDPOINT localhost:4317)
splunk-collector-1  |      -> category: Str(OTLPLOGExporter)
splunk-collector-1  | Trace ID:
splunk-collector-1  | Span ID:
splunk-collector-1  | Flags: 0
splunk-collector-1  | LogRecord #1
splunk-collector-1  | ObservedTimestamp: 2025-02-19 11:38:16.1244879 +0000 UTC
splunk-collector-1  | Timestamp: 2025-02-19 11:38:16.1244879 +0000 UTC
splunk-collector-1  | SeverityText: Information
splunk-collector-1  | SeverityNumber: Info(9)
splunk-collector-1  | Body: Str(All Done!)
splunk-collector-1  | Attributes:
splunk-collector-1  |      -> {OriginalFormat}: Str(All Done!)
splunk-collector-1  |      -> category: Str(OTLPLOGExporter)
splunk-collector-1  | Trace ID:
splunk-collector-1  | Span ID:
splunk-collector-1  | Flags: 0
splunk-collector-1  |   {"kind": "exporter", "data_type": "logs", "name": "debug/debug"}

Could you please prepare more detailed steps to reproduce? docker compose file could be beneficial to reproduce it.

@pravinpushkar
Copy link
Author

@Kielek Thanks a lot for responding quickly.

I need to change LogInformationWithDetails to LogInformation and I changed localhost to localhost:4317.

Sorry, These are my local setup method and need to change it accordingly. The output above shows from console exporter, which work fine for me as well with docker a image. These logs are not actually reaching the grpc receiver.

The same code when I use it with 1.10.0 open telemetry SDK, it works fine and logs are reaching the grpc receiver.

@Kielek
Copy link
Contributor

Kielek commented Feb 19, 2025

It is debug log from the collector with grpc receiver

@pravinpushkar
Copy link
Author

ok, it it a bit strange that this code works with 1.10.0 but not with 1.11.1.

@Kielek
Copy link
Contributor

Kielek commented Feb 21, 2025

As you see, it is working with 1.11.1 for me. Can you share Minimal, Reproducible Example?

@rajkumar-rangaraj
Copy link
Contributor

@pravinpushkar This could be related to #6138. Can you validate this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage New issues which have not been classified or triaged by a community member pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package
Projects
None yet
Development

No branches or pull requests

3 participants