pinqloq 2.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package pinqloq --version 2.0.2
                    
NuGet\Install-Package pinqloq -Version 2.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="pinqloq" Version="2.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="pinqloq" Version="2.0.2" />
                    
Directory.Packages.props
<PackageReference Include="pinqloq" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add pinqloq --version 2.0.2
                    
#r "nuget: pinqloq, 2.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package pinqloq@2.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=pinqloq&version=2.0.2
                    
Install as a Cake Addin
#tool nuget:?package=pinqloq&version=2.0.2
                    
Install as a Cake Tool

Pinqloq

Lightweight .NET SDK that buffers logs in-memory and ships them in batches to the Pinqloq ingest endpoint. No message broker, no token refresh — just an HTTPS endpoint and a secret key.

Installation

dotnet add package pinqloq

Quick Start

// Program.cs
builder.Services.AddPinqloq(options =>
{
    options.SecretKey             = "your-secret-key";
    options.ApiLogsCollectionName = "myapp_api_logs"; // required for UsePinqloqRequestLogging
});

app.UsePinqloqRequestLogging(); // auto-captures every HTTP request

Manual logging

Inject IPinqloqLogger wherever you need to emit logs. Event is required on every entry (see below):

public class OrderService(IPinqloqLogger logger)
{
    public async Task CreateOrder(Order order)
    {
        // Fire-and-forget (buffered, batched -> /bulk)
        logger.Enqueue(new PinqloqLogEntry
        {
            Event         = "order.created",      // required — shown as the title in the UI
            LogLevel      = PinqloqLogLevel.Information,
            LogSourceType = PinqloqLogSourceType.Api,
            Metadata      = new() { ["orderId"] = order.Id.ToString() }
        });

        // Immediate + awaitable (-> /client-logs); returns a result, never throws for a rejected log
        PinqloqSendResult result = await logger.SendAsync(new PinqloqLogEntry
        {
            Event         = "order.payment_failed", // required
            LogLevel      = PinqloqLogLevel.Error,
            LogSourceType = PinqloqLogSourceType.Api,
            Metadata      = new() { ["orderId"] = order.Id.ToString(), ["stage"] = "payment" }
        });

        if (!result.Success)
            _logger.LogWarning("Pinqloq rejected the log: {Reason}", result.Error!.Reason);
    }
}

Batch enqueue

If you already hold a collection of entries, hand them over in one call. Each is buffered and batched individually:

int queued = logger.Enqueue(entries); // returns how many were accepted into the buffer

Per-call callbacks

Both Enqueue and SendAsync accept optional onSent / onFailed callbacks. Because the buffered path sends in the background, these fire after Enqueue returns. onFailed receives a PinqloqLogError describing what went wrong. Callbacks that throw are swallowed and logged — the logging pipeline never crashes your app.

logger.Enqueue(
    entry,
    onSent:   e  => Console.WriteLine($"delivered: {e.Event}"),
    onFailed: (e, err) => Console.WriteLine($"dropped {e.Event}: {err.Reason} — {err.Message}"));

Error handling

Failures surface through PinqloqLogError — via the onFailed callback on any method, and via PinqloqSendResult.Error from SendAsync. It carries:

Member Description
Reason A PinqloqLogFailureReason category (see below)
StatusCode The HTTP status code when the failure came from the server; null for non-HTTP failures
Message Human-readable message (always populated)
Exception The underlying exception when one exists (stack trace preserved); otherwise null

PinqloqLogFailureReason values:

Reason Meaning
Unauthorized HTTP 401 — secret key invalid or missing
Forbidden HTTP 403 — secret key not authorized for the collection
MissingCollection Neither entry.CollectionName nor ApiLogsCollectionName was set
QueueFull In-memory queue was full, so the log was dropped (only on the Enqueue path)
HttpError Some other non-2xx HTTP response
Timeout The request timed out
Network Network error or unexpected exception
Unknown Unclassified failure

The Event field (required)

