Skip to content

Commit

Permalink
Trim the names just to be sure the metrics are valid
Browse files Browse the repository at this point in the history
  • Loading branch information
niemyjski committed Sep 27, 2024
1 parent 7fe9227 commit 9de727b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/Foundatio/Queues/QueueBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ protected QueueBase(TOptions options) : base(options?.TimeProvider, options?.Log
{
_options = options ?? throw new ArgumentNullException(nameof(options));
_metricsPrefix = $"foundatio.{typeof(T).Name.ToLowerInvariant()}";
if (!String.IsNullOrEmpty(options.MetricsPrefix))
_metricsPrefix = $"{_metricsPrefix}.{options.MetricsPrefix}";
if (!String.IsNullOrWhiteSpace(options.MetricsPrefix))
_metricsPrefix = $"{_metricsPrefix}.{options.MetricsPrefix.Trim()}";

QueueId = options.Name + Guid.NewGuid().ToString("N").Substring(10);
QueueId = $"{options.Name.Trim()}{Guid.NewGuid().ToString("N").Substring(10)}";

_serializer = options.Serializer ?? DefaultSerializer.Instance;
options.Behaviors.ForEach(AttachBehavior);
Expand Down
9 changes: 5 additions & 4 deletions src/Foundatio/Queues/SharedQueueOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ public class SharedQueueOptionsBuilder<T, TOptions, TBuilder> : SharedOptionsBui
{
public TBuilder Name(string name)
{
if (!String.IsNullOrEmpty(name))
Target.Name = name;
if (!String.IsNullOrWhiteSpace(name))
Target.Name = name.Trim();

return (TBuilder)this;
}

Expand Down Expand Up @@ -72,8 +73,8 @@ public TBuilder AddBehavior(IQueueBehavior<T> behavior)
/// </summary>
public TBuilder MetricsPrefix(string prefix)
{
if (!String.IsNullOrEmpty(prefix))
Target.MetricsPrefix = prefix;
if (!String.IsNullOrWhiteSpace(prefix))
Target.MetricsPrefix = prefix.Trim();
return (TBuilder)this;
}
}

0 comments on commit 9de727b

Please sign in to comment.