Skip to content

Commit

Permalink
Merge branch 'main' into filter-processor
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeBlanch committed Oct 27, 2022
2 parents 2ea306c + d954c5b commit b90b4fa
Show file tree
Hide file tree
Showing 32 changed files with 377 additions and 135 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/apicompatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # fetching all
- uses: actions/setup-dotnet@v3.0.2
- uses: actions/setup-dotnet@v3.0.3
with:
dotnet-version: '7.0.x'
include-prerelease: true

- name: Install dependencies
run: dotnet restore
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # fetching all
- uses: actions/setup-dotnet@v3.0.2
- uses: actions/setup-dotnet@v3.0.3
with:
dotnet-version: '7.0.x'
include-prerelease: true

- name: Install dependencies
run: dotnet restore
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/dotnet-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ jobs:
uses: actions/checkout@v3

- name: Setup .NET Core 7.0
uses: actions/setup-dotnet@v3.0.2
uses: actions/setup-dotnet@v3.0.3
with:
dotnet-version: '7.0.x'
include-prerelease: true

- name: Install format tool
run: dotnet tool install -g dotnet-format
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/linux-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@ jobs:
with:
fetch-depth: 0 # fetching all

- uses: actions/setup-dotnet@v3.0.2
- uses: actions/setup-dotnet@v3.0.3
with:
dotnet-version: '6.0.x'

- uses: actions/setup-dotnet@v3.0.2
- uses: actions/setup-dotnet@v3.0.3
with:
dotnet-version: '7.0.x'
include-prerelease: true


- name: Install dependencies
run: dotnet restore
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/publish-packages-1.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ jobs:
fetch-depth: 0 # fetching all
ref: ${{ github.ref || 'main' }}

- uses: actions/setup-dotnet@v3.0.2
- uses: actions/setup-dotnet@v3.0.3
with:
dotnet-version: '7.0.x'
include-prerelease: true

- name: Install dependencies
run: dotnet restore
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/windows-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ jobs:
with:
fetch-depth: 0 # fetching all

- uses: actions/setup-dotnet@v3.0.2
- uses: actions/setup-dotnet@v3.0.3
with:
dotnet-version: '7.0.x'
include-prerelease: true

- name: Install dependencies
run: dotnet restore
Expand Down
4 changes: 2 additions & 2 deletions src/OpenTelemetry.Exporter.Console/ConsoleMetricExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ public override ExportResult Export(in Batch<Metric> batch)
var sum = metricPoint.GetHistogramSum();
var count = metricPoint.GetHistogramCount();
bucketsBuilder.Append($"Sum: {sum} Count: {count} ");
if (metricPoint.HasMinMax())
if (metricPoint.TryGetHistogramMinMaxValues(out double min, out double max))
{
bucketsBuilder.Append($"Min: {metricPoint.GetHistogramMin()} Max: {metricPoint.GetHistogramMax()} ");
bucketsBuilder.Append($"Min: {min} Max: {max} ");
}

bucketsBuilder.AppendLine();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
#if SIGNED
[assembly: InternalsVisibleTo("OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051c1562a090fb0c9f391012a32198b5e5d9a60e9b80fa2d7b434c9e5ccb7259bd606e66f9660676afc6692b8cdc6793d190904551d2103b7b22fa636dcbb8208839785ba402ea08fc00c8f1500ccef28bbf599aa64ffb1e1d5dc1bf3420a3777badfe697856e9d52070a50c3ea5821c80bef17ca3acffa28f89dd413f096f898")]
[assembly: InternalsVisibleTo("Benchmarks, PublicKey=002400000480000094000000060200000024000052534131000400000100010051c1562a090fb0c9f391012a32198b5e5d9a60e9b80fa2d7b434c9e5ccb7259bd606e66f9660676afc6692b8cdc6793d190904551d2103b7b22fa636dcbb8208839785ba402ea08fc00c8f1500ccef28bbf599aa64ffb1e1d5dc1bf3420a3777badfe697856e9d52070a50c3ea5821c80bef17ca3acffa28f89dd413f096f898")]
[assembly: InternalsVisibleTo("MockOpenTelemetryCollector, PublicKey=002400000480000094000000060200000024000052534131000400000100010051c1562a090fb0c9f391012a32198b5e5d9a60e9b80fa2d7b434c9e5ccb7259bd606e66f9660676afc6692b8cdc6793d190904551d2103b7b22fa636dcbb8208839785ba402ea08fc00c8f1500ccef28bbf599aa64ffb1e1d5dc1bf3420a3777badfe697856e9d52070a50c3ea5821c80bef17ca3acffa28f89dd413f096f898")]
[assembly: InternalsVisibleTo("OpenTelemetry.Exporter.OpenTelemetryProtocol.Logs, PublicKey=002400000480000094000000060200000024000052534131000400000100010051c1562a090fb0c9f391012a32198b5e5d9a60e9b80fa2d7b434c9e5ccb7259bd606e66f9660676afc6692b8cdc6793d190904551d2103b7b22fa636dcbb8208839785ba402ea08fc00c8f1500ccef28bbf599aa64ffb1e1d5dc1bf3420a3777badfe697856e9d52070a50c3ea5821c80bef17ca3acffa28f89dd413f096f898")]

