Skip to content

Commit

Permalink
Singleton formatters
Browse files Browse the repository at this point in the history
Make formatters singletons.

See #818 (comment).
  • Loading branch information
martincostello committed Jan 15, 2025
1 parent d10b4b8 commit be25245
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/JustEat.StatsD/TagsFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,35 @@ public static class TagsFormatter
/// <summary>
/// Gets an AWS CloudWatch tags formatter.
/// </summary>
public static IStatsDTagsFormatter CloudWatch => new TrailingTagsFormatter();
public static IStatsDTagsFormatter CloudWatch => TrailingTagsFormatter.Instance;

/// <summary>
/// Gets a DataDog tags formatter.
/// </summary>
public static IStatsDTagsFormatter DataDog => new TrailingTagsFormatter();
public static IStatsDTagsFormatter DataDog => TrailingTagsFormatter.Instance;

/// <summary>
/// Gets a GraphiteDB tags formatter.
/// </summary>
public static IStatsDTagsFormatter GraphiteDb => new GraphiteDbTagsFormatter();
public static IStatsDTagsFormatter GraphiteDb { get; } = new GraphiteDbTagsFormatter();

/// <summary>
/// Gets an InfluxDB tags formatter.
/// </summary>
public static IStatsDTagsFormatter InfluxDb => new InfluxDbTagsFormatter();
public static IStatsDTagsFormatter InfluxDb { get; } = new InfluxDbTagsFormatter();

/// <summary>
/// Gets a Librato tags formatter.
/// </summary>
public static IStatsDTagsFormatter Librato => new LibratoTagsFormatter();
public static IStatsDTagsFormatter Librato { get; } = new LibratoTagsFormatter();

/// <summary>
/// Gets a SignalFX dimensions formatter.
/// </summary>
public static IStatsDTagsFormatter SignalFx => new SignalFxTagsFormatter();
public static IStatsDTagsFormatter SignalFx { get; } = new SignalFxTagsFormatter();

/// <summary>
/// Gets a Splunk tags formatter.
/// </summary>
public static IStatsDTagsFormatter Splunk => new TrailingTagsFormatter();
public static IStatsDTagsFormatter Splunk => TrailingTagsFormatter.Instance;
}
5 changes: 5 additions & 0 deletions src/JustEat.StatsD/TagsFormatters/TrailingTagsFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ public TrailingTagsFormatter()
})
{
}

/// <summary>
/// Gets the singleton instance of the <see cref="TrailingTagsFormatter"/> class.
/// </summary>
public static TrailingTagsFormatter Instance { get; } = new TrailingTagsFormatter();
}

0 comments on commit be25245

Please sign in to comment.