27 #include <sys/socket.h>
39 #define NB_EXAMPLE_STRINGS 5
40 #define MAX_EXAMPLE_STRING_SIZE 256
41 #define SINGLE_FIELD_VALUE 1
71 static int collected_example_events_count;
80 event->event_number = collected_example_events_count++;
98 struct doca_telemetry_exporter_field *field;
99 const int nb_fields = 5;
104 const char *type_name;
114 for (idx = 0; idx < nb_fields; idx++) {
141 bool file_write_enable =
true;
142 bool ipc_enabled =
true;
145 int32_t iteration = 0;
147 struct doca_telemetry_exporter_schema *doca_schema =
NULL;
148 struct doca_telemetry_exporter_source *doca_source =
NULL;
153 struct doca_telemetry_exporter_type *example_type;
189 if (file_write_enable)
237 for (iteration = 0; iteration < repetition; iteration++) {
251 if (iteration % 2 == 0) {
enum doca_error doca_error_t
DOCA API return codes.
@ DOCA_ERROR_INVALID_VALUE
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
#define DOCA_LOG_INFO(format,...)
Generates an INFO application log message.
#define DOCA_TELEMETRY_EXPORTER_FIELD_TYPE_TIMESTAMP
DOCA telemetry timestamp type.
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_schema_init(const char *schema_name, struct doca_telemetry_exporter_schema **doca_schema)
Initialize DOCA schema to prepare it for setting attributes and adding types. DOCA schema is used to ...
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_source_flush(struct doca_telemetry_exporter_source *doca_source)
Immediately flush the data of the DOCA source. This function is not thread-safe and should not be cal...
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_type_destroy(struct doca_telemetry_exporter_type *type)
Destroy doca telemetry type previously created by doca_telemetry_exporter_type_create()
DOCA_EXPERIMENTAL void doca_telemetry_exporter_field_set_type_name(struct doca_telemetry_exporter_field *field_info, const char *type)
Set doca telemetry field type.
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_source_destroy(struct doca_telemetry_exporter_source *doca_source)
Destructor for DOCA source.
DOCA_EXPERIMENTAL void doca_telemetry_exporter_field_set_description(struct doca_telemetry_exporter_field *field_info, const char *desc)
Set doca telemetry field description.
#define DOCA_TELEMETRY_EXPORTER_FIELD_TYPE_INT32
DOCA telemetry int32 type.
DOCA_EXPERIMENTAL void doca_telemetry_exporter_schema_set_ipc_enabled(struct doca_telemetry_exporter_schema *doca_schema)
Enable IPC IPC is disabled by default.
DOCA_EXPERIMENTAL void doca_telemetry_exporter_source_set_id(struct doca_telemetry_exporter_source *doca_source, const char *source_id)
Set source id.
#define DOCA_TELEMETRY_EXPORTER_FIELD_TYPE_UINT64
DOCA telemetry uint64 type.
uint8_t doca_telemetry_exporter_type_index_t
DOCA schema field type index.
DOCA_EXPERIMENTAL void doca_telemetry_exporter_field_set_array_len(struct doca_telemetry_exporter_field *field_info, uint16_t len)
Set doca telemetry field length.
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_schema_add_type(struct doca_telemetry_exporter_schema *doca_schema, const char *new_type_name, struct doca_telemetry_exporter_type *type, doca_telemetry_exporter_type_index_t *type_index)
Add user-defined fields to create new type in DOCA schema. The users loses the ownership of the type ...
DOCA_EXPERIMENTAL void doca_telemetry_exporter_schema_set_buf_size(struct doca_telemetry_exporter_schema *doca_schema, uint64_t size)
Set buffer size Default value is 60000 bytes.
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_source_create(struct doca_telemetry_exporter_schema *doca_schema, struct doca_telemetry_exporter_source **doca_source)
Creates a single DOCA source from schema.
DOCA_EXPERIMENTAL void doca_telemetry_exporter_field_set_name(struct doca_telemetry_exporter_field *field_info, const char *name)
Set doca telemetry field name.
uint64_t doca_telemetry_exporter_timestamp_t
DOCA schema type index type.
#define DOCA_TELEMETRY_EXPORTER_FIELD_TYPE_CHAR
DOCA telemetry char type.
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_type_create(struct doca_telemetry_exporter_type **type)
Create new telemetry type.
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_get_timestamp(doca_telemetry_exporter_timestamp_t *timestamp)
Get timestamp in the proper format.
DOCA_EXPERIMENTAL void doca_telemetry_exporter_source_set_tag(struct doca_telemetry_exporter_source *doca_source, const char *source_tag)
Set source tag.
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_field_create(struct doca_telemetry_exporter_field **field)
Create new telemetry field.
DOCA_EXPERIMENTAL void doca_telemetry_exporter_schema_set_file_write_enabled(struct doca_telemetry_exporter_schema *doca_schema)
Enable file write file write is disabled by default.
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_schema_destroy(struct doca_telemetry_exporter_schema *doca_schema)
Destructor for DOCA schema.
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_schema_start(struct doca_telemetry_exporter_schema *doca_schema)
Finalizes schema setup to start creating Doca Sources from the schema.
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_type_add_field(struct doca_telemetry_exporter_type *type, struct doca_telemetry_exporter_field *field)
Add DOCA telemetry field to type. The users loses the ownership of the field after a successful invoc...
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_source_start(struct doca_telemetry_exporter_source *doca_source)
Applies source attribute and starts DOCA source.
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_source_report(struct doca_telemetry_exporter_source *doca_source, doca_telemetry_exporter_type_index_t index, void *data, int count)
Report events data of the same type via DOCA source.
char example_string[MAX_EXAMPLE_STRING_SIZE]
doca_telemetry_exporter_timestamp_t timestamp
static doca_error_t telemetry_register_fields(struct doca_telemetry_exporter_type *type)
static doca_error_t prepare_example_event(int32_t iter_number, uint64_t string_number, struct test_event_type *event)
struct test_event_type __attribute__((packed))
#define SINGLE_FIELD_VALUE
doca_telemetry_exporter_timestamp_t timestamp
static char * example_strings[NB_EXAMPLE_STRINGS]
doca_error_t telemetry_export(void)
#define NB_EXAMPLE_STRINGS
#define MAX_EXAMPLE_STRING_SIZE
DOCA_LOG_REGISTER(TELEMETRY_EXPORTER)