Simplify code (#2491)
This commit is contained in:
parent
d119447e07
commit
84bdf38fe1
|
|
@ -1,35 +0,0 @@
|
|||
// <copyright file="DropConfiguration.cs" company="OpenTelemetry Authors">
|
||||
// Copyright The OpenTelemetry Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// </copyright>
|
||||
|
||||
using System;
|
||||
|
||||
namespace OpenTelemetry.Metrics
|
||||
{
|
||||
internal class DropConfiguration : MetricStreamConfiguration
|
||||
{
|
||||
private Aggregation aggregation = Aggregation.Drop;
|
||||
|
||||
public override Aggregation Aggregation
|
||||
{
|
||||
get => this.aggregation;
|
||||
|
||||
set
|
||||
{
|
||||
throw new ArgumentException($"Aggregation cannot be set.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -41,5 +41,14 @@ namespace OpenTelemetry.Metrics
|
|||
public virtual Aggregation Aggregation { get; set; }
|
||||
|
||||
// TODO: MetricPoints caps can be configured here
|
||||
|
||||
private sealed class DropConfiguration : MetricStreamConfiguration
|
||||
{
|
||||
public override Aggregation Aggregation
|
||||
{
|
||||
get => Aggregation.Drop;
|
||||
set { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -370,7 +370,8 @@ namespace OpenTelemetry.Metrics.Tests
|
|||
[Fact]
|
||||
public void MetricStreamConfigurationForDropMustNotAllowOverriding()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => MetricStreamConfiguration.Drop.Aggregation = Aggregation.Histogram);
|
||||
MetricStreamConfiguration.Drop.Aggregation = Aggregation.Histogram;
|
||||
Assert.Equal(Aggregation.Drop, MetricStreamConfiguration.Drop.Aggregation);
|
||||
}
|
||||
}
|
||||
#pragma warning restore SA1000 // KeywordsMustBeSpacedCorrectly
|
||||
|
|
|
|||
Loading…
Reference in New Issue