Every log must carry a non-empty Event. It is the human-readable title of the log and is what the Log Panel UI shows as the row title.

  • The server injects it into the stored metadata as metadata["event"] before persisting (an explicit Event overrides any "event" you also put in Metadata).
  • If Event is empty/whitespace the log is rejected: SendAsync returns a result with Success == false (server 400), and in a batch (/bulk) that single entry is silently skipped.
  • UsePinqloqRequestLogging() sets it automatically to "{method} {path}" (e.g. GET /api/orders/42), so you never set it for auto-captured HTTP logs.

Timestamps (Date)

PinqloqLogEntry.Date is optional:

  • Leave it unset and the SDK stamps it at enqueue time (DateTimeOffset.UtcNow). This is important for buffered logs: a log keeps the time it actually happened, not the time the batch was later flushed.
  • Set it explicitly to backfill or forward a known event time. The server uses it as-is; only if it is omitted does the server fall back to its receive time.

How it works

  • UsePinqloqRequestLogging() captures every incoming HTTP request and calls Enqueue internally. It throws at startup if ApiLogsCollectionName is not set. It auto-fills Event ("{method} {path}") and the timestamp, so no per-request setup is needed.
  • Every log must have a non-empty Event; entries without one are rejected (single) or skipped (batch). See The Event field.
  • A log's target is entry.CollectionName if set, otherwise ApiLogsCollectionName. If neither is set the log is dropped client-side (never sent to a default collection).
  • A background dispatcher drains the in-memory channel every 200 logs or 2 seconds (whichever comes first) and POSTs to /api/client-logs/bulk.
  • Every request is authenticated via the X-Secret-Key header — no JWT, no token refresh.
  • On graceful shutdown, remaining buffered logs are flushed before the process exits.

Public API

Member Purpose
AddPinqloq(options => …) Registers the SDK (buffer, dispatcher, HTTP client) in DI
UsePinqloqRequestLogging() Middleware that auto-captures every HTTP request
IPinqloqLogger.Enqueue(entry, onSent?, onFailed?) Buffered, fire-and-forget logging (batched → /bulk). Returns bool — false if the queue was full
IPinqloqLogger.Enqueue(entries, onSent?, onFailed?) Buffered batch enqueue. Returns the count accepted into the buffer
IPinqloqLogger.SendAsync(entry, onSent?, onFailed?, ct?) Immediate, awaitable logging (→ /client-logs). Returns PinqloqSendResult

All logging methods accept optional onSent / onFailed callbacks; onFailed receives a PinqloqLogError. See Per-call callbacks.

Options

Property Default Description
SecretKey (required) API secret key
ApiLogsCollectionName null Target collection for UsePinqloqRequestLogging (required) and fallback for entries without a CollectionName. If neither is set, the log is dropped.
BulkPath api/client-logs/bulk Path of the batched ingest endpoint
SinglePath api/client-logs Path of the single (immediate) ingest endpoint
BatchSize 200 Max logs per HTTP request
FlushInterval 00:00:02 Max wait before flushing
QueueCapacity 10000 In-memory channel capacity
HttpTimeout 00:00:10 HTTP request timeout
AppVersionName null Optional app version tag written by UsePinqloqRequestLogging. Only used for auto-captured HTTP logs; safe to leave unset.

License

MIT

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net9.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on pinqloq:

Package Downloads
Pinqponq.Observability

Pinqloq logging for ASP.NET Core: one structured record per request (redacted request/response bodies, route-based event names, error detail from Pinqponq.ErrorHandling), and an ILogService for application and job logs with stack trace trimming.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.3.2 403 9/14/2026
4.3.1 132 9/9/2026
4.3.0 1,838 9/8/2026
4.2.0 559 9/1/2026
4.1.0 234 8/25/2026
4.0.3 266 8/6/2026
4.0.2 352 7/22/2026
4.0.1 138 7/21/2026
4.0.0 133 7/20/2026
3.0.0 140 7/14/2026
2.0.8 168 7/14/2026
2.0.7 291 7/6/2026
2.0.6 126 7/6/2026
2.0.5 197 7/6/2026
2.0.4 138 7/6/2026
2.0.3 188 7/2/2026
2.0.2 137 7/2/2026
2.0.1 148 7/1/2026
2.0.0 222 6/23/2026
1.0.2 142 6/19/2026
Loading failed