Skip to content

Commit

Permalink
[sdk] Expose the ctor on Batch<T> which accepts a single item (#5642)
Browse files Browse the repository at this point in the history
Co-authored-by: Cijo Thomas <cijo.thomas@gmail.com>
  • Loading branch information
CodeBlanch and cijothomas authored Nov 1, 2024
1 parent ed1b27f commit 7c0f24c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
OpenTelemetry.Batch<T>.Batch(T! item) -> void
OpenTelemetry.Metrics.MetricStreamConfiguration.CardinalityLimit.get -> int?
OpenTelemetry.Metrics.MetricStreamConfiguration.CardinalityLimit.set -> void
OpenTelemetry.OpenTelemetrySdk
Expand Down
8 changes: 6 additions & 2 deletions src/OpenTelemetry/Batch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@ public Batch(T[] items, int count)
this.Count = this.targetCount = count;
}

internal Batch(T item)
/// <summary>
/// Initializes a new instance of the <see cref="Batch{T}"/> struct.
/// </summary>
/// <param name="item">The item to store in the batch.</param>
public Batch(T item)
{
Debug.Assert(item != null, $"{nameof(item)} was null.");
Guard.ThrowIfNull(item);

this.item = item;
this.Count = this.targetCount = 1;
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ Notes](../../RELEASENOTES.md).
There is NO ability to revert to old behavior.
([#5909](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5909))

* Exposed a `public` constructor on `Batch<T>` which accepts a single instance
of `T` to be contained in the batch.
([#5642](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5642))

## 1.10.0-beta.1

Released 2024-Sep-30
Expand Down
2 changes: 2 additions & 0 deletions test/OpenTelemetry.Tests/Trace/BatchTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public void CheckConstructorExceptions()
Assert.Throws<ArgumentNullException>(() => new Batch<string>((string[]?)null!, 0));
Assert.Throws<ArgumentOutOfRangeException>(() => new Batch<string>(Array.Empty<string>(), -1));
Assert.Throws<ArgumentOutOfRangeException>(() => new Batch<string>(Array.Empty<string>(), 1));

Assert.Throws<ArgumentNullException>(() => new Batch<string>(null!));
}

[Fact]
Expand Down

0 comments on commit 7c0f24c

Please sign in to comment.