forked from timescale/pg_influx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetric.h
53 lines (42 loc) · 1.17 KB
/
metric.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* Module to insert metrics into the database.
*
* The module will translate metrics to insert statements and execute
* them to insert the data. The module will use the prepared statement
* cache to avoid re-preparing statements multiple times.
*/
#ifndef METRIC_H_
#define METRIC_H_
#include <postgres.h>
#include <funcapi.h>
#include <nodes/pg_list.h>
typedef enum Type { TYPE_NONE, TYPE_STRING, TYPE_INTEGER, TYPE_FLOAT } Type;
typedef struct KVItem {
char *key;
char *value;
Type type;
} KVItem;
/**
* A metric.
*
* A metric consists of:
* - A name
* - A timestamp
* - A set of zero or more tags
* - A set of one or more values
*/
typedef struct Metric {
/** Measurement identifier, pointer into the line buffer */
const char *name;
/** Timestamp as a string */
const char *timestamp;
/** List of items that represent tags */
List *tags;
/** List of items that represent fields */
List *fields;
} Metric;
Oid MetricCreate(Metric *metric, Oid nspid);
void MetricInsert(Metric *metric, Oid nspid);
bool CollectValues(Metric *metric, AttInMetadata *attinmeta, Oid *argtypes,
Datum *values, bool *nulls);
#endif /* METRIC_H_ */