opentracing-c
OpenTracing C API
span.h
Go to the documentation of this file.
1 #ifndef OPENTRACINGC_SPAN_H
2 #define OPENTRACINGC_SPAN_H
3 
4 #include <opentracing-c/config.h>
6 #include <opentracing-c/value.h>
7 
10 #ifdef __cplusplus
11 extern "C" {
12 #endif /* __cplusplus */
13 
20 typedef struct opentracing_span_context {
23 
33  void (*foreach_baggage_item)(struct opentracing_span_context* span_context,
34  opentracing_bool (*f)(void* arg,
35  const char* key,
36  const char* value),
37  void* arg);
38 
59  const void* type_descriptor;
60 
64  unsigned int type_descriptor_length;
66 
70 typedef struct opentracing_log_field {
72  const char* key;
76 
81 typedef struct opentracing_log_record {
89 
97 
124 
127  opentracing_span_context* referenced_context;
129 
130 #define OPENTRACINGC_CHILD_OF(span_context) \
131  { \
132  opentracing_span_reference_child_of, &(span_context) \
133  }
134 
135 #define OPENTRACINGC_FOLLOWS_FROM(span_context) \
136  { \
137  opentracing_span_reference_follows_from, &(span_context) \
138  }
139 
143 
146 
153 
154 /* Forward declaration. */
155 struct opentracing_tracer;
156 
161 typedef struct opentracing_span {
164 
175  void (*finish)(struct opentracing_span* span) OPENTRACINGC_NONNULL_ALL;
176 
183  void (*finish_with_options)(struct opentracing_span* span,
184  const opentracing_finish_span_options* options)
185  OPENTRACINGC_NONNULL(1);
186 
195  opentracing_span_context* (*span_context)(struct opentracing_span* span)
196  OPENTRACINGC_NONNULL_ALL;
197 
203  void (*set_operation_name)(struct opentracing_span* span,
204  const char* operation_name)
205  OPENTRACINGC_NONNULL_ALL;
206 
217  void (*set_tag)(struct opentracing_span* span,
218  const char* key,
219  const opentracing_value* value) OPENTRACINGC_NONNULL_ALL;
220 
229  void (*log_fields)(struct opentracing_span* span,
230  const opentracing_log_field* fields,
231  int num_fields) OPENTRACINGC_NONNULL(1);
232 
250  void (*set_baggage_item)(struct opentracing_span* span,
251  const char* key,
252  const char* value) OPENTRACINGC_NONNULL_ALL;
253 
261  const char* (*baggage_item)(const struct opentracing_span* span,
262  const char* key) OPENTRACINGC_NONNULL_ALL;
263 
269  struct opentracing_tracer* (*tracer)(const struct opentracing_span* span)
270  OPENTRACINGC_NONNULL_ALL;
272 
273 #ifdef __cplusplus
274 }
275 #endif /* __cplusplus */
276 
277 #endif /* OPENTRACINGC_SPAN_H */
Duration type to calculate precise intervals (should use monotonic clock).
Definition: common.h:37
opentracing_log_field * fields
Array of fields.
Definition: span.h:85
opentracing_destructible base
Base class member.
Definition: span.h:22
opentracing_value value
Value representation.
Definition: span.h:74
opentracing_bool
Boolean type.
Definition: common.h:19
void(* set_tag)(struct opentracing_span *span, const char *key, const opentracing_value *value) OPENTRACINGC_NONNULL_ALL
Adds a tag to the span.
Definition: span.h:217
opentracing_destructible base
Base class member.
Definition: span.h:163
void(* set_baggage_item)(struct opentracing_span *span, const char *key, const char *value) OPENTRACINGC_NONNULL_ALL
Sets a key:value pair on this span and its span context that also propagates to descendants of this s...
Definition: span.h:250
void(* set_operation_name)(struct opentracing_span *span, const char *operation_name) OPENTRACINGC_NONNULL_ALL
Sets or changes the operation name.
Definition: span.h:203
opentracing_timestamp timestamp
Time of logged event.
Definition: span.h:83
Definition: span.h:125
Destructible interface.
Definition: destructible.h:16
opentracing_duration finish_time
Time span finished using monotonic clock.
Definition: span.h:142
const void * type_descriptor
Unique data used to identify tracing vendor span type.
Definition: span.h:59
Refers to a parent span that caused and somehow depends upon the new child span.
Definition: span.h:96
int num_fields
Number of fields.
Definition: span.h:87
Log record can be used to describe events that occur in the lifetime of a span.
Definition: span.h:81
void(* log_fields)(struct opentracing_span *span, const opentracing_log_field *fields, int num_fields) OPENTRACINGC_NONNULL(1)
Record key:value logging data about a span.
Definition: span.h:229
const char * key
Key string.
Definition: span.h:72
struct opentracing_span_context opentracing_span_context
Span context interface.
Tracer interface.
Definition: tracer.h:61
struct opentracing_log_field opentracing_log_field
Log field to represent key-value pair for a log.
void(* finish)(struct opentracing_span *span) OPENTRACINGC_NONNULL_ALL
Sets the end timestamp and finalizes span state.
Definition: span.h:175
Definition: span.h:140
Timestamp type to represent absolute time (should use system clock).
Definition: common.h:43
struct opentracing_log_record opentracing_log_record
Log record can be used to describe events that occur in the lifetime of a span.
Log field to represent key-value pair for a log.
Definition: span.h:70
Refers to a parent span that does not depend in any way on the result of the new child span...
Definition: span.h:122
unsigned int type_descriptor_length
Number of bytes the type descriptor occupies in memory.
Definition: span.h:64
void(* finish_with_options)(struct opentracing_span *span, const opentracing_finish_span_options *options) OPENTRACINGC_NONNULL(1)
Like finish() but with explicit control over timestamps and log data.
Definition: span.h:183
struct opentracing_span opentracing_span
Span interface.
const opentracing_log_record * log_records
Array of log records.
Definition: span.h:145
void(* foreach_baggage_item)(struct opentracing_span_context *span_context, opentracing_bool(*f)(void *arg, const char *key, const char *value), void *arg)
Calls a function for each baggage item in the span context.
Definition: span.h:33
int num_log_records
Number of log records.
Definition: span.h:151
Span interface.
Definition: span.h:161
Tagged union that can represent a number of value types.
Definition: value.h:30
Span context interface.
Definition: span.h:20
opentracing_span_reference_type
Definition: span.h:90