| 1 | /* |
| 2 | * hist_track.h |
| 3 | * |
| 4 | * Copyright (C) 2012-2014 Aerospike, Inc. |
| 5 | * |
| 6 | * Portions may be licensed to Aerospike, Inc. under one or more contributor |
| 7 | * license agreements. |
| 8 | * |
| 9 | * This program is free software: you can redistribute it and/or modify it under |
| 10 | * the terms of the GNU Affero General Public License as published by the Free |
| 11 | * Software Foundation, either version 3 of the License, or (at your option) any |
| 12 | * later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 16 | * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
| 17 | * details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU Affero General Public License |
| 20 | * along with this program. If not, see http://www.gnu.org/licenses/ |
| 21 | */ |
| 22 | |
| 23 | #pragma once |
| 24 | |
| 25 | |
| 26 | //========================================================== |
| 27 | // Includes |
| 28 | // |
| 29 | |
| 30 | #include <stdbool.h> |
| 31 | #include <stdint.h> |
| 32 | #include "dynbuf.h" |
| 33 | #include "hist.h" |
| 34 | |
| 35 | |
| 36 | //========================================================== |
| 37 | // Typedefs |
| 38 | // |
| 39 | |
| 40 | typedef struct cf_hist_track_s cf_hist_track; |
| 41 | |
| 42 | typedef enum { |
| 43 | CF_HIST_TRACK_FMT_PACKED, |
| 44 | CF_HIST_TRACK_FMT_TABLE |
| 45 | } cf_hist_track_info_format; |
| 46 | |
| 47 | |
| 48 | //========================================================== |
| 49 | // Public API |
| 50 | // |
| 51 | |
| 52 | //------------------------------------------------ |
| 53 | // Constructor/Destructor |
| 54 | // |
| 55 | cf_hist_track* cf_hist_track_create(const char* name, histogram_scale scale); |
| 56 | void cf_hist_track_destroy(cf_hist_track* _this); |
| 57 | |
| 58 | //------------------------------------------------ |
| 59 | // Start/Stop Caching Data |
| 60 | // |
| 61 | bool cf_hist_track_start(cf_hist_track* _this, uint32_t back_sec, |
| 62 | uint32_t slice_sec, const char* thresholds); |
| 63 | void cf_hist_track_stop(cf_hist_track* _this); |
| 64 | |
| 65 | //------------------------------------------------ |
| 66 | // Histogram API "Overrides" |
| 67 | // |
| 68 | void cf_hist_track_clear(cf_hist_track* _this); |
| 69 | void cf_hist_track_dump(cf_hist_track* _this); |
| 70 | |
| 71 | // These are just pass-throughs to histogram insertion methods: |
| 72 | uint64_t cf_hist_track_insert_data_point(cf_hist_track* _this, |
| 73 | uint64_t start_ns); |
| 74 | void cf_hist_track_insert_raw(cf_hist_track* _this, uint64_t value); |
| 75 | |
| 76 | //------------------------------------------------ |
| 77 | // Get Statistics from Cached Data |
| 78 | // |
| 79 | void cf_hist_track_get_info(cf_hist_track* _this, uint32_t back_sec, |
| 80 | uint32_t duration_sec, uint32_t slice_sec, bool throughput_only, |
| 81 | cf_hist_track_info_format info_fmt, cf_dyn_buf* db_p); |
| 82 | |
| 83 | //------------------------------------------------ |
| 84 | // Get Current Settings |
| 85 | // |
| 86 | void cf_hist_track_get_settings(cf_hist_track* _this, cf_dyn_buf* db_p); |
| 87 | |