To measure transactions and important segments of code in your application:
- Include the newrelic_transaction.h and newrelic_common.h header files.
- Link your application to the libnewrelic-transaction and libnewrelic-common libraries.
Create a transaction; for example:
long transaction_id = newrelic_transaction_begin();
Optional: Set a name for the transaction any time before the transaction ends. For example:
int return_code = newrelic_transaction_set_name ( transaction_id, "create_account" );
Measure segments; for example:
long segment_id = newrelic_segment_generic_begin ( transaction_id, parent_id, "check_if_account_exists" ); <call check_if_account_exists> int return_code = newrelic_segment_end ( transaction_id, segment_id );
Optional: If this is not a web transaction, set the transaction type any time before the transaction ends. For example:
End your transaction; for example:
int error_code = newrelic_transaction_end(transaction_id);
- Start your app, and then wait a few minutes to start seeing data in your New Relic dashboards.
For more help
Additional documentation resources include:
- Configuring the Agent SDK (choosing daemon-mode or embedded mode, updating your configuration's environmental variables, and running the agent in the selected mode)
- Configuring Agent SDK logging (customizing and reviewing log file information)
- Limiting or disabling Agent SDK settings (using additional options for data collection)