Miroslav Zagorac | 70230c6 | 2020-12-09 16:54:31 +0100 | [diff] [blame] | 1 | /*** |
| 2 | * Copyright 2020 HAProxy Technologies |
| 3 | * |
| 4 | * This file is part of the HAProxy OpenTracing filter. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version 2 |
| 9 | * of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 19 | */ |
| 20 | #ifndef _OPENTRACING_OT_H_ |
| 21 | #define _OPENTRACING_OT_H_ |
| 22 | |
| 23 | #include <opentracing-c-wrapper/include.h> |
| 24 | |
| 25 | |
| 26 | #define FLT_OT_VSET(p,t,v) \ |
| 27 | do { (p)->type = otc_value_##t; (p)->value.t##_value = (v); } while (0) |
| 28 | |
| 29 | #define FLT_OT_DBG_TEXT_MAP(a) \ |
| 30 | FLT_OT_DBG(3, "%p:{ %p %p %zu/%zu %hhu }", \ |
| 31 | (a), (a)->key, (a)->value, (a)->count, (a)->size, (a)->is_dynamic) |
| 32 | |
| 33 | #define FLT_OT_DBG_TEXT_CARRIER(a,f) \ |
| 34 | FLT_OT_DBG(3, "%p:{ { %p %p %zu/%zu %hhu } %p }", \ |
| 35 | (a), (a)->text_map.key, (a)->text_map.value, (a)->text_map.count, \ |
| 36 | (a)->text_map.size, (a)->text_map.is_dynamic, (a)->f) |
| 37 | |
| 38 | #define FLT_OT_DBG_CUSTOM_CARRIER(a,f) \ |
| 39 | FLT_OT_DBG(3, "%p:{ { %p %zu %hhu } %p }", \ |
| 40 | (a), (a)->binary_data.data, (a)->binary_data.size, \ |
| 41 | (a)->binary_data.is_dynamic, (a)->f) |
| 42 | |
| 43 | #define FLT_OT_DBG_SPAN_CONTEXT(a) \ |
| 44 | FLT_OT_DBG(3, "%p:{ %" PRId64 " %p %p }", (a), (a)->idx, (a)->span, (a)->destroy) |
| 45 | |
| 46 | |
| 47 | #ifndef DEBUG_OT |
| 48 | # define ot_debug() while (0) |
| 49 | # define ot_text_map_show(...) while (0) |
| 50 | #else |
| 51 | void ot_text_map_show(const struct otc_text_map *text_map); |
| 52 | void ot_debug(void); |
| 53 | #endif |
Miroslav Zagorac | fcf4e3d | 2021-06-10 01:23:15 +0200 | [diff] [blame] | 54 | int ot_init(struct otc_tracer **tracer, const char *plugin, char **err); |
| 55 | int ot_start(struct otc_tracer *tracer, const char *cfgbuf, char **err); |
Miroslav Zagorac | 70230c6 | 2020-12-09 16:54:31 +0100 | [diff] [blame] | 56 | struct otc_span *ot_span_init(struct otc_tracer *tracer, const char *operation_name, const struct timespec *ts_steady, const struct timespec *ts_system, int ref_type, int ref_ctx_idx, const struct otc_span *ref_span, const struct otc_tag *tags, int num_tags, char **err); |
| 57 | int ot_span_tag(struct otc_span *span, const struct otc_tag *tags, int num_tags); |
| 58 | int ot_span_log(struct otc_span *span, const struct otc_log_field *log_fields, int num_fields); |
| 59 | int ot_span_set_baggage(struct otc_span *span, const struct otc_text_map *baggage); |
| 60 | struct otc_span_context *ot_inject_http_headers(struct otc_tracer *tracer, const struct otc_span *span, struct otc_http_headers_writer *carrier, char **err); |
| 61 | struct otc_span_context *ot_extract_http_headers(struct otc_tracer *tracer, struct otc_http_headers_reader *carrier, const struct otc_text_map *text_map, char **err); |
| 62 | void ot_span_finish(struct otc_span **span, const struct timespec *ts_finish, const struct timespec *log_ts, const char *log_key, const char *log_value, ...); |
| 63 | void ot_close(struct otc_tracer **tracer); |
| 64 | |
| 65 | /* Unused code. */ |
| 66 | struct otc_span *ot_span_init_va(struct otc_tracer *tracer, const char *operation_name, const struct timespec *ts_steady, const struct timespec *ts_system, int ref_type, int ref_ctx_idx, const struct otc_span *ref_span, char **err, const char *tag_key, const char *tag_value, ...); |
| 67 | int ot_span_tag_va(struct otc_span *span, const char *key, int type, ...); |
| 68 | int ot_span_log_va(struct otc_span *span, const char *key, const char *value, ...); |
| 69 | int ot_span_log_fmt(struct otc_span *span, const char *key, const char *format, ...) __attribute__ ((format(printf, 3, 4))); |
| 70 | int ot_span_set_baggage_va(struct otc_span *span, const char *key, const char *value, ...); |
| 71 | struct otc_text_map *ot_span_baggage_va(const struct otc_span *span, const char *key, ...); |
| 72 | struct otc_span_context *ot_inject_text_map(struct otc_tracer *tracer, const struct otc_span *span, struct otc_text_map_writer *carrier); |
| 73 | struct otc_span_context *ot_inject_binary(struct otc_tracer *tracer, const struct otc_span *span, struct otc_custom_carrier_writer *carrier); |
| 74 | struct otc_span_context *ot_extract_text_map(struct otc_tracer *tracer, struct otc_text_map_reader *carrier, const struct otc_text_map *text_map); |
| 75 | struct otc_span_context *ot_extract_binary(struct otc_tracer *tracer, struct otc_custom_carrier_reader *carrier, const struct otc_binary_data *binary_data); |
| 76 | |
| 77 | #endif /* _OPENTRACING_OT_H_ */ |
| 78 | |
| 79 | /* |
| 80 | * Local variables: |
| 81 | * c-indent-level: 8 |
| 82 | * c-basic-offset: 8 |
| 83 | * End: |
| 84 | * |
| 85 | * vi: noexpandtab shiftwidth=8 tabstop=8 |
| 86 | */ |