|
pmetrics 0.1
PostgreSQL metrics instrumentation extension
|
#include "postgres.h"#include "pmetrics.h"#include "common/hashfn.h"#include "fmgr.h"#include "funcapi.h"#include "lib/dshash.h"#include "miscadmin.h"#include "storage/ipc.h"#include "storage/lwlock.h"#include "storage/shmem.h"#include "utils/builtins.h"#include "utils/dsa.h"#include "utils/guc.h"#include "utils/hsearch.h"#include "utils/jsonb.h"#include "math.h"#include <stdio.h>
Go to the source code of this file.
Data Structures | |
| struct | PMetricsSharedState |
| struct | MetricKey |
| struct | Metric |
Macros | |
| #define | LWTRANCHE_PMETRICS_DSA 43001 |
| #define | LWTRANCHE_PMETRICS 43002 |
| #define | DEFAULT_ENABLED true |
| #define | DEFAULT_BUCKET_VARIABILITY 0.1 |
| #define | DEFAULT_BUCKETS_UPPER_BOUND 30000 |
Typedefs | |
| typedef enum MetricType | MetricType |
| typedef struct PMetricsSharedState | PMetricsSharedState |
| typedef enum LabelsLocation | LabelsLocation |
Enumerations | |
| enum | MetricType { METRIC_TYPE_COUNTER = 0 , METRIC_TYPE_GAUGE = 1 , METRIC_TYPE_HISTOGRAM = 2 , METRIC_TYPE_HISTOGRAM_SUM = 3 } |
| enum | LabelsLocation { LABELS_NONE = 0 , LABELS_LOCAL = 1 , LABELS_DSA = 2 } |
Functions | |
| void | _PG_init (void) |
| static void | metrics_shmem_request (void) |
| static void | metrics_shmem_startup (void) |
| static dshash_table * | get_metrics_table (void) |
| static void | cleanup_metrics_backend (int code, Datum arg) |
| static void | validate_inputs (const char *name) |
| static void | init_metric_key (MetricKey *key, const char *name, Jsonb *labels_jsonb, MetricType type, int bucket) |
| static int | bucket_for (double value) |
| static int64 | increment_by (const char *name_str, Jsonb *labels_jsonb, MetricType type, int bucket, int64 amount) |
| static int64 | delete_metrics_by_name_labels (const char *name_str, Jsonb *labels_jsonb) |
| static void | extract_metric_args (FunctionCallInfo fcinfo, int name_arg, int labels_arg, char **name_out, Jsonb **labels_out) |
| static Jsonb * | get_labels_jsonb (const MetricKey *key, dsa_area *dsa) |
| static uint32 | metric_hash_dshash (const void *key, size_t key_size, void *arg) |
| static int | metric_compare_dshash (const void *a, const void *b, size_t key_size, void *arg) |
| static void | metric_key_copy (void *dst, const void *src, size_t key_size, void *arg) |
| PG_FUNCTION_INFO_V1 (increment_counter) | |
| Datum | increment_counter (PG_FUNCTION_ARGS) |
| PG_FUNCTION_INFO_V1 (increment_counter_by) | |
| Datum | increment_counter_by (PG_FUNCTION_ARGS) |
| PG_FUNCTION_INFO_V1 (set_gauge) | |
| Datum | set_gauge (PG_FUNCTION_ARGS) |
| PG_FUNCTION_INFO_V1 (add_to_gauge) | |
| Datum | add_to_gauge (PG_FUNCTION_ARGS) |
| PG_FUNCTION_INFO_V1 (list_metrics) | |
| Datum | list_metrics (PG_FUNCTION_ARGS) |
| __attribute__ ((visibility("default"))) | |
| PG_FUNCTION_INFO_V1 (record_to_histogram) | |
| Datum | record_to_histogram (PG_FUNCTION_ARGS) |
| PG_FUNCTION_INFO_V1 (list_histogram_buckets) | |
| Datum | list_histogram_buckets (PG_FUNCTION_ARGS) |
| PG_FUNCTION_INFO_V1 (clear_metrics) | |
| Datum | clear_metrics (PG_FUNCTION_ARGS) |
| PG_FUNCTION_INFO_V1 (delete_metric) | |
| Datum | delete_metric (PG_FUNCTION_ARGS) |
Variables | |
| PG_MODULE_MAGIC | |
| static PMetricsSharedState * | shared_state = NULL |
| static dsa_area * | local_dsa = NULL |
| static dshash_table * | local_metrics_table = NULL |
| static shmem_startup_hook_type | prev_shmem_startup_hook = NULL |
| static shmem_request_hook_type | prev_shmem_request_hook = NULL |
| static bool | pmetrics_enabled = DEFAULT_ENABLED |
| static double | bucket_variability = DEFAULT_BUCKET_VARIABILITY |
| static int | buckets_upper_bound = DEFAULT_BUCKETS_UPPER_BOUND |
| static double | gamma_val = 0 |
| static double | log_gamma = 0 |
| static const dshash_parameters | metrics_params |
| #define DEFAULT_BUCKET_VARIABILITY 0.1 |
Definition at line 52 of file pmetrics.c.
| #define DEFAULT_BUCKETS_UPPER_BOUND 30000 |
Definition at line 53 of file pmetrics.c.
| #define DEFAULT_ENABLED true |
Definition at line 51 of file pmetrics.c.
| #define LWTRANCHE_PMETRICS 43002 |
Definition at line 48 of file pmetrics.c.
| #define LWTRANCHE_PMETRICS_DSA 43001 |
Definition at line 47 of file pmetrics.c.
| typedef enum LabelsLocation LabelsLocation |
| typedef enum MetricType MetricType |
| typedef struct PMetricsSharedState PMetricsSharedState |
| enum LabelsLocation |
| Enumerator | |
|---|---|
| LABELS_NONE | |
| LABELS_LOCAL | |
| LABELS_DSA | |
Definition at line 71 of file pmetrics.c.
| enum MetricType |
| Enumerator | |
|---|---|
| METRIC_TYPE_COUNTER | |
| METRIC_TYPE_GAUGE | |
| METRIC_TYPE_HISTOGRAM | |
| METRIC_TYPE_HISTOGRAM_SUM | |
Definition at line 56 of file pmetrics.c.
| __attribute__ | ( | (visibility("default")) | ) |
Definition at line 659 of file pmetrics.c.
| void _PG_init | ( | void | ) |
Definition at line 197 of file pmetrics.c.
| Datum add_to_gauge | ( | PG_FUNCTION_ARGS | ) |
Definition at line 490 of file pmetrics.c.
|
static |
Definition at line 971 of file pmetrics.c.
|
static |
Definition at line 299 of file pmetrics.c.
| Datum clear_metrics | ( | PG_FUNCTION_ARGS | ) |
Definition at line 855 of file pmetrics.c.
| Datum delete_metric | ( | PG_FUNCTION_ARGS | ) |
Definition at line 919 of file pmetrics.c.
|
static |
Definition at line 864 of file pmetrics.c.
|
static |
Definition at line 263 of file pmetrics.c.
|
static |
Definition at line 996 of file pmetrics.c.
|
static |
Definition at line 319 of file pmetrics.c.
|
static |
Definition at line 368 of file pmetrics.c.
| Datum increment_counter | ( | PG_FUNCTION_ARGS | ) |
Definition at line 397 of file pmetrics.c.
| Datum increment_counter_by | ( | PG_FUNCTION_ARGS | ) |
Definition at line 425 of file pmetrics.c.
|
static |
Definition at line 278 of file pmetrics.c.
| Datum list_histogram_buckets | ( | PG_FUNCTION_ARGS | ) |
Definition at line 767 of file pmetrics.c.
| Datum list_metrics | ( | PG_FUNCTION_ARGS | ) |
Definition at line 525 of file pmetrics.c.
|
static |
Definition at line 1038 of file pmetrics.c.
|
static |
Definition at line 1015 of file pmetrics.c.
|
static |
Definition at line 1098 of file pmetrics.c.
|
static |
Definition at line 145 of file pmetrics.c.
|
static |
Definition at line 154 of file pmetrics.c.
| PG_FUNCTION_INFO_V1 | ( | add_to_gauge | ) |
| PG_FUNCTION_INFO_V1 | ( | clear_metrics | ) |
| PG_FUNCTION_INFO_V1 | ( | delete_metric | ) |
| PG_FUNCTION_INFO_V1 | ( | increment_counter | ) |
| PG_FUNCTION_INFO_V1 | ( | increment_counter_by | ) |
| PG_FUNCTION_INFO_V1 | ( | list_histogram_buckets | ) |
| PG_FUNCTION_INFO_V1 | ( | list_metrics | ) |
| PG_FUNCTION_INFO_V1 | ( | record_to_histogram | ) |
| PG_FUNCTION_INFO_V1 | ( | set_gauge | ) |
| Datum record_to_histogram | ( | PG_FUNCTION_ARGS | ) |
Definition at line 737 of file pmetrics.c.
| Datum set_gauge | ( | PG_FUNCTION_ARGS | ) |
Definition at line 459 of file pmetrics.c.
|
static |
Definition at line 250 of file pmetrics.c.
|
static |
Definition at line 106 of file pmetrics.c.
|
static |
Definition at line 107 of file pmetrics.c.
|
static |
Definition at line 109 of file pmetrics.c.
|
static |
Definition at line 96 of file pmetrics.c.
|
static |
Definition at line 97 of file pmetrics.c.
|
static |
Definition at line 110 of file pmetrics.c.
|
static |
Definition at line 137 of file pmetrics.c.
| PG_MODULE_MAGIC |
Definition at line 44 of file pmetrics.c.
|
static |
Definition at line 105 of file pmetrics.c.
|
static |
Definition at line 101 of file pmetrics.c.
|
static |
Definition at line 100 of file pmetrics.c.
|
static |
Definition at line 93 of file pmetrics.c.