newrelic-telemetry-sdk.h
Go to the documentation of this file.
1 /*
2  * Copyright 2020 New Relic Corporation. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 
14 #ifndef NEWRELIC_TELEMETRY_SDK
15 #define NEWRELIC_TELEMETRY_SDK
16 
17 #include <stdbool.h>
18 #include <stdint.h>
19 #include <stddef.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
28 typedef struct _nrt_client_config_t nrt_client_config_t;
29 
34 typedef struct _nrt_client_t nrt_client_t;
35 
44 typedef struct _nrt_span_batch_t nrt_span_batch_t;
45 
53 typedef struct _nrt_span_t nrt_span_t;
54 
60 typedef struct _nrt_attributes_t nrt_attributes_t;
61 
68 typedef uint64_t nrt_time_t;
69 
78 
82 typedef enum {
83  NRT_LOG_ERROR = 0,
84  NRT_LOG_WARN = 1,
85  NRT_LOG_INFO = 2,
86  NRT_LOG_DEBUG = 3,
87  NRT_LOG_TRACE = 4,
89 
103 bool nrt_log_init(nrt_log_level_t level, const char* filename);
104 
114  const char* key,
115  int64_t value);
116 
126  const char* key,
127  uint64_t value);
128 
138  const char* key,
139  double value);
140 
150  const char* key,
151  const char* value);
152 
162  const char* key,
163  bool value);
164 
174 
185 nrt_span_t* nrt_span_new(const char* id,
186  const char* trace_id,
187  uint64_t timestamp);
188 
196 bool nrt_span_set_id(nrt_span_t* span, const char* id);
197 
205 bool nrt_span_set_trace_id(nrt_span_t* span, const char* trace_id);
206 
215 
223 bool nrt_span_set_name(nrt_span_t* span, const char* name);
224 
232 bool nrt_span_set_service_name(nrt_span_t* span, const char* service_name);
233 
241 bool nrt_span_set_parent_id(nrt_span_t* span, const char* parent_id);
242 
251 
265 
275 
285 
298 
308 
324 
347  nrt_time_t backoff_factor);
348 
369  uint32_t retries);
370 
383  const char* host,
384  uint16_t port);
385 
401  const char* product,
402  const char* version);
403 
415  size_t queue_max);
416 
426 
437 
454 
464 
474 
488 #ifdef __cplusplus
489 }
490 #endif
491 
492 #endif /* NEWRELIC_TELEMETRY_SDK */
nrt_span_batch_t * nrt_span_batch_new()
Create a new span batch.
nrt_client_t * nrt_client_new(nrt_client_config_t **config)
Create a new client.
struct _nrt_client_config_t nrt_client_config_t
A configuration object used to initialize a nrt_client_t.
Definition: newrelic-telemetry-sdk.h:28
bool nrt_attributes_set_string(nrt_attributes_t *attributes, const char *key, const char *value)
Add a string attribute to an attribute collection.
bool nrt_span_set_attributes(nrt_span_t *span, nrt_attributes_t **attributes)
Set attributes on a span.
bool nrt_attributes_set_int(nrt_attributes_t *attributes, const char *key, int64_t value)
Add an int attribute to an attribute collection.
bool nrt_log_init(nrt_log_level_t level, const char *filename)
Initialize logging.
bool nrt_span_set_timestamp(nrt_span_t *span, nrt_time_t timestamp)
Set the start timestamp for a span.
void nrt_client_destroy(nrt_client_t **client)
Destroy a client.
struct _nrt_client_t nrt_client_t
A Client is capable of both queuing and sending span and metrics batches to a configured New Relic co...
Definition: newrelic-telemetry-sdk.h:34
nrt_client_config_t * nrt_client_config_new(const char *key)
Create a new client configuration with an Insights API key.
bool nrt_span_set_parent_id(nrt_span_t *span, const char *parent_id)
Set the parent_id of a span.
bool nrt_span_set_service_name(nrt_span_t *span, const char *service_name)
Set the service name of a span.
struct _nrt_span_batch_t nrt_span_batch_t
A span batch.
Definition: newrelic-telemetry-sdk.h:44
bool nrt_attributes_set_bool(nrt_attributes_t *attributes, const char *key, bool value)
Add a bool attribute to an attribute collection.
struct _nrt_span_t nrt_span_t
A span.
Definition: newrelic-telemetry-sdk.h:53
uint64_t nrt_time_t
Indicates a point in time or a duration.
Definition: newrelic-telemetry-sdk.h:68
void nrt_client_config_set_retries_max(nrt_client_config_t *config, uint32_t retries)
Configures the maximum numbers of retries.
bool nrt_attributes_set_uint(nrt_attributes_t *attributes, const char *key, uint64_t value)
Add an unsigned int attribute to an attribute collection.
bool nrt_span_set_id(nrt_span_t *span, const char *id)
Set the id of a span.
bool nrt_span_batch_record(nrt_span_batch_t *batch, nrt_span_t **span)
Add a span to a span batch.
void nrt_client_config_set_backoff_factor(nrt_client_config_t *config, nrt_time_t backoff_factor)
Configures a backoff factor.
void nrt_client_config_set_product_info(nrt_client_config_t *config, const char *product, const char *version)
Configure a product and version.
nrt_log_level_t
Represents the available verbosity levels of the logger.
Definition: newrelic-telemetry-sdk.h:82
void nrt_attributes_destroy(nrt_attributes_t **attributes)
Destroy an attribute collection.
void nrt_span_destroy(nrt_span_t **span)
Destroy a span.
bool nrt_span_set_name(nrt_span_t *span, const char *name)
Set the name of a span.
struct _nrt_attributes_t nrt_attributes_t
A collection of attributes.
Definition: newrelic-telemetry-sdk.h:60
void nrt_client_config_set_endpoint_traces(nrt_client_config_t *config, const char *host, uint16_t port)
Configure the ingest host for traces.
void nrt_client_config_set_queue_max(nrt_client_config_t *config, size_t queue_max)
Configure the maximum of batches sent in one go.
bool nrt_span_set_duration(nrt_span_t *span, nrt_time_t duration)
Set the duration for a span.
nrt_attributes_t * nrt_attributes_new()
Create a new attribute collection.
void nrt_client_config_destroy(nrt_client_config_t **config)
Destroy a client configuration.
bool nrt_attributes_set_double(nrt_attributes_t *attributes, const char *key, double value)
Add a double attribute to an attribute collection.
void nrt_client_shutdown(nrt_client_t **client)
Shutdown a client.
nrt_span_t * nrt_span_new(const char *id, const char *trace_id, uint64_t timestamp)
Create a new span.
void nrt_span_batch_destroy(nrt_span_batch_t **batch)
Destroy a span batch.
bool nrt_span_set_trace_id(nrt_span_t *span, const char *trace_id)
Set the trace_id of a span.
bool nrt_client_send(nrt_client_t *client, nrt_span_batch_t **batch)
Send a span batch.