Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding MinMax to Histograms #2735

Merged
merged 164 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from 159 commits
Commits
Show all changes
164 commits
Select commit Hold shift + click to select a range
f53d8b6
Squashed commit of the following:
mic-max Sep 23, 2021
e51aca6
Merge remote-tracking branch 'upstream/main' into main
mic-max Sep 27, 2021
3d15631
Merge remote-tracking branch 'upstream/main' into main
mic-max Sep 30, 2021
472eabb
Merge remote-tracking branch 'upstream/main' into main
mic-max Oct 13, 2021
4295758
Merge remote-tracking branch 'upstream/main'
mic-max Oct 14, 2021
4de8d0f
Merge remote-tracking branch 'upstream/main'
mic-max Oct 18, 2021
ccd3b53
Guard Type summary comment fix
mic-max Oct 18, 2021
1cac13f
Update TracerProviderBuilder.cs
mic-max Oct 18, 2021
d971dae
TryFetch optional param to skip obj null check
mic-max Oct 20, 2021
8ba84c5
Make guard internal
mic-max Oct 20, 2021
45d4caf
GuardTest doesn't need to be a static class
mic-max Oct 20, 2021
0b4c80e
Update src/OpenTelemetry/DiagnosticSourceInstrumentation/PropertyFetc…
mic-max Oct 20, 2021
964e9a6
Update Guard.cs
mic-max Oct 20, 2021
eae26ac
Merge branch 'main' of https://github.com/mic-max/opentelemetry-dotnet
mic-max Oct 20, 2021
169547a
Add Compile Guard to required project files
mic-max Oct 20, 2021
a473889
Update OpenTelemetry.Instrumentation.Http.csproj
mic-max Oct 20, 2021
e256363
Merge branch 'main' into main
cijothomas Oct 26, 2021
307ca0a
Merge remote-tracking branch 'upstream/main'
mic-max Oct 27, 2021
a67164e
Merge remote-tracking branch 'upstream/main'
mic-max Nov 4, 2021
ebe09e7
Merge remote-tracking branch 'upstream/main'
mic-max Nov 5, 2021
46deabc
Merge remote-tracking branch 'upstream/main'
mic-max Nov 9, 2021
88867c6
Merge remote-tracking branch 'upstream/main'
mic-max Nov 9, 2021
583e946
Merge remote-tracking branch 'upstream/main'
mic-max Nov 16, 2021
28c0299
Merge remote-tracking branch 'upstream/main'
mic-max Dec 6, 2021
18fc9c9
Merge remote-tracking branch 'upstream/main'
mic-max Dec 7, 2021
7734ff6
Merge remote-tracking branch 'upstream/main'
mic-max Dec 13, 2021
34f9c83
Merge remote-tracking branch 'upstream/main'
mic-max Dec 17, 2021
6dc71f0
Merge remote-tracking branch 'upstream/main'
mic-max Jan 7, 2022
d0d778d
Merge remote-tracking branch 'upstream/main'
mic-max Jan 12, 2022
01c4577
WIP compacting MetricPoint struct part 2.
CodeBlanch Dec 1, 2021
d6da88a
Smaller storage size for MetricPointStatus.
CodeBlanch Dec 1, 2021
7faec57
Cleanup and xml comments.
CodeBlanch Dec 2, 2021
eb3eed3
Histogram MinMax Configurable
mic-max Dec 11, 2021
41ed3f0
Fix test + fix sum and count for HistogramWithMinMax
mic-max Dec 11, 2021
8e85649
Refactor and fix RequestMetricIsCaptured in MetricTest.cs
mic-max Dec 11, 2021
87816e0
Update PublicAPI.Unshipped.txt
mic-max Dec 13, 2021
3429248
Fixed failing tests
mic-max Dec 15, 2021
f151e29
add another test case
mic-max Dec 15, 2021
ce6db94
histogram update and snapshot generalisation
mic-max Jan 10, 2022
7c3e806
Inlining: Aggressive instead of No
mic-max Jan 12, 2022
bb72e5d
Update MetricViewTests.cs
mic-max Jan 12, 2022
746e546
Merge branch 'main' into hist-min-max
cijothomas Jan 13, 2022
ecf8698
aggregation types
mic-max Feb 1, 2022
436c328
Update MetricPoint.cs
mic-max Feb 1, 2022
24e658d
Merge branch 'main' into hist-min-max
cijothomas Feb 2, 2022
8a05290
add: HistogramWithMinMax MetricType
mic-max Feb 2, 2022
823d28f
Merge remote-tracking branch 'upstream/main' into histogram-min-max
mic-max Feb 18, 2022
6ba455b
remove api
mic-max Feb 18, 2022
a69121c
Binary search for large bucket count histograms
mic-max May 4, 2022
6e446cd
Update CHANGELOG.md
mic-max May 4, 2022
e420a15
netcoreapp3.1 was complaining
mic-max May 4, 2022
e8913b2
ci rerun
mic-max May 4, 2022
4ade35a
ci rerun
mic-max May 4, 2022
52e2c43
Update MetricTestData.cs
mic-max May 4, 2022
f7e88af
use 400 buckets
mic-max May 12, 2022
51d7219
Update ExplicitBucketHistogramConfiguration.cs
mic-max May 4, 2022
1bb61e9
separate nan part
mic-max May 12, 2022
685b46e
Address PR comments
mic-max May 12, 2022
773fefd
Merge branch 'hist-binary' of https://github.com/mic-max/opentelemetr…
mic-max May 12, 2022
de60b0e
update to 140
mic-max May 12, 2022
020c42e
remove double.nan from invalid hist bounds
mic-max May 12, 2022
daf1a80
Refactor and perf to histogram bucket index find
mic-max May 25, 2022
5bc4998
fine tune bound limit to switch to binary search
mic-max May 26, 2022
e84127a
included benchmark results in comment
mic-max May 26, 2022
fb1ad6b
histogram stress test update
mic-max Jun 9, 2022
99bd6f1
Merge remote-tracking branch 'upstream/main' into hist-binary
mic-max Jun 28, 2022
05cc3c1
fix changelog
mic-max Jun 28, 2022
15c3464
spacing fix
mic-max Jun 28, 2022
99b0862
Merge remote-tracking branch 'upstream/main' into hist-min-max
mic-max Jun 29, 2022
e203c2f
Fix some (all?) build errors
mic-max Jun 29, 2022
a13fb6a
change already amde
mic-max Jun 29, 2022
acfebca
add min and max to otlp exporter
mic-max Jun 29, 2022
a2c0e5d
sealed bucket class
mic-max Jul 1, 2022
ef28da0
ci
mic-max Jul 1, 2022
1810ddd
Merge branch 'main' into hist-binary
mic-max Jul 1, 2022
543a6d5
double.negative infinity
mic-max Jul 5, 2022
19ddae3
Merge branch 'hist-binary' of https://github.com/mic-max/opentelemetr…
mic-max Jul 5, 2022
f2a20f7
update order of operations
mic-max Jul 5, 2022
c9f3a3d
remove stress test change
mic-max Jul 5, 2022
a201b86
ci
mic-max Jul 5, 2022
d0d92a7
Add histogram binary mode tests
mic-max Jul 6, 2022
7f8d32b
ci
mic-max Jul 6, 2022
53ad017
Merge branch 'main' into hist-binary
utpilla Jul 6, 2022
b41879c
Merge branch 'main' into hist-binary
mic-max Jul 8, 2022
dbc5f3e
pr review changes
mic-max Jul 11, 2022
3046ac7
Merge branch 'hist-binary' of https://github.com/mic-max/opentelemetr…
mic-max Jul 11, 2022
881caca
Merge branch 'main' into hist-binary
mic-max Jul 11, 2022
370fb1a
allocated column - hist benchmark
mic-max Jul 12, 2022
07689ac
Merge branch 'hist-binary' of https://github.com/mic-max/opentelemetr…
mic-max Jul 12, 2022
4fe19f9
Merge branch 'main' into hist-binary
mic-max Jul 12, 2022
4d97b4e
Merge branch 'main' into hist-binary
utpilla Jul 15, 2022
664d85a
Merge branch 'main' into hist-min-max
utpilla Jul 15, 2022
7b324c6
Merge branch 'main' into hist-min-max
cijothomas Jul 16, 2022
8307bf8
Merge branch 'main' into hist-binary
mic-max Jul 26, 2022
3b2f762
CI
mic-max Jul 26, 2022
2030736
Merge branch 'hist-binary' of https://github.com/mic-max/opentelemetr…
mic-max Jul 26, 2022
2ff79a9
add public api (still borked?)
mic-max Aug 2, 2022
2166c5a
Merge branch 'main' into hist-min-max
mic-max Aug 2, 2022
9485159
Merge branch 'main' into hist-min-max
utpilla Aug 2, 2022
4566b92
Exponential Bucket Histogram - part 6 (#3494)
reyang Jul 26, 2022
7f8801a
Minor fixes to Stress Tests (#3496)
cijothomas Jul 27, 2022
16f1e3f
Asp.Net Core Unit test [Activity started in middleware is modified by…
vishweshbankwar Jul 27, 2022
8854de3
Exponential Bucket Histogram - part 7 (#3499)
reyang Jul 27, 2022
7e65f56
OTLP exporter support for limiting activity tags, events, and links (…
alanwest Jul 28, 2022
df97482
EnvironmentVariableHelper support for boolean (#3457)
Kielek Jul 28, 2022
4e0dccd
[Logs] Add extension for registering OpenTelemetryLoggerProvider with…
CodeBlanch Jul 28, 2022
e3450b2
[Prometheus] Split up projects based on hosting mechanism. (#3430)
Yun-Ting Jul 28, 2022
8a4d395
Fix nits (#3502)
reyang Jul 29, 2022
c475666
fix: replace all newtonsoft.json usages (#3478)
ness001 Jul 29, 2022
eb49e4d
Fix Remote IP Address - NULL reference exception (#3481)
Jul 29, 2022
a3397aa
improve test coverage: OpenTelemetry.Api `CallerArgumentExpressionAtt…
TimothyMothra Jul 29, 2022
ba2986a
Exponential Bucket Histogram - part 8 (#3505)
reyang Jul 29, 2022
7517702
[Prometheus] Remove shared project and move the shared code under lis…
Yun-Ting Jul 30, 2022
cc5a56e
Dust off Prometheus Exporters (#3507)
reyang Aug 1, 2022
365828c
Nit fixed in prometheus for asp.net core (#3510)
cijothomas Aug 1, 2022
61ba0ed
Nit fixes to prometheus asp.net core (#3511)
cijothomas Aug 1, 2022
493ab1a
[Prometheus] Update changelog and minor cleanup. (#3512)
Yun-Ting Aug 2, 2022
9b0cc13
Aligning formats for CHANGLOG.md files. (#3513)
Yun-Ting Aug 2, 2022
fec60fe
ConsoleLogExporter special casing original format (#3516)
cijothomas Aug 2, 2022
0244fa0
refactor test exporters, use instead `DelegatingTestExporter` (#3486)
TimothyMothra Aug 2, 2022
59ed033
Improve PrometheusHttpListener options (#3521)
reyang Aug 2, 2022
0846309
Minor improvements to Prometheus Exporter (ASP.NET Core) (#3522)
reyang Aug 3, 2022
4362115
Fix OpenTracing shim under legacy AspNetCore activities (#3506)
pjanotti Aug 3, 2022
15e2e0a
Update CHANGELOG for 1.4.0-alpha.1 release (#3523)
utpilla Aug 3, 2022
b519072
Nit cleanup (#3518)
cijothomas Aug 3, 2022
dad7f99
Nit internal fixes for PrometheusExporter (#3525)
cijothomas Aug 3, 2022
e60763c
Add Min and Max to Histograms
mic-max Aug 3, 2022
9693e39
Forgot HistogramConfiguration.cs file
mic-max Aug 3, 2022
efb9aea
publicApi
mic-max Aug 4, 2022
f7eb066
Merge remote-tracking branch 'upstream/main' into min-max
mic-max Aug 4, 2022
7656430
Merge branch 'hist-min-max' of https://github.com/mic-max/opentelemet…
mic-max Aug 31, 2022
5b9116a
Merge remote-tracking branch 'upstream/main' into hist-min-max
mic-max Sep 2, 2022
4e58fef
bump
mic-max Sep 2, 2022
87dd299
Delete PublicAPI.Unshipped.txt
mic-max Sep 2, 2022
24dceb8
undo
mic-max Sep 2, 2022
d122198
fix
mic-max Sep 2, 2022
f834a90
Update PublicAPI.Unshipped.txt
mic-max Sep 3, 2022
637225f
Update MetricPoint.cs
mic-max Sep 6, 2022
922d19a
Initial upload
mic-max Sep 7, 2022
aa94f89
Add HistogramConfiguration.cs
mic-max Sep 7, 2022
f13ee18
Merge branch 'main' into hist-min-max
mic-max Sep 7, 2022
4ec2787
Merge branch 'main' into hist-min-max
mic-max Sep 13, 2022
6d126aa
Merge branch 'main' into hist-min-max
cijothomas Sep 13, 2022
efa15c8
Merge branch 'main' into hist-min-max
cijothomas Sep 14, 2022
47c4342
Merge branch 'main' into hist-min-max
cijothomas Sep 26, 2022
0760c35
mention MetricType.HistogramWithMinMax in changelog
mic-max Sep 26, 2022
f1f0a3f
reset running values to -/+ inf
mic-max Sep 26, 2022
5d81019
Merge branch 'hist-min-max' of https://github.com/mic-max/opentelemet…
mic-max Sep 26, 2022
d182298
Update AggregationType.cs
mic-max Sep 27, 2022
b2f84e6
Merge branch 'main' into hist-min-max
cijothomas Sep 27, 2022
e3e96e6
Update CHANGELOG.md
mic-max Sep 28, 2022
67dd44c
Merge branch 'main' into hist-min-max
mic-max Sep 28, 2022
c8fb75c
undo addition of histogramwithminmax metrictype
mic-max Oct 7, 2022
d9bdf1b
unfold hist update and snapshot
mic-max Oct 7, 2022
fea3c65
move recordminmax to metricstreamidentity
mic-max Oct 11, 2022
61be3b5
Merge remote-tracking branch 'upstream/main' into latest-min-max
mic-max Oct 11, 2022
3bad254
remove logs publicapi
mic-max Oct 11, 2022
1ad4a54
this one
mic-max Oct 11, 2022
fe853f3
TryGetHistogram Min/Max
mic-max Oct 12, 2022
3a868ae
Do not throw for minmax histogram
mic-max Oct 12, 2022
cb744d7
hasminmax strategy
mic-max Oct 12, 2022
a3dcdef
fix logic
mic-max Oct 12, 2022
7169a98
only aggtype for hasminmax
mic-max Oct 14, 2022
a282844
Merge branch 'main' into hist-min-max
mic-max Oct 14, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

* OTLP histogram data points will now include `Min` and `Max` values when
they are present.
([#2735](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2735))
mic-max marked this conversation as resolved.
Show resolved Hide resolved

## 1.4.0-beta.1

Released 2022-Sep-29
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,16 @@ internal static OtlpMetrics.Metric ToOtlpMetric(this Metric metric)
dataPoint.Count = (ulong)metricPoint.GetHistogramCount();
dataPoint.Sum = metricPoint.GetHistogramSum();

if (metricPoint.TryGetHistogramMax(out var max))
{
dataPoint.Max = max;
}

if (metricPoint.TryGetHistogramMin(out var min))
{
dataPoint.Min = min;
}

foreach (var histogramMeasurement in metricPoint.GetHistogramBuckets())
{
dataPoint.BucketCounts.Add((ulong)histogramMeasurement.BucketCount);
Expand Down
6 changes: 6 additions & 0 deletions src/OpenTelemetry/.publicApi/net462/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ OpenTelemetry.Logs.LogRecord.TraceFlags.set -> void
OpenTelemetry.Logs.LogRecord.TraceId.set -> void
OpenTelemetry.Logs.LogRecord.TraceState.set -> void
OpenTelemetry.Logs.OpenTelemetryLoggerOptions.ConfigureResource(System.Action<OpenTelemetry.Resources.ResourceBuilder!>! configure) -> OpenTelemetry.Logs.OpenTelemetryLoggerOptions!
OpenTelemetry.Metrics.HistogramConfiguration
OpenTelemetry.Metrics.HistogramConfiguration.HistogramConfiguration() -> void
OpenTelemetry.Metrics.HistogramConfiguration.RecordMinMax.get -> bool
OpenTelemetry.Metrics.HistogramConfiguration.RecordMinMax.set -> void
OpenTelemetry.Metrics.MetricPoint.TryGetHistogramMax(out double max) -> bool
OpenTelemetry.Metrics.MetricPoint.TryGetHistogramMin(out double min) -> bool
static Microsoft.Extensions.DependencyInjection.MeterProviderBuilderServiceCollectionExtensions.ConfigureOpenTelemetryMetrics(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> Microsoft.Extensions.DependencyInjection.IServiceCollection!
static Microsoft.Extensions.DependencyInjection.MeterProviderBuilderServiceCollectionExtensions.ConfigureOpenTelemetryMetrics(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services, System.Action<OpenTelemetry.Metrics.MeterProviderBuilder!>! configure) -> Microsoft.Extensions.DependencyInjection.IServiceCollection!
static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddInstrumentation<T>(this OpenTelemetry.Metrics.MeterProviderBuilder! meterProviderBuilder) -> OpenTelemetry.Metrics.MeterProviderBuilder!
Expand Down
6 changes: 6 additions & 0 deletions src/OpenTelemetry/.publicApi/net6.0/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ OpenTelemetry.Logs.LogRecord.TraceFlags.set -> void
OpenTelemetry.Logs.LogRecord.TraceId.set -> void
OpenTelemetry.Logs.LogRecord.TraceState.set -> void
OpenTelemetry.Logs.OpenTelemetryLoggerOptions.ConfigureResource(System.Action<OpenTelemetry.Resources.ResourceBuilder!>! configure) -> OpenTelemetry.Logs.OpenTelemetryLoggerOptions!
OpenTelemetry.Metrics.HistogramConfiguration
OpenTelemetry.Metrics.HistogramConfiguration.HistogramConfiguration() -> void
OpenTelemetry.Metrics.HistogramConfiguration.RecordMinMax.get -> bool
OpenTelemetry.Metrics.HistogramConfiguration.RecordMinMax.set -> void
OpenTelemetry.Metrics.MetricPoint.TryGetHistogramMax(out double max) -> bool
OpenTelemetry.Metrics.MetricPoint.TryGetHistogramMin(out double min) -> bool
static Microsoft.Extensions.DependencyInjection.MeterProviderBuilderServiceCollectionExtensions.ConfigureOpenTelemetryMetrics(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> Microsoft.Extensions.DependencyInjection.IServiceCollection!
static Microsoft.Extensions.DependencyInjection.MeterProviderBuilderServiceCollectionExtensions.ConfigureOpenTelemetryMetrics(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services, System.Action<OpenTelemetry.Metrics.MeterProviderBuilder!>! configure) -> Microsoft.Extensions.DependencyInjection.IServiceCollection!
static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddInstrumentation<T>(this OpenTelemetry.Metrics.MeterProviderBuilder! meterProviderBuilder) -> OpenTelemetry.Metrics.MeterProviderBuilder!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ OpenTelemetry.Logs.LogRecord.TraceFlags.set -> void
OpenTelemetry.Logs.LogRecord.TraceId.set -> void
OpenTelemetry.Logs.LogRecord.TraceState.set -> void
OpenTelemetry.Logs.OpenTelemetryLoggerOptions.ConfigureResource(System.Action<OpenTelemetry.Resources.ResourceBuilder!>! configure) -> OpenTelemetry.Logs.OpenTelemetryLoggerOptions!
OpenTelemetry.Metrics.HistogramConfiguration
OpenTelemetry.Metrics.HistogramConfiguration.HistogramConfiguration() -> void
OpenTelemetry.Metrics.HistogramConfiguration.RecordMinMax.get -> bool
OpenTelemetry.Metrics.HistogramConfiguration.RecordMinMax.set -> void
OpenTelemetry.Metrics.MetricPoint.TryGetHistogramMax(out double max) -> bool
OpenTelemetry.Metrics.MetricPoint.TryGetHistogramMin(out double min) -> bool
static Microsoft.Extensions.DependencyInjection.MeterProviderBuilderServiceCollectionExtensions.ConfigureOpenTelemetryMetrics(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> Microsoft.Extensions.DependencyInjection.IServiceCollection!
static Microsoft.Extensions.DependencyInjection.MeterProviderBuilderServiceCollectionExtensions.ConfigureOpenTelemetryMetrics(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services, System.Action<OpenTelemetry.Metrics.MeterProviderBuilder!>! configure) -> Microsoft.Extensions.DependencyInjection.IServiceCollection!
static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddInstrumentation<T>(this OpenTelemetry.Metrics.MeterProviderBuilder! meterProviderBuilder) -> OpenTelemetry.Metrics.MeterProviderBuilder!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ OpenTelemetry.Logs.LogRecord.TraceFlags.set -> void
OpenTelemetry.Logs.LogRecord.TraceId.set -> void
OpenTelemetry.Logs.LogRecord.TraceState.set -> void
OpenTelemetry.Logs.OpenTelemetryLoggerOptions.ConfigureResource(System.Action<OpenTelemetry.Resources.ResourceBuilder!>! configure) -> OpenTelemetry.Logs.OpenTelemetryLoggerOptions!
OpenTelemetry.Metrics.HistogramConfiguration
OpenTelemetry.Metrics.HistogramConfiguration.HistogramConfiguration() -> void
OpenTelemetry.Metrics.HistogramConfiguration.RecordMinMax.get -> bool
OpenTelemetry.Metrics.HistogramConfiguration.RecordMinMax.set -> void
OpenTelemetry.Metrics.MetricPoint.TryGetHistogramMax(out double max) -> bool
OpenTelemetry.Metrics.MetricPoint.TryGetHistogramMin(out double min) -> bool
static Microsoft.Extensions.DependencyInjection.MeterProviderBuilderServiceCollectionExtensions.ConfigureOpenTelemetryMetrics(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> Microsoft.Extensions.DependencyInjection.IServiceCollection!
static Microsoft.Extensions.DependencyInjection.MeterProviderBuilderServiceCollectionExtensions.ConfigureOpenTelemetryMetrics(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services, System.Action<OpenTelemetry.Metrics.MeterProviderBuilder!>! configure) -> Microsoft.Extensions.DependencyInjection.IServiceCollection!
static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddInstrumentation<T>(this OpenTelemetry.Metrics.MeterProviderBuilder! meterProviderBuilder) -> OpenTelemetry.Metrics.MeterProviderBuilder!
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

* Make recording of `Min` and `Max` for histograms configurable, enabled by
default.
([#2735](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2735))

* Fixed an issue where `LogRecord.ForEachScope` may return scopes from a
previous log if accessed in a custom processor before
`BatchLogRecordExportProcessor.OnEnd` is fired.
Expand Down
16 changes: 13 additions & 3 deletions src/OpenTelemetry/Metrics/AggregationType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,23 @@ internal enum AggregationType
DoubleGauge = 5,

/// <summary>
/// Histogram.
/// Histogram with sum, count, buckets.
/// </summary>
Histogram = 6,

/// <summary>
/// Histogram with sum, count only.
/// Histogram with sum, count, min, max, buckets.
/// </summary>
HistogramSumCount = 7,
HistogramMinMax = 7,

/// <summary>
/// Histogram with sum, count.
/// </summary>
HistogramSumCount = 8,

/// <summary>
/// Histogram with sum, count, min, max.
/// </summary>
HistogramSumCountMinMax = 9,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace OpenTelemetry.Metrics
/// <summary>
/// Stores configuration for a histogram metric stream with explicit bucket boundaries.
/// </summary>
public class ExplicitBucketHistogramConfiguration : MetricStreamConfiguration
public class ExplicitBucketHistogramConfiguration : HistogramConfiguration
{
/// <summary>
/// Gets or sets the optional boundaries of the histogram metric stream.
Expand Down
8 changes: 6 additions & 2 deletions src/OpenTelemetry/Metrics/HistogramBuckets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@ public class HistogramBuckets
internal readonly double[] ExplicitBounds;

internal readonly long[] RunningBucketCounts;

internal readonly long[] SnapshotBucketCounts;

internal double RunningSum;

internal double SnapshotSum;

internal double RunningMin = double.PositiveInfinity;
internal double SnapshotMin;

internal double RunningMax = double.NegativeInfinity;
internal double SnapshotMax;

internal int IsCriticalSectionOccupied = 0;

private readonly BucketLookupNode bucketLookupTreeRoot;
Expand Down
26 changes: 26 additions & 0 deletions src/OpenTelemetry/Metrics/HistogramConfiguration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// <copyright file="HistogramConfiguration.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>

namespace OpenTelemetry.Metrics;

public class HistogramConfiguration : MetricStreamConfiguration
utpilla marked this conversation as resolved.
Show resolved Hide resolved
{
/// <summary>
/// Gets or sets a value indicating whether Min, Max
/// should be collected.
/// </summary>
public bool RecordMinMax { get; set; } = true;
}
15 changes: 5 additions & 10 deletions src/OpenTelemetry/Metrics/Metric.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ internal Metric(
AggregationTemporality temporality,
int maxMetricPointsPerMetricStream,
double[] histogramBounds = null,
string[] tagKeysInteresting = null)
string[] tagKeysInteresting = null,
bool histogramRecordMinMax = true)
{
this.InstrumentIdentity = instrumentIdentity;

Expand Down Expand Up @@ -118,15 +119,9 @@ internal Metric(
{
this.MetricType = MetricType.Histogram;

if (histogramBounds != null
&& histogramBounds.Length == 0)
{
aggType = AggregationType.HistogramSumCount;
}
else
{
aggType = AggregationType.Histogram;
}
aggType = histogramBounds != null && histogramBounds.Length == 0
? (histogramRecordMinMax ? AggregationType.HistogramSumCountMinMax : AggregationType.HistogramSumCount)
mic-max marked this conversation as resolved.
Show resolved Hide resolved
: (histogramRecordMinMax ? AggregationType.HistogramMinMax : AggregationType.Histogram);
}
else
{
Expand Down
Loading