Willy Tarreau | 4151c75 | 2019-08-08 18:21:26 +0200 | [diff] [blame] | 1 | /* |
| 2 | * include/types/trace.h |
| 3 | * This file provides definitions for runtime tracing |
| 4 | * |
| 5 | * Copyright (C) 2000-2019 Willy Tarreau - w@1wt.eu |
| 6 | * |
| 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public |
| 9 | * License as published by the Free Software Foundation, version 2.1 |
| 10 | * exclusively. |
| 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Lesser General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public |
| 18 | * License along with this library; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ |
| 21 | |
| 22 | #ifndef _TYPES_TRACE_H |
| 23 | #define _TYPES_TRACE_H |
| 24 | |
| 25 | #include <common/buffer.h> |
| 26 | #include <common/compat.h> |
| 27 | #include <common/config.h> |
| 28 | #include <common/ist.h> |
| 29 | #include <common/mini-clist.h> |
| 30 | #include <types/sink.h> |
| 31 | |
| 32 | enum trace_state { |
| 33 | TRACE_STATE_STOPPED = 0, // completely disabled |
| 34 | TRACE_STATE_WAITING, // waiting for the start condition to happen |
| 35 | TRACE_STATE_RUNNING, // waiting for the stop or pause conditions |
| 36 | }; |
| 37 | |
| 38 | enum trace_level { |
| 39 | TRACE_LEVEL_USER = 0, // info useful to the end user |
| 40 | TRACE_LEVEL_PAYLOAD, // add info relevant to the payload |
| 41 | TRACE_LEVEL_PROTO, // add info relevant to the protocol |
| 42 | TRACE_LEVEL_STATE, // add info relevant to the state machine |
| 43 | TRACE_LEVEL_DEVELOPER, // add info useful only to the developer |
| 44 | }; |
| 45 | |
| 46 | enum trace_lockon { |
| 47 | TRACE_LOCKON_NOTHING = 0, // don't lock on anything |
| 48 | TRACE_LOCKON_THREAD, // lock on the thread that started the trace |
| 49 | TRACE_LOCKON_LISTENER, // lock on the listener that started the trace |
| 50 | TRACE_LOCKON_FRONTEND, // lock on the frontend that started the trace |
| 51 | TRACE_LOCKON_BACKEND, // lock on the backend that started the trace |
| 52 | TRACE_LOCKON_SERVER, // lock on the server that started the trace |
| 53 | TRACE_LOCKON_CONNECTION, // lock on the connection that started the trace |
| 54 | TRACE_LOCKON_SESSION, // lock on the session that started the trace |
| 55 | TRACE_LOCKON_STREAM, // lock on the stream that started the trace |
| 56 | }; |
| 57 | |
| 58 | /* Each trace event maps a name to a mask in an uint64_t. Multiple bits are |
| 59 | * permitted to have composite events. This is supposed to be stored into an |
| 60 | * array terminated by mask 0 (name and desc are then ignored). Names "now", |
| 61 | * "any" and "none" are reserved by the CLI parser for start/pause/stop |
| 62 | * operations.. |
| 63 | */ |
| 64 | struct trace_event { |
| 65 | uint64_t mask; |
| 66 | const char *name; |
| 67 | const char *desc; |
| 68 | }; |
| 69 | |
| 70 | struct trace_source { |
| 71 | /* source definition */ |
| 72 | const struct ist name; |
| 73 | const char *desc; |
| 74 | const struct trace_event *known_events; |
| 75 | struct list source_link; // element in list of known trace sources |
| 76 | /* trace configuration, adjusted by "trace <module>" on CLI */ |
| 77 | enum trace_lockon lockon; |
| 78 | uint64_t start_events; // what will start the trace. default: 0=nothing |
| 79 | uint64_t pause_events; // what will pause the trace. default: 0=nothing |
| 80 | uint64_t stop_events; // what will stop the trace. default: 0=nothing |
| 81 | uint64_t report_events; // mask of which events need to be reported. |
| 82 | enum trace_level level; // report traces up to this level of info |
| 83 | int detail_level; // report events with this level of detail (LOG_*) |
| 84 | struct sink *sink; // where to send the trace |
| 85 | /* trace state part below */ |
| 86 | enum trace_state state; |
| 87 | void *lockon_ptr; // what to lockon when lockon is set |
| 88 | }; |
| 89 | |
| 90 | #endif /* _TYPES_TRACE_H */ |
| 91 | |
| 92 | /* |
| 93 | * Local variables: |
| 94 | * c-indent-level: 8 |
| 95 | * c-basic-offset: 8 |
| 96 | * End: |
| 97 | */ |