OpenSpanner 0.1.13
dotnet add package OpenSpanner --version 0.1.13
NuGet\Install-Package OpenSpanner -Version 0.1.13
<PackageReference Include="OpenSpanner" Version="0.1.13" />
<PackageVersion Include="OpenSpanner" Version="0.1.13" />
<PackageReference Include="OpenSpanner" />
paket add OpenSpanner --version 0.1.13
#r "nuget: OpenSpanner, 0.1.13"
#:package OpenSpanner@0.1.13
#addin nuget:?package=OpenSpanner&version=0.1.13
#tool nuget:?package=OpenSpanner&version=0.1.13
Open Spanner C# SDK
Generated C# client for the Open Spanner API.
gRPC streaming
Use the stream client from trusted backend code when you want to send usage through the gRPC ingestion service:
using OpenSpanner.Streaming;
var client = new StreamClient(
"http://localhost:18090",
"osp_live_...",
retryPolicy: new RetryPolicy
{
MaxAttempts = 3,
OnRetry = retry => Console.WriteLine($"retry {retry.Attempt} after {retry.Delay}"),
});
var result = await client.TrackBulkAsync(
idempotencyKey: Guid.NewGuid().ToString(),
events:
[
new Event
{
IdempotencyKey = Guid.NewGuid().ToString(),
Subject = "org_123",
Meter = "api_requests",
Quantity = 1,
Timestamp = DateTimeOffset.UtcNow,
Metadata = new Dictionary<string, object?>
{
["endpoint"] = "/checkout",
["status"] = 200,
},
},
]);
Console.WriteLine($"accepted={result.AcceptedCount} failed={result.FailedCount}");
Retries are opt-in and apply to unary TrackAsync and TrackBulkAsync calls. They honor google.rpc.RetryInfo and retry only overload, temporary unavailability, and deadline failures. Client streams are not replayed automatically; retry an uncertain stream through TrackBulkAsync with the original event idempotency keys.
REST client
Record usage for a meter that already exists:
using Microsoft.Kiota.Abstractions.Authentication;
using Microsoft.Kiota.Http.HttpClientLibrary;
using OpenSpanner;
using OpenSpanner.Models;
using OpenSpanner.Retrying;
var apiKey = "...";
var authProvider = new BaseBearerTokenAuthenticationProvider(new ApiKeyProvider(apiKey));
var adapter = new HttpClientRequestAdapter(authProvider)
{
BaseUrl = "https://api.example.com",
};
var client = new OpenSpannerClient(adapter);
var request = new UsageCreateRequest
{
IdempotencyKey = Guid.NewGuid().ToString(),
Subject = "org_123",
Meter = "api_requests",
Quantity = 1,
Timestamp = DateTimeOffset.UtcNow.ToString("O"),
};
var usage = await UsageRetry.ExecuteAsync(
cancellationToken => client.V1.Usages.PostAsync(request, cancellationToken: cancellationToken));
Console.WriteLine(usage?.Id);
sealed class ApiKeyProvider(string apiKey) : IAccessTokenProvider
{
public AllowedHostsValidator AllowedHostsValidator { get; } = new();
public Task<string> GetAuthorizationTokenAsync(
Uri uri,
Dictionary<string, object>? additionalAuthenticationContext = null,
CancellationToken cancellationToken = default)
{
return Task.FromResult(apiKey);
}
}
UsageRetry.ExecuteAsync retries transport failures, 429, and temporary 5xx responses, and honors Retry-After.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Google.Api.CommonProtos (>= 2.17.0)
- Google.Protobuf (>= 3.33.1)
- Grpc.Net.Client (>= 2.71.0)
- Microsoft.Kiota.Bundle (>= 2.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.13 | 119 | 7/20/2026 |
| 0.1.12 | 119 | 6/22/2026 |
| 0.1.11 | 120 | 6/21/2026 |
| 0.1.10 | 116 | 6/21/2026 |
| 0.1.9 | 119 | 6/19/2026 |
| 0.1.8 | 115 | 6/19/2026 |
| 0.1.7 | 149 | 6/19/2026 |
| 0.1.6 | 1,034 | 6/18/2026 |
| 0.1.5 | 225 | 6/17/2026 |
| 0.1.4 | 121 | 6/16/2026 |
| 0.1.3 | 123 | 6/15/2026 |
| 0.1.2 | 113 | 6/10/2026 |
| 0.1.1 | 109 | 6/9/2026 |
| 0.1.0 | 109 | 6/9/2026 |