Skip to content

Commit

Permalink
Fix double formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
stevejgordon committed Dec 4, 2024
1 parent 4eee56e commit 4394389
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
7 changes: 3 additions & 4 deletions src/Elastic.Apm/Report/Serialization/CustomJsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.Text.Json;
using System.Text.Json.Serialization;


namespace Elastic.Apm.Report.Serialization;

internal class CustomJsonConverter : JsonConverter<Dictionary<string, string>>
Expand Down Expand Up @@ -64,13 +63,13 @@ public override void Write(Utf8JsonWriter writer, bool value, JsonSerializerOpti
public class JsonConverterDouble : JsonConverter<double>
{
public override double Read(ref Utf8JsonReader reader,
Type typeToConvert, JsonSerializerOptions options) =>
reader.GetDouble();
Type typeToConvert, JsonSerializerOptions options) => reader.GetDouble();

public override void Write(Utf8JsonWriter writer, double value,
JsonSerializerOptions options) =>
writer.WriteRawValue(value.ToString("N1", CultureInfo.InvariantCulture));
writer.WriteRawValue(value.ToString("0.000", CultureInfo.InvariantCulture));
}

public class JsonConverterDecimal : JsonConverter<decimal>
{
public override decimal Read(ref Utf8JsonReader reader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ public Task<ActionResult> Contact()

return SafeCaptureSpan<ActionResult>($"{ContactSpanPrefix}{SpanNameSuffix}", $"{ContactSpanPrefix}{SpanTypeSuffix}", async () =>
{
await Task.Delay(1000); // Force response to take longer than 1 second to validate formatting of duration.

async Task<HttpResponseMessage> GetContentFromUrl(Uri url)
{
Console.WriteLine($"Getting `{url}'...");
Expand Down
8 changes: 4 additions & 4 deletions test/iis/Elastic.Apm.AspNetFullFramework.Tests/TestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ internal static class SampleAppUrlPaths
internal static readonly SampleAppUrlPathData PageThatDoesNotExist =
new SampleAppUrlPathData("dummy_URL_path_to_page_that_does_not_exist", 404, errorsCount: 1);

internal static readonly List<SampleAppUrlPathData> AllPaths = new List<SampleAppUrlPathData>
{
new SampleAppUrlPathData("", 200),
internal static readonly List<SampleAppUrlPathData> AllPaths =
[
new("", 200),
HomePage,
ContactPage,
CustomSpanThrowsExceptionPage,
PageThatDoesNotExist
};
];

/// <summary>
/// `CallReturnBadRequest' page processing does HTTP Get for `ReturnBadRequest' page (additional transaction) - so 1 span
Expand Down

0 comments on commit 4394389

Please sign in to comment.