Skip to content

Commit

Permalink
Merge branch 'main' into vibankwa/remove-baggage-clearance-aspnetcore
Browse files Browse the repository at this point in the history
  • Loading branch information
vishweshbankwar authored Mar 10, 2023
2 parents 7c098e7 + a1ea6d6 commit 00ec5b7
Show file tree
Hide file tree
Showing 33 changed files with 566 additions and 20 deletions.
12 changes: 7 additions & 5 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
Fixes #.
Fixes #
Design discussion issue #

## Changes

Please provide a brief description of the changes here.

For significant contributions please make sure you have completed the following items:
## Merge requirement checklist

* [ ] Appropriate `CHANGELOG.md` updated for non-trivial changes
* [ ] Design discussion issue #
* [ ] Changes in public API reviewed
* [ ] [CONTRIBUTING](https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/CONTRIBUTING.md) guidelines followed (nullable enabled, static analysis, etc.)
* [ ] Unit tests added/updated
* [ ] Appropriate `CHANGELOG.md` files updated for non-trivial changes
* [ ] Changes in public API reviewed (if applicable)
39 changes: 39 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,42 @@ only and does not affect the actual build of the project.
This repository also includes StyleCop ruleset files under the `./build` folder.
These files are used to configure the _StyleCop.Analyzers_ which runs during
build. Breaking the rules will result in a build failure.

## New projects

New projects are required to:

* Use [nullable reference
types](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/nullable-reference-types).

