zupt/vendor/vuptsdk/include/zuptsdk_metrics.h
Cristian Cezar Moisés 59f9ebc59e codec: update vendored VaptVupt codec 2.65.0 -> 2.65.3
From vaptvupt-codec tag v2.65.3. Output is byte-identical to 2.65.0 (same
ratio, wire format v1.6 unchanged) but extreme-mode encode is ~1.6-2x faster
(Sprint 132 optimal-parser speedup) and the extreme prepass window allocation
is capped at wlog=20 = 8 MiB virtual instead of up to 128 MiB (Sprint 133
memory hygiene). Our AVX2 offset-read decoder guard is now UPSTREAM (dropped
from the local patch set); the ANS safe-zone 2*SAFEZONE_MAX_RUN reserve is
re-applied on top (still not upstream). make check 16/16, KAT 16/16, cross-
version roundtrip with 5.1.0 archives verified.
2026-07-12 14:47:40 -03:00

57 lines
1.7 KiB
C

/* zuptsdk observability — metrics & structured logging hooks
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#ifndef ZUPTSDK_METRICS_H
#define ZUPTSDK_METRICS_H
#include "zuptsdk.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
uint64_t encrypt_pq_count;
uint64_t decrypt_pq_count;
uint64_t encrypt_password_count;
uint64_t decrypt_password_count;
uint64_t encrypt_field_count;
uint64_t decrypt_field_count;
uint64_t encrypt_failures;
uint64_t decrypt_failures;
uint64_t mac_failures;
uint64_t commitment_failures;
uint64_t fault_detections;
uint64_t bytes_encrypted;
uint64_t bytes_decrypted;
uint64_t total_latency_ns;
} zuptsdk_metrics_t;
/** Get a snapshot of accumulated metrics (thread-safe, atomic read). */
void zuptsdk_metrics_snapshot(zuptsdk_metrics_t *out);
/** Reset all counters to zero. */
void zuptsdk_metrics_reset(void);
/** Render snapshot in Prometheus exposition format to a buffer.
* Returns bytes written, or -1 if buf too small.
* If out is NULL, returns required size. */
int zuptsdk_metrics_render_prometheus(char *buf, size_t buf_sz);
/** Structured log callback for ops. Called on each encrypt/decrypt with
* outcome and timing. Set to NULL to disable.
* @param op "encrypt_pq" / "decrypt_pq" / "encrypt_password" / etc.
* @param rc error code (0 = OK)
* @param bytes plaintext bytes processed
* @param duration_ns elapsed time
*/
typedef void (*zuptsdk_op_log_t)(const char *op, int rc, size_t bytes,
uint64_t duration_ns, void *userdata);
void zuptsdk_set_op_log(zuptsdk_op_log_t cb, void *userdata);
#ifdef __cplusplus
}
#endif
#endif