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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* Fluent Bit
* ==========
* Copyright (C) 2022 The Fluent Bit Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FLB_CHUNK_TRACE_H
#define FLB_CHUNK_TRACE_H
#include <fluent-bit/flb_time.h>
#include <fluent-bit/flb_lib.h>
#include <chunkio/cio_chunk.h>
/* A record has been received from input */
#define FLB_CHUNK_TRACE_TYPE_INPUT 1
/* A record has been filtered */
#define FLB_CHUNK_TRACE_TYPE_FILTER 2
/* A trace with the final record before output */
#define FLB_CHUNK_TRACE_TYPE_PRE_OUTPUT 3
/* A record has been output */
#define FLB_CHUNK_TRACE_TYPE_OUTPUT 4
#define FLB_CHUNK_TRACE_LIMIT_TIME 1
#define FLB_CHUNK_TRACE_LIMIT_COUNT 2
struct flb_chunk_trace_input_record {
struct flb_time t;
void *input;
char *buf;
size_t buf_size;
};
struct flb_chunk_trace_filter_record {
struct flb_time t;
int trace_version;
void *filter;
char *buf;
size_t buf_size;
};
struct flb_chunk_trace_limit {
/* set to one of: */
/* FLB_CHUNK_TRACE_LIMIT_TIME */
/* FLB_CHUNK_TRACE_LIMIT_COUNT */
int type;
/* limit is in seconds */
int seconds;
/* unix timestamp when time limit started */
int seconds_started;
/* limit is a count */
int count;
};
struct flb_chunk_trace_context {
void *input;
void *output;
int trace_count;
struct flb_chunk_trace_limit limit;
flb_sds_t trace_prefix;
int to_destroy;
int chunks;
flb_ctx_t *flb;
struct cio_ctx *cio;
};
struct flb_chunk_trace {
struct flb_input_chunk *ic;
struct flb_chunk_trace_context *ctxt;
flb_sds_t trace_id;
int tracer_versions;
};
struct flb_chunk_trace_context *flb_chunk_trace_context_new(void *input, const char *output_name, const char *trace_prefix, void *data, struct mk_list *props);
void flb_chunk_trace_context_destroy(void *input);
struct flb_chunk_trace *flb_chunk_trace_new(struct flb_input_chunk *chunk);
void flb_chunk_trace_destroy(struct flb_chunk_trace *);
int flb_chunk_trace_input(struct flb_chunk_trace *trace);
void flb_chunk_trace_do_input(struct flb_input_chunk *trace);
int flb_chunk_trace_pre_output(struct flb_chunk_trace *trace);
int flb_chunk_trace_filter(struct flb_chunk_trace *trace, void *pfilter, struct flb_time *, struct flb_time *, char *buf, size_t buf_size);
void flb_chunk_trace_free(struct flb_chunk_trace *trace);
int flb_chunk_trace_context_set_limit(void *input, int, int);
int flb_chunk_trace_context_hit_limit(void *input);
#endif // FLB_CHUNK_TRACE_H
|