This should be enabled automatically via
[Common.props](https://github.com/open-telemetry/opentelemetry-dotnet/blob/990deee419ab4c1449efd628bed3df57a50963a6/build/Common.props#L9).
New project MUST NOT disable this.

* Pass [static
analysis](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/overview).

New projects MUST enable static analysis by specifying
`<AnalysisLevel>latest-all</AnalysisLevel>` in the project file (`.csproj`).

> **Note**
> There are other project-level features enabled automatically via
[Common.props](https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/build/Common.props)
new projects must NOT manually override these settings.

## New code

New code files MUST enable [nullable reference
types](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/nullable-reference-types)
manually in projects where it is not automatically enabled project-wide. This is
done by specifying `#nullable enable` towards the top of the file (usually after
the copyright header). We are currently working towards enabling nullable
context in every project by updating code as it is worked on, this requirement
is to make sure the surface area of code needing updates is shrinking and not
expanding.

> **Note**
> The first time a project is updated to use nullable context in public APIs
some housekeeping needs to be done in public API definitions (`.publicApi`
folder). This can be done automatically via a code fix offered by the public API
analyzer.
2 changes: 1 addition & 1 deletion OpenTelemetry.sln
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "getting-started-console", "
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "getting-started-jaeger", "docs\trace\getting-started-jaeger\getting-started-jaeger.csproj", "{A0C0B77C-6C7B-4EC2-AC61-EA1F489811B9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "stratified-sampling-example", "docs\trace\advanced\stratified-sampling-example\stratified-sampling-example.csproj", "{9C99621C-343E-479C-A943-332DB6129B71}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "stratified-sampling-example", "docs\trace\stratified-sampling-example\stratified-sampling-example.csproj", "{9C99621C-343E-479C-A943-332DB6129B71}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
2 changes: 1 addition & 1 deletion examples/MicroserviceExample/WebApi/WebApi.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Worker">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Api.ProviderBuilderExtensions/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.5.0-alpha.1

Released 2023-Mar-07

## 1.4.0

Released 2023-Feb-24
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.5.0-alpha.1

Released 2023-Mar-07

## 1.4.0

Released 2023-Feb-24
Expand Down
7 changes: 7 additions & 0 deletions src/OpenTelemetry.Exporter.Console/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## Unreleased

## 1.5.0-alpha.1

Released 2023-Mar-07

* Added Exemplar support. See [exemplars](../../docs/metrics/customizing-the-sdk/README.md#exemplars)
for instructions to enable exemplars.

## 1.4.0

Released 2023-Feb-24
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Exporter.InMemory/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.5.0-alpha.1

Released 2023-Mar-07

## 1.4.0

Released 2023-Feb-24
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Exporter.Jaeger/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.5.0-alpha.1

Released 2023-Mar-07

## 1.4.0

Released 2023-Feb-24
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.5.0-alpha.1

Released 2023-Mar-07

## 1.4.0-rc.4

Released 2023-Feb-10
Expand Down
7 changes: 7 additions & 0 deletions src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@

## Unreleased

## 1.5.0-alpha.1

Released 2023-Mar-07

* Bumped the version of `Google.Protobuf` used by the project to `3.22.0` so
that a new performance feature can be used instead of reflection. Removed the
dependency on `System.Reflection.Emit.Lightweight`.
([#4201](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4201))

* Added Exemplar support. See [exemplars](../../docs/metrics/customizing-the-sdk/README.md#exemplars)
for instructions to enable exemplars.

## 1.4.0

Released 2023-Feb-24
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Api\Internal\ExceptionExtensions.cs" Link="Includes\ExceptionExtensions.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Api\Internal\SemanticConventions.cs" Link="Includes\SemanticConventions.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Api\Internal\SpanAttributeConstants.cs" Link="Includes\SpanAttributeConstants.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Api\Internal\ActivityHelperExtensions.cs" Link="Includes\ActivityHelperExtensions.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Api\Internal\StatusHelper.cs" Link="Includes\StatusHelper.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Api\Internal\Guard.cs" Link="Includes\Guard.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Internal\EnvironmentVariables\*.cs" Link="Includes\EnvironmentVariables\%(Filename).cs" />
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Exporter.Prometheus.AspNetCore/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.5.0-alpha.1

Released 2023-Mar-07

## 1.4.0-rc.4

Released 2023-Feb-10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.5.0-alpha.1

Released 2023-Mar-07

## 1.4.0-rc.4

Released 2023-Feb-10
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.5.0-alpha.1

Released 2023-Mar-07

## 1.4.0

Released 2023-Feb-24
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Extensions.Hosting/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.5.0-alpha.1

Released 2023-Mar-07

## 1.4.0

Released 2023-Feb-24
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Extensions.Propagators/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 1.5.0-alpha.1

Released 2023-Mar-07

## 1.4.0

Released 2023-Feb-24
Expand Down
8 changes: 6 additions & 2 deletions src/OpenTelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

## Unreleased

* Added Exemplar support.
([#4217](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4217))
## 1.5.0-alpha.1

Released 2023-Mar-07

* Added Exemplar support. See [exemplars](../../docs/metrics/customizing-the-sdk/README.md#exemplars)
for instructions to enable exemplars.

* Added `AddDetector` factory overload on `ResourceBuilder`.
([#4261](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4261))
Expand Down
4 changes: 2 additions & 2 deletions src/OpenTelemetry/Metrics/AggregatorStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ private void UpdateLongCustomTags(long value, ReadOnlySpan<KeyValuePair<string,
if (this.IsExemplarEnabled())
{
var shouldSample = this.exemplarFilter.ShouldSample(value, tags);
this.metricPoints[index].UpdateWithExemplar(value, tags: default, shouldSample);
this.metricPoints[index].UpdateWithExemplar(value, tags: tags, shouldSample);
}
else
{
Expand Down Expand Up @@ -438,7 +438,7 @@ private void UpdateDoubleCustomTags(double value, ReadOnlySpan<KeyValuePair<stri
if (this.IsExemplarEnabled())
{
var shouldSample = this.exemplarFilter.ShouldSample(value, tags);
this.metricPoints[index].UpdateWithExemplar(value, tags: default, shouldSample);
this.metricPoints[index].UpdateWithExemplar(value, tags: tags, shouldSample);
}
else
{
Expand Down
25 changes: 25 additions & 0 deletions src/OpenTelemetry/Metrics/Base2ExponentialBucketHistogram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ internal sealed class Base2ExponentialBucketHistogram

internal int IsCriticalSectionOccupied = 0;

internal int SnapshotScale;
internal long SnapshotZeroCount;
internal CircularBufferBuckets SnapshotPositiveBuckets;
internal CircularBufferBuckets SnapshotNegativeBuckets;

private int scale;
private double scalingFactor; // 2 ^ scale / log(2)

Expand Down Expand Up @@ -130,6 +135,9 @@ internal int Scale

internal CircularBufferBuckets NegativeBuckets { get; }

internal ExponentialBucketSnapshot ExponentialBucketSnapshot =>
new ExponentialBucketSnapshot(this.SnapshotScale, this.SnapshotZeroCount, this.SnapshotPositiveBuckets, this.SnapshotNegativeBuckets);

/// <summary>
/// Maps a finite positive IEEE 754 double-precision floating-point
/// number to <c>Bucket[index] = ( base ^ index, base ^ (index + 1) ]</c>,
Expand Down Expand Up @@ -211,4 +219,21 @@ public void Record(double value)
n = buckets.TryIncrement(index >> n);
Debug.Assert(n == 0, "Increment should always succeed after scale down.");
}

internal void Reset()
{
// TODO: Determine if this is sufficient for delta temporality.
// I'm not sure we should be resetting the scale.
this.ZeroCount = 0;
this.PositiveBuckets.Reset();
this.NegativeBuckets.Reset();
}

internal void Snapshot()
{
this.SnapshotScale = this.Scale;
this.SnapshotZeroCount = this.ZeroCount;
this.SnapshotPositiveBuckets = this.PositiveBuckets.Copy();
this.SnapshotNegativeBuckets = this.NegativeBuckets.Copy();
}
}
31 changes: 31 additions & 0 deletions src/OpenTelemetry/Metrics/CircularBufferBuckets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,37 @@ static void Move(long[] array, uint src, uint dst)
}
}

internal void Reset()
{
if (this.trait != null)
{
for (var i = 0; i < this.trait.Length; ++i)
{
this.trait[i] = 0;
}
}
}

internal CircularBufferBuckets Copy()
{
// TODO: Consider avoiding allocating a new one every time.
// Maybe we can have two instances that we swap between snapshots.
var copy = new CircularBufferBuckets(this.Capacity);
copy.begin = this.begin;
copy.end = this.end;

if (this.trait != null)
{
copy.trait = new long[this.trait.Length];
for (var i = 0; i < copy.trait.Length; ++i)
{
copy.trait[i] = this.trait[i];
}
}

return copy;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private int ModuloIndex(int value)
{
Expand Down
42 changes: 42 additions & 0 deletions src/OpenTelemetry/Metrics/ExponentialBucketSnapshot.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// <copyright file="ExponentialBucketSnapshot.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;

internal class ExponentialBucketSnapshot
{
internal ExponentialBucketSnapshot(int scale, long snapshotZeroCount, CircularBufferBuckets positiveBuckets, CircularBufferBuckets negativeBuckets)
{
this.Scale = scale;
this.ZeroCount = snapshotZeroCount;
this.PositiveOffset = positiveBuckets.Offset;
this.NegativeOffset = negativeBuckets.Offset;
this.PositiveBuckets = new(positiveBuckets);
this.NegativeBuckets = new(negativeBuckets);
}

public int Scale { get; }

public long ZeroCount { get; }

public int PositiveOffset { get; }

public int NegativeOffset { get; }

public ExponentialBuckets PositiveBuckets { get; }

public ExponentialBuckets NegativeBuckets { get; }
}
Loading

0 comments on commit 00ec5b7

Please sign in to comment.