Skip to content

Commit

Permalink
Expose the ctor on Batch<T> which accepts a single item.
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeBlanch committed May 21, 2024
1 parent 6c0327c commit d2a82cc
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.Exemplar
OpenTelemetry.Metrics.Exemplar.DoubleValue.get -> double
OpenTelemetry.Metrics.Exemplar.Exemplar() -> void
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 @@ -2,6 +2,10 @@

## Unreleased

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

## 1.9.0-alpha.1

Released 2024-May-20
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 d2a82cc

Please sign in to comment.