Skip to content
This repository was archived by the owner on Nov 14, 2019. It is now read-only.

Commit bfa286b

Browse files
committed
remove expire mechanism
1 parent dad4b3b commit bfa286b

3 files changed

Lines changed: 10 additions & 33 deletions

File tree

config.default.json.example

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"server_name" : "brubeck_debug",
44
"dumpfile" : "./brubeck.dump",
55
"capacity" : 15,
6-
"expire" : 20,
76
"http" : ":8080",
87

98
"backends" : [

src/metric.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ gauge__record(struct brubeck_metric *metric, value_t value, value_t sample_freq,
4949
} else {
5050
metric->as.gauge.value = value;
5151
}
52+
metric->expire = BRUBECK_EXPIRE_ACTIVE;
5253
}
5354
pthread_spin_unlock(&metric->lock);
5455
}
@@ -61,6 +62,7 @@ gauge__sample(struct brubeck_metric *metric, brubeck_sample_cb sample, void *opa
6162
pthread_spin_lock(&metric->lock);
6263
{
6364
value = metric->as.gauge.value;
65+
metric->expire = BRUBECK_EXPIRE_DISABLED;
6466
}
6567
pthread_spin_unlock(&metric->lock);
6668

@@ -82,6 +84,7 @@ meter__record(struct brubeck_metric *metric, value_t value, value_t sample_freq,
8284
pthread_spin_lock(&metric->lock);
8385
{
8486
metric->as.meter.value += value;
87+
metric->expire = BRUBECK_EXPIRE_ACTIVE;
8588
}
8689
pthread_spin_unlock(&metric->lock);
8790
}
@@ -95,6 +98,7 @@ meter__sample(struct brubeck_metric *metric, brubeck_sample_cb sample, void *opa
9598
{
9699
value = metric->as.meter.value;
97100
metric->as.meter.value = 0.0;
101+
metric->expire = BRUBECK_EXPIRE_DISABLED;
98102
}
99103
pthread_spin_unlock(&metric->lock);
100104

@@ -124,6 +128,7 @@ counter__record(struct brubeck_metric *metric, value_t value, value_t sample_fre
124128
}
125129

126130
metric->as.counter.previous = value;
131+
metric->expire = BRUBECK_EXPIRE_ACTIVE;
127132
}
128133
pthread_spin_unlock(&metric->lock);
129134
}
@@ -137,6 +142,7 @@ counter__sample(struct brubeck_metric *metric, brubeck_sample_cb sample, void *o
137142
{
138143
value = metric->as.counter.value;
139144
metric->as.counter.value = 0.0;
145+
metric->expire = BRUBECK_EXPIRE_DISABLED;
140146
}
141147
pthread_spin_unlock(&metric->lock);
142148

@@ -155,6 +161,7 @@ histogram__record(struct brubeck_metric *metric, value_t value, value_t sample_f
155161
pthread_spin_lock(&metric->lock);
156162
{
157163
brubeck_histo_push(&metric->as.histogram, value, sample_freq);
164+
metric->expire = BRUBECK_EXPIRE_ACTIVE;
158165
}
159166
pthread_spin_unlock(&metric->lock);
160167
}
@@ -168,6 +175,7 @@ histogram__sample(struct brubeck_metric *metric, brubeck_sample_cb sample, void
168175
pthread_spin_lock(&metric->lock);
169176
{
170177
brubeck_histo_sample(&hsample, &metric->as.histogram);
178+
metric->expire = BRUBECK_EXPIRE_DISABLED;
171179
}
172180
pthread_spin_unlock(&metric->lock);
173181

@@ -187,11 +195,6 @@ histogram__sample(struct brubeck_metric *metric, brubeck_sample_cb sample, void
187195
sample(key, hsample.count / (double)backend->sample_freq, opaque);
188196
}
189197

190-
/* if there have been no metrics during this sampling period,
191-
* we don't need to report any of the histogram samples */
192-
if (hsample.count == 0.0)
193-
return;
194-
195198
WITH_SUFFIX(".min") {
196199
sample(key, hsample.min, opaque);
197200
}
@@ -333,6 +336,5 @@ brubeck_metric_find(struct brubeck_server *server, const char *key, size_t key_l
333336
brubeck_atomic_inc(&metric->flow);
334337
#endif
335338

336-
metric->expire = BRUBECK_EXPIRE_ACTIVE;
337339
return metric;
338340
}

src/server.c

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,6 @@ update_proctitle(struct brubeck_server *server)
6363
setproctitle("brubeck", buf);
6464
}
6565

66-
static void
67-
expire_metric(struct brubeck_metric *mt, void *_)
68-
{
69-
/* If this metric is not disabled, turn "inactive"
70-
* into "disabled" and "active" into "inactive"
71-
*/
72-
if (mt->expire > BRUBECK_EXPIRE_DISABLED)
73-
mt->expire = mt->expire - 1;
74-
}
75-
7666
static void
7767
dump_metric(struct brubeck_metric *mt, void *out_file)
7868
{
@@ -192,7 +182,6 @@ static void load_config(struct brubeck_server *server, const char *path)
192182
json_t *backends, *samplers;
193183

194184
/* optional */
195-
int expire = 0;
196185
char *http = NULL;
197186

198187
server->name = "brubeck";
@@ -211,8 +200,7 @@ static void load_config(struct brubeck_server *server, const char *path)
211200
"capacity", &capacity,
212201
"backends", &backends,
213202
"samplers", &samplers,
214-
"http", &http,
215-
"expire", &expire);
203+
"http", &http);
216204

217205
gh_log_set_instance(server->name);
218206

@@ -224,7 +212,6 @@ static void load_config(struct brubeck_server *server, const char *path)
224212
load_samplers(server, samplers);
225213

226214
if (http) brubeck_http_endpoint_init(server, http);
227-
if (expire) server->fd_expire = load_timerfd(expire);
228215
}
229216

230217
void brubeck_server_init(struct brubeck_server *server, const char *config)
@@ -237,7 +224,6 @@ void brubeck_server_init(struct brubeck_server *server, const char *config)
237224

238225
server->fd_signal = load_signalfd();
239226
server->fd_update = load_timerfd(1);
240-
server->fd_expire = -1;
241227

242228
/* init the memory allocator */
243229
brubeck_slab_init(&server->slab);
@@ -272,7 +258,7 @@ static int signal_triggered(struct pollfd *fd)
272258

273259
int brubeck_server_run(struct brubeck_server *server)
274260
{
275-
struct pollfd fds[3];
261+
struct pollfd fds[2];
276262
int nfd = 2;
277263
size_t i;
278264

@@ -284,11 +270,6 @@ int brubeck_server_run(struct brubeck_server *server)
284270
fds[1].fd = server->fd_update;
285271
fds[1].events = POLLIN;
286272

287-
if (server->fd_expire >= 0) {
288-
fds[2].fd = server->fd_expire;
289-
fds[2].events = POLLIN;
290-
nfd++;
291-
}
292273

293274
server->running = 1;
294275
log_splunk("event=listening");
@@ -315,11 +296,6 @@ int brubeck_server_run(struct brubeck_server *server)
315296
update_flows(server);
316297
update_proctitle(server);
317298
}
318-
319-
if (timer_elapsed(&fds[2])) {
320-
log_splunk("event=expire_metrics");
321-
brubeck_hashtable_foreach(server->metrics, &expire_metric, NULL);
322-
}
323299
}
324300

325301
for (i = 0; i < server->active_backends; ++i)

0 commit comments

Comments
 (0)