Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions THIRD-PARTY-NOTICES.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ freely, subject to the following restrictions:

3. This notice may not be removed or altered from any source distribution.

License notice for opentelemetry-dotnet
---------------------------------------

https://github.com/open-telemetry/opentelemetry-dotnet/blob/805dd6b4abfa18ef2706d04c30d0ed28dbc2955e/LICENSE.TXT#L1

Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

Copyright The OpenTelemetry Authors


License notice for LinuxTracepoints
-----------------------------------

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
<!--
Microsoft ResX Schema

Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes

The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.

Example:

... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
Expand All @@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple

There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the

Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not

The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can

Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.

mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
Expand Down Expand Up @@ -177,4 +177,10 @@
<data name="InvalidHistogramExplicitBucketBoundaries" xml:space="preserve">
<value>Histogram explicit bucket boundaries must be specified in ascending order and cannot contain duplicate values.</value>
</data>
</root>
<data name="InvalidHistogramScale" xml:space="preserve">
<value>Invalid scale value {0}. Scale must be greater than or equal to {1} and less than or equal to {2}.</value>
</data>
<data name="InvalidHistogramMaxBuckets" xml:space="preserve">
<value>Invalid Max buckets value {0}. Max buckets must be greater than or equal to {1}.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ System.Diagnostics.DiagnosticSource</PackageDescription>
<Compile Include="System\Diagnostics\Metrics\AggregationManager.cs" />
<Compile Include="System\Diagnostics\Metrics\Aggregator.cs" />
<Compile Include="System\Diagnostics\Metrics\AggregatorStore.cs" />
<Compile Include="System\Diagnostics\Metrics\Base2ExponentialHistogramAggregator.cs" />
<Compile Include="System\Diagnostics\Metrics\CircularBufferBuckets.cs" />
<Compile Include="System\Diagnostics\Metrics\Counter.cs" />
<Compile Include="System\Diagnostics\Metrics\ExponentialHistogramAggregator.cs" />
<Compile Include="System\Diagnostics\Metrics\Gauge.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ internal sealed class AggregationManager
private DateTime _startTime;
private DateTime _intervalStartTime;
private DateTime _nextIntervalStartTime;
private Func<Aggregator?> _histogramAggregatorFactory = () => new ExponentialHistogramAggregator(s_defaultHistogramConfig);

public AggregationManager(
int maxTimeSeries,
Expand Down Expand Up @@ -120,6 +121,16 @@ private void Include(Predicate<Instrument> instrumentFilter)
}
}

public void SetHistogramAggregation(Func<Aggregator?> histogramAggregatorFactory)
{
lock (this)
{
// While this operation is atomic, we use a lock to ensure thread safety when it's accessed by other parts of the code.
// Using lock(this) guarantees that no other thread is interacting with the field concurrently.
_histogramAggregatorFactory = histogramAggregatorFactory;
}
}

public AggregationManager SetCollectionPeriod(TimeSpan collectionPeriod)
{
// The caller, MetricsEventSource, is responsible for enforcing this
Expand Down Expand Up @@ -417,9 +428,7 @@ private void RemoveInstrumentState(Instrument instrument)
lock (this)
{
// checking currentHistograms first because avoiding unexpected increment of TimeSeries count.
return (!CheckHistogramAllowed() || !CheckTimeSeriesAllowed()) ?
null :
new ExponentialHistogramAggregator(s_defaultHistogramConfig);
return (!CheckHistogramAllowed() || !CheckTimeSeriesAllowed()) ? null : _histogramAggregatorFactory();
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,77 @@ internal HistogramStatistics(QuantileValue[] quantiles, int count, double sum)
public double Sum { get; }
}

internal sealed class LabeledAggregationStatistics
/// <summary>
/// Represents the statistics of a base 2 exponential histogram.
/// </summary>
internal sealed class Base2ExponentialHistogramStatistics : IAggregationStatistics
{
public LabeledAggregationStatistics(IAggregationStatistics stats, params KeyValuePair<string, string>[] labels)
/// <summary>
/// Initializes a new instance of the <see cref="Base2ExponentialHistogramStatistics"/> class capturing the current collected statistics.
/// </summary>
/// <param name="scale">Maximum scale factor.</param>
/// <param name="zeroCount">The number of zero values in the histogram.</param>
/// <param name="sum">The sum of all values in the histogram.</param>
/// <param name="count">The count of all values in the histogram.</param>
/// <param name="min">The minimum value in the histogram.</param>
/// <param name="max">The maximum value in the histogram.</param>
/// <param name="buckets">The buckets in the histogram.</param>
internal Base2ExponentialHistogramStatistics(int scale, long zeroCount, double sum, long count, double min, double max, long[] buckets)
{
AggregationStatistics = stats;
Labels = labels;
Scale = scale;
ZeroCount = zeroCount;
Sum = sum;
Count = count;
Minimum = min;
Maximum = max;
PositiveBuckets = buckets;
}

public KeyValuePair<string, string>[] Labels { get; }
public IAggregationStatistics AggregationStatistics { get; }
/// <summary>
/// Gets the maximum scale factor.
/// </summary>
public int Scale { get; }

/// <summary>
/// Gets the number of zero values in the histogram.
/// </summary>
public long ZeroCount { get; }

/// <summary>
/// Gets the sum of all values in the histogram.
/// </summary>
public double Sum { get; }

/// <summary>
/// Gets the count of all values in the histogram.
/// </summary>
public long Count { get; }

/// <summary>
/// Gets the minimum value in the histogram.
/// </summary>
public double Minimum { get; }

/// <summary>
/// Gets the maximum value in the histogram.
/// </summary>
public double Maximum { get; }

/// <summary>
/// Gets the positive measurement buckets in the histogram.
/// </summary>
public long[] PositiveBuckets { get; }
}

internal sealed class LabeledAggregationStatistics
{
public LabeledAggregationStatistics(IAggregationStatistics stats, params KeyValuePair<string, string>[] labels)
{
AggregationStatistics = stats;
Labels = labels;
}

public KeyValuePair<string, string>[] Labels { get; }
public IAggregationStatistics AggregationStatistics { get; }
}
}
Loading
Loading