// Used by Moq.
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
#else
[assembly: InternalsVisibleTo("OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests")]
[assembly: InternalsVisibleTo("Benchmarks")]
[assembly: InternalsVisibleTo("MockOpenTelemetryCollector")]

// Used by Moq.
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,10 @@ internal static OtlpMetrics.Metric ToOtlpMetric(this Metric metric)
dataPoint.Count = (ulong)metricPoint.GetHistogramCount();
dataPoint.Sum = metricPoint.GetHistogramSum();

if (metricPoint.HasMinMax())
if (metricPoint.TryGetHistogramMinMaxValues(out double min, out double max))
{
dataPoint.Min = metricPoint.GetHistogramMin();
dataPoint.Max = metricPoint.GetHistogramMax();
dataPoint.Min = min;
dataPoint.Max = max;
}

foreach (var histogramMeasurement in metricPoint.GetHistogramBuckets())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal sealed class AspNetCoreInstrumentation : IDisposable
"Microsoft.AspNetCore.Hosting.UnhandledException",
};

private readonly Func<string, object, object, bool> isEnabled = (eventName, obj1, obj2)
private readonly Func<string, object, object, bool> isEnabled = (eventName, _, _)
=> DiagnosticSourceEvents.Contains(eventName);

private readonly DiagnosticSourceSubscriber diagnosticSourceSubscriber;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// </copyright>

using System;
using System.Collections.Generic;
using System.Diagnostics.Metrics;
using System.Reflection;
using OpenTelemetry.Instrumentation.AspNetCore.Implementation;
Expand All @@ -30,6 +31,16 @@ internal sealed class AspNetCoreMetrics : IDisposable
internal static readonly string InstrumentationName = AssemblyName.Name;
internal static readonly string InstrumentationVersion = AssemblyName.Version.ToString();

private static readonly HashSet<string> DiagnosticSourceEvents = new()
{
"Microsoft.AspNetCore.Hosting.HttpRequestIn",
"Microsoft.AspNetCore.Hosting.HttpRequestIn.Start",
"Microsoft.AspNetCore.Hosting.HttpRequestIn.Stop",
};

private readonly Func<string, object, object, bool> isEnabled = (eventName, _, _)
=> DiagnosticSourceEvents.Contains(eventName);

private readonly DiagnosticSourceSubscriber diagnosticSourceSubscriber;
private readonly Meter meter;

Expand All @@ -39,7 +50,7 @@ internal sealed class AspNetCoreMetrics : IDisposable
public AspNetCoreMetrics()
{
this.meter = new Meter(InstrumentationName, InstrumentationVersion);
this.diagnosticSourceSubscriber = new DiagnosticSourceSubscriber(new HttpInMetricsListener("Microsoft.AspNetCore", this.meter), null);
this.diagnosticSourceSubscriber = new DiagnosticSourceSubscriber(new HttpInMetricsListener("Microsoft.AspNetCore", this.meter), this.isEnabled);
this.diagnosticSourceSubscriber.Subscribe();
}

