ex_simple.c
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
/*
* A standalone example that demonstrates to users how to
* configure logging, configure an app, connect an app,
* start a transaction and a segment, and cleanly destroy
* everything.
*/
#include "libnewrelic.h"
int main(void) {
newrelic_app_t* app;
newrelic_txn_t* txn;
newrelic_app_config_t* config;
newrelic_segment_t* seg;
config
printf("Error configuring logging.\n");
return -1;
}
printf("Error connecting to daemon.\n");
return -1;
}
/* Wait up to 10 seconds for the SDK to connect to the daemon */
app = newrelic_create_app(config, 10000);
newrelic_destroy_app_config(&config);
/* Start a web transaction and a segment */
/* Interesting application code happens here */
sleep(2);
/* End the segment and web transaction */
newrelic_end_segment(txn, &seg);
newrelic_end_transaction(&txn);
newrelic_destroy_app(&app);
return 0;
}
struct _newrelic_txn_t newrelic_txn_t
A New Relic transaction.
Definition: libnewrelic.h:106
bool newrelic_init(const char *daemon_socket, int time_limit_ms)
Initialise the C SDK with non-default settings.
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
bool newrelic_end_segment(newrelic_txn_t *transaction, newrelic_segment_t **segment_ptr)
Record the completion of a segment in a transaction.
bool newrelic_configure_log(const char *filename, newrelic_loglevel_t level)
Configure the C SDK's logging system.
Definition: libnewrelic.h:135
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.
newrelic_segment_t * newrelic_start_segment(newrelic_txn_t *transaction, const char *name, const char *category)
Record the start of a custom segment in a transaction.
struct _newrelic_segment_t newrelic_segment_t
A segment within a transaction.
Definition: libnewrelic.h:840
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,...
Generated on Wed Jan 8 2020 01:11:45 for New Relic C SDK by 1.8.16