#include <float.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "common.h"
#include "libnewrelic.h"
void record_error(newrelic_txn_t* txn) {
int priority = 50;
newrelic_notice_error(txn, priority, "Meaningful error message",
int main(void) {
newrelic_app_t* app = 0;
newrelic_txn_t* txn = 0;
newrelic_app_config_t* config = 0;
char* app_name = get_app_name();
if (NULL == app_name)
return -1;
char* license_key = get_license_key();
if (NULL == license_key)
return -1;
config = newrelic_create_app_config(app_name, license_key);
/* Wait up to 10 seconds for the SDK to connect to the daemon */
app = newrelic_create_app(config, 10000);
/* Start a web transaction */
txn = newrelic_start_web_transaction(app, "ExampleWebTransaction");
newrelic_add_attribute_int(txn, "Custom_int", INT_MAX);
/* Record an error.
* Note the nested call to newrelic_notice_error() so that something
* interesting appears in the backtrace.
/* End web transaction */
return 0;
struct _newrelic_txn_t newrelic_txn_t
A New Relic transaction.
Definition: libnewrelic.h:106
newrelic_txn_t * newrelic_start_web_transaction(newrelic_app_t *app, const char *name)
Start a web based transaction.
Configuration used to describe application name, license key, as well as optional transaction tracer ...
Definition: libnewrelic.h:347
struct _nr_app_and_info_t newrelic_app_t
A New Relic application. Once an application configuration is created with newrelic_create_app_config...
Definition: libnewrelic.h:95
newrelic_app_config_t * newrelic_create_app_config(const char *app_name, const char *license_key)
Create a populated application configuration.
newrelic_app_t * newrelic_create_app(const newrelic_app_config_t *config, unsigned short timeout_ms)
Create an application.
bool newrelic_destroy_app_config(newrelic_app_config_t **config)
Destroy the application configuration.
bool newrelic_end_transaction(newrelic_txn_t **transaction_ptr)
End a transaction.
This is the New Relic C SDK! If your application does not use other New Relic APM agent languages,...
void newrelic_notice_error(newrelic_txn_t *transaction, int priority, const char *errmsg, const char *errclass)
Record an error in a transaction.
bool newrelic_add_attribute_int(newrelic_txn_t *transaction, const char *key, const int value)
Add a custom integer attribute to a transaction.
bool newrelic_destroy_app(newrelic_app_t **app)
Destroy the application.