ascii-chat
Binary v0.16.114-28-gf5913657f
Library lib/v0.3.2-3302-gf5913657f
Video chat in your terminal
Loading...
Searching...
No Matches
otel.h
Go to the documentation of this file.
1#pragma once
4#include <stdarg.h>
5#include <stdbool.h>
6typedef enum {
7#define ASCII_OTEL_OPERATION(id, name, realtime) ASCII_OTEL_##id,
8#include <ascii-chat/otel_operations.def>
9#undef ASCII_OTEL_OPERATION
12typedef enum {
13#define ASCII_OTEL_METRIC(id, name, type, unit) ASCII_OTEL_METRIC_##id,
14#include <ascii-chat/otel_metrics.def>
15#undef ASCII_OTEL_METRIC
18#ifndef __EMSCRIPTEN__
19#include <gotel/gotel.h>
20#include <gotel/sqlite.h>
21#include <sqlite3.h>
22#ifdef __cplusplus
23extern "C" {
24#endif
36asciichat_error_t ascii_otel_init(const char *mode, int argc, char **argv);
37void ascii_otel_shutdown(void);
41bool ascii_otel_enabled(void);
42const char *ascii_otel_current_operation(void);
43void ascii_otel_metric(ascii_otel_metric_t metric, double value);
46 unsigned id);
47void ascii_otel_ui_usage(const char *screen, const char *event,
48 uint64_t duration_ns);
49void ascii_otel_call_session_used(const char *session_string);
51 size_t payload_size, const char *action, int transport);
52void ascii_otel_exit(int code);
53void ascii_otel_frame_rejected(const char *validator, const char *reason,
54 size_t bytes, uint32_t width, uint32_t height,
56gotel_context_t ascii_otel_context(void);
57void ascii_otel_scope_int(ascii_otel_scope_t *scope, const char *key,
58 int64_t value);
60 const char *value);
62 ascii_otel_operation_t operation,
63 const gotel_context_t *parent);
65 ascii_otel_operation_t operation);
67void ascii_otel_log(int level, const char *file, int line, const char *function,
68 const char *format, va_list args);
69void ascii_otel_error(const char *message);
70void ascii_otel_error_code(asciichat_error_t code, const char *message);
72 const char *origin);
73double ascii_otel_pipeline_age(uint64_t now, uint64_t capture,
74 uint64_t progress, bool expected);
75// Stages: capture=0 (expected bits: display=1, encode=2), display=1, encode=2,
76// stop=3.
77void ascii_otel_pipeline_progress(unsigned stage, unsigned expected);
78void ascii_otel_http(ascii_otel_scope_t *scope, const char *hostname,
79 const char *path);
81void ascii_otel_sqlite(sqlite3 *db, const gotel_query_t *queries, size_t count);
84void ascii_otel_sqlite_catalog(sqlite3 *db,
85 const gotel_query_catalog_t *catalog);
86
89int ascii_otel_sqlite_prepare(sqlite3 *db, const char *sql,
90 sqlite3_stmt **statement);
91
92#define ASCII_OTEL_ATTR_STRING(key, value) \
93 ascii_otel_scope_string(&otel_scope, key, value)
94#define ASCII_OTEL_ATTR_INT(key, value) \
95 ascii_otel_scope_int(&otel_scope, key, value)
96#define ASCII_OTEL_PACKET(type, size, action, transport) \
97 ascii_otel_packet(&otel_scope, type, size, action, transport)
98#define ASCII_OTEL_SCOPE_PARENT(id, parent) \
99 ascii_otel_scope_t otel_scope \
100 __attribute__((cleanup(ascii_otel_scope_end))) = {0}; \
101 ascii_otel_scope_parent(&otel_scope, ASCII_OTEL_##id, parent)
102#define ASCII_OTEL_SCOPE(id) \
103 ascii_otel_scope_t otel_scope \
104 __attribute__((cleanup(ascii_otel_scope_end))) = {0}; \
105 ascii_otel_scope_begin(&otel_scope, ASCII_OTEL_##id)
106#define ASCII_OTEL_SCOPE_AS(variable, id) \
107 ascii_otel_scope_t variable \
108 __attribute__((cleanup(ascii_otel_scope_end))) = {0}; \
109 ascii_otel_scope_begin(&variable, ASCII_OTEL_##id)
110#else
111#define ASCII_OTEL_ATTR_STRING(key, value) ((void)(key), (void)(value))
112#define ASCII_OTEL_ATTR_INT(key, value) ((void)(key), (void)(value))
113#define ASCII_OTEL_PACKET(type, size, action, transport) ((void)0)
114#define ascii_otel_frame_rejected(validator, reason, bytes, width, height, \
115 code) \
116 ((void)(validator), (void)(reason), (void)(bytes), (void)(width), \
117 (void)(height), (void)(code))
118#define ascii_otel_pipeline_progress(stage, expected) \
119 ((void)(stage), (void)(expected))
120#define ascii_otel_ui_usage(screen, event, duration_ns) \
121 ((void)(screen), (void)(event), (void)(duration_ns))
122#define ascii_otel_sqlite_prepare(db, sql, statement) \
123 sqlite3_prepare_v2(db, sql, -1, statement, NULL)
124#define ascii_otel_enabled() false
125#define ascii_otel_current_operation() ""
126#define ascii_otel_call_session_used(session_string) ((void)(session_string))
127#define ascii_otel_metric(metric, value) ((void)(metric), (void)(value))
128#define ascii_otel_stats_attach(scope) ((void)(scope))
129#define ASCII_OTEL_SCOPE_PARENT(id, parent) ((void)0)
130#define ASCII_OTEL_SCOPE(id) ((void)0)
131#define ASCII_OTEL_SCOPE_AS(variable, id) ((void)0)
132#endif
133
134#ifdef __cplusplus
135}
136#endif
137
138// Test executables may link the ordinary library; never initialize its
139// exporter.
140#if !defined(ASCIICHAT_OTEL_IMPLEMENTATION) && defined(TESTING)
141#define ascii_otel_init(mode, argc, argv) \
142 ((void)(mode), (void)(argc), (void)(argv), ASCIICHAT_OK)
143#endif
Synchronized per-thread pending error stacks and value snapshots. SET_ERRNO pushes,...
unsigned int height
Definition fft.c:24
unsigned int width
Definition fft.c:24
unsigned short uint16_t
unsigned int uint32_t
unsigned long long uint64_t
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:48
struct stats_scope stats_scope_t
action_args_t args
deferred_action_t action
void ascii_otel_error_code(asciichat_error_t code, const char *message)
Definition otel.c:932
void ascii_otel_http_status(ascii_otel_scope_t *scope, int status)
Definition otel.c:993
void ascii_otel_http(ascii_otel_scope_t *scope, const char *hostname, const char *path)
Definition otel.c:974
bool ascii_otel_enabled(void)
Definition otel.c:171
void ascii_otel_scope_int(ascii_otel_scope_t *scope, const char *key, int64_t value)
Definition otel.c:871
ascii_otel_operation_t
Definition otel.h:6
@ ASCII_OTEL_OPERATION_COUNT
Definition otel.h:10
void ascii_otel_shutdown(void)
Definition otel.c:548
int ascii_otel_sqlite_prepare(sqlite3 *db, const char *sql, sqlite3_stmt **statement)
Definition otel.c:1007
void ascii_otel_log(int level, const char *file, int line, const char *function, const char *format, va_list args)
Definition otel.c:844
gotel_context_t ascii_otel_context(void)
Definition otel.c:870
void ascii_otel_ui_usage(const char *screen, const char *event, uint64_t duration_ns)
Definition otel.c:506
void ascii_otel_exit(int code)
Definition otel.c:881
void ascii_otel_pipeline_progress(unsigned stage, unsigned expected)
Definition otel.c:298
void ascii_otel_stats_attach(stats_scope_t *scope)
Definition otel.c:237
ascii_otel_operation_t ascii_otel_failure_operation(asciichat_error_t code, const char *origin)
Definition otel.c:914
void ascii_otel_scope_end(ascii_otel_scope_t *scope)
Definition otel.c:497
void ascii_otel_scope_string(ascii_otel_scope_t *scope, const char *key, const char *value)
Definition otel.c:876
const char * ascii_otel_current_operation(void)
Definition otel.c:165
void ascii_otel_scope_parent(ascii_otel_scope_t *scope, ascii_otel_operation_t operation, const gotel_context_t *parent)
Definition otel.c:448
double ascii_otel_pipeline_age(uint64_t now, uint64_t capture, uint64_t progress, bool expected)
Definition otel.c:324
void ascii_otel_sqlite_catalog(sqlite3 *db, const gotel_query_catalog_t *catalog)
Definition otel.c:1028
ascii_otel_metric_t ascii_otel_stats_metric(stats_record_kind_t kind, unsigned id)
Definition otel.c:197
void ascii_otel_request_shutdown(void)
Definition otel.c:172
void ascii_otel_sqlite(sqlite3 *db, const gotel_query_t *queries, size_t count)
Definition otel.c:1012
void ascii_otel_error(const char *message)
Definition otel.c:965
struct ascii_otel_scope ascii_otel_scope_t
ascii otel scope is intentionally a small, concrete record. Fields such as scope, retained,...
ascii_otel_metric_t
Definition otel.h:12
@ ASCII_OTEL_METRIC_COUNT
Definition otel.h:16
void ascii_otel_packet(ascii_otel_scope_t *scope, uint16_t type, size_t payload_size, const char *action, int transport)
Definition otel.c:524
void ascii_otel_metric(ascii_otel_metric_t metric, double value)
Definition otel.c:175
void ascii_otel_call_session_used(const char *session_string)
Definition otel.c:516
void ascii_otel_frame_rejected(const char *validator, const char *reason, size_t bytes, uint32_t width, uint32_t height, asciichat_error_t code)
Definition otel.c:893
void ascii_otel_scope_begin(ascii_otel_scope_t *scope, ascii_otel_operation_t operation)
Definition otel.c:445
asciichat_error_t ascii_otel_init(const char *mode, int argc, char **argv)
Definition otel.c:648
ascii otel scope is intentionally a small, concrete record. Fields such as scope, retained,...
Definition otel.h:31
gotel_scope_t scope
Definition otel.h:32
bool retained
Definition otel.h:33
struct ascii_otel_scope * previous
Definition otel.h:34