question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Configuration with decimal-point numbers

See original GitHub issue

When reading configuration for sinks that include decimal-point numbers, the configuration reads the value as a string and then parses it using whatever number format the current culture supports.

Example of configuring Sentry as a sink, where SampleRate should be set to 10%::

      {
        "Name": "Sentry",
        "Args": {
          "Dsn": "https://<some value>.ingest.sentry.io/<some value>",
          "MinimumEventLevel": "Warning",
          "Environment": "Prod",
          "Release": "<some value>",
          "SampleRate": 0.1
        }
      }

The value is read / parsed as a string here: argumentValue = new StringArgumentValue(argumentSection.Value);

While applying the configuration the rSampleRate value then depends on whether the current context supports point or comma as decimal point, giving either 0.1 (10%) or 1 (100%) as result.

The desired behavior would be for the number value to be parsed as a number and not a string, when the value is supplied as a number.

Package versions used:

  • Serilog: 2.10.0
  • Serilog.Settings.Configuration: 3.3.0
  • Sentry.Serilog: 3.17.1

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
sungam3rcommented, Feb 8, 2023

If we are talking about break binary compatibility, then I propose to group the entire set of additional parameters in the settings class. This will allow to protect code from further breaking changes when adding new settings in the future:

public static LoggerConfiguration Configuration(
        this LoggerSettingsConfiguration settingConfiguration,
        IConfiguration configuration,
        LoggerConfigurationOptions options = null)
    {
        options ??= new();
        // go on with values from options instance
    }

    public class LoggerConfigurationOptions
    {
        public string SectionName { get; set; } = DefaultSectionName;
        public CultureInfo Culture { get; set; } = CultureInfo.InvariantCulture;
        // and so on
    }

So only one method exists, no combinations now and in the future, no breaking changes also (in ideal).

1reaction
tmjorgcommented, Sep 13, 2022

Adding an optional CultureInfo to ReadFrom.Configuration() sounds like a good solution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use decimal tabs to line up numbers with decimal points
When you work with numbers, setting a decimal tab makes numbers, such as amounts of currency, align correctly in a column. ... Click...
Read more >
Configuring decimal places for fields with Numbers
Configuring fields to allow for decimal places​​ Set the Decimal Places dropdown to the desired number and then save and publish your form...
Read more >
Number helper with decimals - Configuration
So trying to keep things kleen this time I found the helper UI and creaed a helper number BUT cant get it to...
Read more >
Configure Windows to Use Commas in Decimal Numbers
For example, some regions use a comma (,) as a decimal separator rather than a decimal point (.). ProntoForms supports different characters as ......
Read more >
How to Add Decimal Places in Excel (Automatically)
Automatically Add Decimal Point to Numbers While Typing · Click the File tab · Click on Options · In the Excel Options dialog...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found