Expand Down
4 changes: 1 addition & 3 deletions src/OpenTelemetry/.publicApi/net462/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ OpenTelemetry.Metrics.HistogramConfiguration
OpenTelemetry.Metrics.HistogramConfiguration.HistogramConfiguration() -> void
OpenTelemetry.Metrics.HistogramConfiguration.RecordMinMax.get -> bool
OpenTelemetry.Metrics.HistogramConfiguration.RecordMinMax.set -> void
OpenTelemetry.Metrics.MetricPoint.GetHistogramMax() -> double
OpenTelemetry.Metrics.MetricPoint.GetHistogramMin() -> double
OpenTelemetry.Metrics.MetricPoint.HasMinMax() -> bool
OpenTelemetry.Metrics.MetricPoint.TryGetHistogramMinMaxValues(out double min, out double max) -> bool
OpenTelemetry.Resources.ResourceBuilder.AddDetector(System.Func<System.IServiceProvider?, OpenTelemetry.Resources.IResourceDetector!>! resourceDetectorFactory) -> OpenTelemetry.Resources.ResourceBuilder!
OpenTelemetry.Trace.BatchExportActivityProcessorOptions.BatchExportActivityProcessorOptions(Microsoft.Extensions.Configuration.IConfiguration! configuration) -> void
static Microsoft.Extensions.DependencyInjection.MeterProviderBuilderServiceCollectionExtensions.ConfigureOpenTelemetryMetrics(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> Microsoft.Extensions.DependencyInjection.IServiceCollection!
Expand Down
4 changes: 1 addition & 3 deletions src/OpenTelemetry/.publicApi/net6.0/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ OpenTelemetry.Metrics.HistogramConfiguration
OpenTelemetry.Metrics.HistogramConfiguration.HistogramConfiguration() -> void
OpenTelemetry.Metrics.HistogramConfiguration.RecordMinMax.get -> bool
OpenTelemetry.Metrics.HistogramConfiguration.RecordMinMax.set -> void
OpenTelemetry.Metrics.MetricPoint.GetHistogramMax() -> double
OpenTelemetry.Metrics.MetricPoint.GetHistogramMin() -> double
OpenTelemetry.Metrics.MetricPoint.HasMinMax() -> bool
OpenTelemetry.Metrics.MetricPoint.TryGetHistogramMinMaxValues(out double min, out double max) -> bool
OpenTelemetry.Resources.ResourceBuilder.AddDetector(System.Func<System.IServiceProvider?, OpenTelemetry.Resources.IResourceDetector!>! resourceDetectorFactory) -> OpenTelemetry.Resources.ResourceBuilder!
OpenTelemetry.Trace.BatchExportActivityProcessorOptions.BatchExportActivityProcessorOptions(Microsoft.Extensions.Configuration.IConfiguration! configuration) -> void
static Microsoft.Extensions.DependencyInjection.MeterProviderBuilderServiceCollectionExtensions.ConfigureOpenTelemetryMetrics(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> Microsoft.Extensions.DependencyInjection.IServiceCollection!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ OpenTelemetry.Metrics.HistogramConfiguration
OpenTelemetry.Metrics.HistogramConfiguration.HistogramConfiguration() -> void
OpenTelemetry.Metrics.HistogramConfiguration.RecordMinMax.get -> bool
OpenTelemetry.Metrics.HistogramConfiguration.RecordMinMax.set -> void
OpenTelemetry.Metrics.MetricPoint.GetHistogramMax() -> double
OpenTelemetry.Metrics.MetricPoint.GetHistogramMin() -> double
OpenTelemetry.Metrics.MetricPoint.HasMinMax() -> bool
OpenTelemetry.Metrics.MetricPoint.TryGetHistogramMinMaxValues(out double min, out double max) -> bool
OpenTelemetry.Resources.ResourceBuilder.AddDetector(System.Func<System.IServiceProvider?, OpenTelemetry.Resources.IResourceDetector!>! resourceDetectorFactory) -> OpenTelemetry.Resources.ResourceBuilder!
OpenTelemetry.Trace.BatchExportActivityProcessorOptions.BatchExportActivityProcessorOptions(Microsoft.Extensions.Configuration.IConfiguration! configuration) -> void
static Microsoft.Extensions.DependencyInjection.MeterProviderBuilderServiceCollectionExtensions.ConfigureOpenTelemetryMetrics(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> Microsoft.Extensions.DependencyInjection.IServiceCollection!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ OpenTelemetry.Metrics.HistogramConfiguration
OpenTelemetry.Metrics.HistogramConfiguration.HistogramConfiguration() -> void
OpenTelemetry.Metrics.HistogramConfiguration.RecordMinMax.get -> bool
OpenTelemetry.Metrics.HistogramConfiguration.RecordMinMax.set -> void
OpenTelemetry.Metrics.MetricPoint.GetHistogramMax() -> double
OpenTelemetry.Metrics.MetricPoint.GetHistogramMin() -> double
OpenTelemetry.Metrics.MetricPoint.HasMinMax() -> bool
OpenTelemetry.Metrics.MetricPoint.TryGetHistogramMinMaxValues(out double min, out double max) -> bool
OpenTelemetry.Resources.ResourceBuilder.AddDetector(System.Func<System.IServiceProvider?, OpenTelemetry.Resources.IResourceDetector!>! resourceDetectorFactory) -> OpenTelemetry.Resources.ResourceBuilder!
OpenTelemetry.Trace.BatchExportActivityProcessorOptions.BatchExportActivityProcessorOptions(Microsoft.Extensions.Configuration.IConfiguration! configuration) -> void
static Microsoft.Extensions.DependencyInjection.MeterProviderBuilderServiceCollectionExtensions.ConfigureOpenTelemetryMetrics(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> Microsoft.Extensions.DependencyInjection.IServiceCollection!
Expand Down
7 changes: 7 additions & 0 deletions src/OpenTelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
([#3782](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3782),
[#3798](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3798))

* Breaking: MetricPoint API to retrieve Histogram Min, Max changed. The existing
pattern of checking if Min/Max is available with `HasMinMax()` and then
retrieving the same using `GetHistogramMin()`, `GetHistogramMax()` is replaced
with a single API `TryGetHistogramMinMaxValues(out double min, out double
max)`.
([#3822](https://github.com/open-telemetry/opentelemetry-dotnet/pull/3822))

## 1.4.0-beta.2

Released 2022-Oct-17
Expand Down
8 changes: 4 additions & 4 deletions src/OpenTelemetry/Metrics/AggregationType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,21 @@ internal enum AggregationType
/// <summary>
/// Histogram with sum, count, buckets.
/// </summary>
Histogram = 6,
HistogramWithBuckets = 6,

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

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

/// <summary>
/// Histogram with sum, count, min, max.
/// </summary>
HistogramSumCountMinMax = 9,
HistogramWithMinMax = 9,
}
}
20 changes: 10 additions & 10 deletions src/OpenTelemetry/Metrics/AggregatorStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,16 @@ private int LookupAggregatorStore(string[] tagKeys, object[] tagValues, int leng

if (!this.tagsToMetricPointIndexDictionary.TryGetValue(sortedTags, out aggregatorIndex))
{
aggregatorIndex = this.metricPointIndex;
if (aggregatorIndex >= this.maxMetricPoints)
{
// sorry! out of data points.
// TODO: Once we support cleanup of
// unused points (typically with delta)
// we can re-claim them here.
return -1;
}

// Note: We are using storage from ThreadStatic for both the input order of tags and the sorted order of tags,
// so we need to make a deep copy for Dictionary storage.
var givenKeys = new string[length];
Expand All @@ -208,16 +218,6 @@ private int LookupAggregatorStore(string[] tagKeys, object[] tagValues, int leng
givenTags = new Tags(givenKeys, givenValues);
sortedTags = new Tags(sortedTagKeys, sortedTagValues);

aggregatorIndex = this.metricPointIndex;
if (aggregatorIndex >= this.maxMetricPoints)
{
// sorry! out of data points.
// TODO: Once we support cleanup of
// unused points (typically with delta)
// we can re-claim them here.
return -1;
}

lock (this.tagsToMetricPointIndexDictionary)
{
// check again after acquiring lock.
Expand Down
4 changes: 2 additions & 2 deletions src/OpenTelemetry/Metrics/Metric.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ internal Metric(
this.MetricType = MetricType.Histogram;

aggType = histogramBounds != null && histogramBounds.Length == 0
? (histogramRecordMinMax ? AggregationType.HistogramSumCountMinMax : AggregationType.HistogramSumCount)
: (histogramRecordMinMax ? AggregationType.HistogramMinMax : AggregationType.Histogram);
? (histogramRecordMinMax ? AggregationType.HistogramWithMinMax : AggregationType.Histogram)
: (histogramRecordMinMax ? AggregationType.HistogramWithMinMaxBuckets : AggregationType.HistogramWithBuckets);
}
else
{
Expand Down
Loading

0 comments on commit b90b4fa

Please sign in to comment.