#ifndef VGI_RPC_TELEMETRY_H#define VGI_RPC_TELEMETRY_H#include<stddef.h>#include<stdint.h>#include"nanoarrow/nanoarrow.h"#ifdef __cplusplusextern"C"{#endifstructVgiTelemetry;structVgiTraceContext{chartraceparent[56],tracestate[513];};structVgiTelemetryOptions{constchar*endpoint;/* OTLP/HTTP base URL; /v1/traces and /v1/metrics appended. */constchar*service_name;constchar*tls_ca_file;unsignedtimeout_ms;size_tmax_queue;intenable_tracing,enable_metrics;/* Optional host exporter: receives OTLP/JSON on the export thread. * Return zero on success. Payload borrowed for the callback only. * Callback state must outlive the telemetry instance. */int(*export_json)(void*,constchar*signal,constchar*json,size_tlength);void*export_state;};structVgiTelemetryStats{uint64_trecorded,dropped,export_failures;size_tqueued;};voidVgiTelemetryOptionsInit(structVgiTelemetryOptions*);intVgiTelemetryNew(conststructVgiTelemetryOptions*,structVgiTelemetry**,structArrowError*);/* Shared by clients and servers; configure before serving. Must outlive them. * Export failures never change RPC results; inspect stats/Flush for delivery. */intVgiTelemetryFlush(structVgiTelemetry*,unsignedtimeout_ms);voidVgiTelemetryGetStats(structVgiTelemetry*,structVgiTelemetryStats*);voidVgiTelemetryFree(structVgiTelemetry*);/* W3C context for integrating an application's existing tracer. Swap is thread- * local; restore the returned previous context after a synchronous scope. */intVgiTraceContextParse(constchar*traceparent,constchar*tracestate,structVgiTraceContext*);voidVgiTraceContextSwap(conststructVgiTraceContext*,structVgiTraceContext*previous);voidVgiTraceContextCurrent(structVgiTraceContext*);#ifdef __cplusplus}#endif#endif