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

[sdk] Expose the ctor on Batch<T> which accepts a single item #5642

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
@@ -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
Loading