Skip to content

Commit 9de727b

Browse files
committed
Trim the names just to be sure the metrics are valid
1 parent 7fe9227 commit 9de727b

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/Foundatio/Queues/QueueBase.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ protected QueueBase(TOptions options) : base(options?.TimeProvider, options?.Log
4141
{
4242
_options = options ?? throw new ArgumentNullException(nameof(options));
4343
_metricsPrefix = $"foundatio.{typeof(T).Name.ToLowerInvariant()}";
44-
if (!String.IsNullOrEmpty(options.MetricsPrefix))
45-
_metricsPrefix = $"{_metricsPrefix}.{options.MetricsPrefix}";
44+
if (!String.IsNullOrWhiteSpace(options.MetricsPrefix))
45+
_metricsPrefix = $"{_metricsPrefix}.{options.MetricsPrefix.Trim()}";
4646

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

4949
_serializer = options.Serializer ?? DefaultSerializer.Instance;
5050
options.Behaviors.ForEach(AttachBehavior);

src/Foundatio/Queues/SharedQueueOptions.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ public class SharedQueueOptionsBuilder<T, TOptions, TBuilder> : SharedOptionsBui
2323
{
2424
public TBuilder Name(string name)
2525
{
26-
if (!String.IsNullOrEmpty(name))
27-
Target.Name = name;
26+
if (!String.IsNullOrWhiteSpace(name))
27+
Target.Name = name.Trim();
28+
2829
return (TBuilder)this;
2930
}
3031

@@ -72,8 +73,8 @@ public TBuilder AddBehavior(IQueueBehavior<T> behavior)
7273
/// </summary>
7374
public TBuilder MetricsPrefix(string prefix)
7475
{
75-
if (!String.IsNullOrEmpty(prefix))
76-
Target.MetricsPrefix = prefix;
76+
if (!String.IsNullOrWhiteSpace(prefix))
77+
Target.MetricsPrefix = prefix.Trim();
7778
return (TBuilder)this;
7879
}
7980
}

0 commit comments

Comments
 (0)