attributes.c

A list of examples for Doxygen to cross-reference. If a function in newrelic-telemetry-sdk.h appears in one of these examples, the example source file appears under the "Examples" header.

/*
* Copyright 2020 New Relic Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
/*
* Create and destroy an attributes collection.
*/
int main() {
/* Destroy a NULL configuration. */
nrt_attributes_t* attrs = NULL;
/* Initialize and destroy attributes of all types. */
attrs = nrt_attributes_new();
assert(attrs);
nrt_attributes_set_int(attrs, "int", -6);
nrt_attributes_set_uint(attrs, "uint", 6);
nrt_attributes_set_double(attrs, "double", 3.14159);
nrt_attributes_set_string(attrs, "string", "value");
nrt_attributes_set_bool(attrs, "bool", true);
assert(NULL == attrs);
/* Call with NULL values */
nrt_attributes_set_int(NULL, NULL, -6);
nrt_attributes_set_uint(NULL, NULL, 6);
nrt_attributes_set_double(NULL, NULL, 3.14159);
nrt_attributes_set_string(NULL, NULL, NULL);
nrt_attributes_set_bool(NULL, NULL, true);
}
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_attributes_set_int(nrt_attributes_t *attributes, const char *key, int64_t value)
Add an int attribute to an attribute collection.
This is a helper library that supports sending New Relic data from within your C/C++ application.
bool nrt_attributes_set_bool(nrt_attributes_t *attributes, const char *key, bool value)
Add a bool attribute to an attribute collection.
bool nrt_attributes_set_uint(nrt_attributes_t *attributes, const char *key, uint64_t value)
Add an unsigned int attribute to an attribute collection.
void nrt_attributes_destroy(nrt_attributes_t **attributes)
Destroy an attribute collection.
struct _nrt_attributes_t nrt_attributes_t
A collection of attributes.
Definition: newrelic-telemetry-sdk.h:60
nrt_attributes_t * nrt_attributes_new()
Create a new attribute collection.
bool nrt_attributes_set_double(nrt_attributes_t *attributes, const char *key, double value)
Add a double attribute to an attribute collection.