ydb-platform / ydb-dotnet-sdk

YDB .NET SDK
Apache License 2.0
31 stars 17 forks source link

bug: Empty log message #174

Closed molostovvs closed 2 months ago

molostovvs commented 2 months ago

Bug Report

YDB dotnet SDK version: 0.6.0

Environment: Yandex Cloud Function, .NET 8, 256MB ram

Current behavior:

The log message is formed incorrectly because of unfilled placeholders. Also, since placeholders are empty, logs are useless if I want to query them.

Here is an example of the log that comes out as a result of calling Driver.CreateInitialized:

image

Expected behavior:

Logs have placeholders filled, so they are filled correctly and can be queried. A simple example of such a log:

image

Steps to reproduce:

Just call Driver.CreateInitialized with logger factory. I use Serilog for logging.

var logger = new LoggerConfiguration().WriteTo.Console().CreateLogger();
var services = new ServiceCollection().AddLogging(loggingBuilder => loggingBuilder.AddSerilog(logger));
var _loggerFactory = services.BuildServiceProvider().GetRequiredService<ILoggerFactory>();

var metadataProvider = new MetadataProvider(_loggerFactory);
await metadataProvider.Initialize();

var driverConfig = new DriverConfig(_ydbEndpoint, _ydbDatabase, metadataProvider);

_ = Driver.CreateInitialized(driverConfig, _loggerFactory);

Related code:

All logging must use correct placeholders. In a particular case, such a call (from Driver.cs, line 236):

_logger.LogInformation("Successfully discovered endpoints: {}, self location: {}, sdk info: {}",
    resultProto.Endpoints.Count, resultProto.SelfLocation, _sdkInfo);

should be replaced by the following:

_logger.LogInformation(
    "Successfully discovered endpoints: {EndpointsCount}, self location: {SelfLocation}, sdk info: {SdkInfo}",
    resultProto.Endpoints.Count, resultProto.SelfLocation, _sdkInfo);

Other information:

I suggest adding correct placeholders to all logging calls with parameters.

KirillKurdyukov commented 2 months ago

Thanks for the issue! Fixed in 0.6.2 version.