| 1 |
|
| #include "Agent.h" |
| 2 |
|
| |
| 3 |
|
| #include "newrelic_common.h" |
| 4 |
|
| #include "newrelic_collector_client.h" |
| 5 |
|
| #include "newrelic_transaction.h" |
| 6 |
|
| |
| 7 |
|
| #include <string> |
| 8 |
|
| |
| 9 |
|
| using namespace std; |
| 10 |
|
| |
| 11 |
0 |
| Agent::Agent( |
| 12 |
|
| const char *license_key_, |
| 13 |
|
| const char *app_name_, |
| 14 |
|
| const char *app_language_, |
| 15 |
|
| const char *app_language_version_ |
| 16 |
0 |
| ) |
| 17 |
0 |
▶ | : license_key(string(license_key_)), |
Branch: 1 branch
| Branch | True | False | Total |
| : license_key(string(license_key_)), |
0 |
0 |
0 |
|
| 18 |
0 |
▶ | app_name(string(app_name_)), |
Branch: 1 branch
| Branch | True | False | Total |
| app_name(string(app_name_)), |
0 |
0 |
0 |
|
| 19 |
0 |
▶ | app_language(string(app_language_)), |
Branch: 1 branch
| Branch | True | False | Total |
| app_language(string(app_language_)), |
0 |
0 |
0 |
|
| 20 |
0 |
▶ | app_language_version(string(app_language_version_)) |
Branch: 1 branch
| Branch | True | False | Total |
| app_language_version(string(app_language_version_)) |
0 |
0 |
0 |
|
| 21 |
|
| { |
| 22 |
0 |
| if (!license_key.empty() && |
| 23 |
0 |
▶ | !app_name.empty() && |
Branch: 1 branch
| Branch | True | False | Total |
| !app_name.empty() && |
0 |
0 |
0 |
|
| 24 |
0 |
▶ | !app_language.empty() && |
Branch: 3 branches
| Branch | True | False | Total |
| !app_language.empty() && |
0 |
0 |
0 |
| !app_language.empty() && |
0 |
0 |
0 |
| !app_language.empty() && |
0 |
0 |
0 |
|
| 25 |
0 |
▶ | !app_language_version.empty()) |
Branch: 1 branch
| Branch | True | False | Total |
| !app_language_version.empty()) |
0 |
0 |
0 |
|
| 26 |
0 |
| config_loaded = true; |
| 27 |
0 |
| } |
| 28 |
|
| |
| 29 |
0 |
| void Agent::embed_collector() { |
| 30 |
0 |
| newrelic_register_message_handler(newrelic_message_handler); |
| 31 |
0 |
| } |
| 32 |
|
| |
| 33 |
0 |
| void Agent::init() { |
| 34 |
0 |
| newrelic_init( |
| 35 |
|
| license_key.c_str(), |
| 36 |
|
| app_name.c_str(), |
| 37 |
|
| app_language.c_str(), |
| 38 |
|
| app_language_version.c_str() |
| 39 |
|
| ); |
| 40 |
0 |
| } |
| 41 |
|
| |
| 42 |
0 |
| long Agent::begin_transaction() { |
| 43 |
0 |
| return newrelic_transaction_begin(); |
| 44 |
|
| } |
| 45 |
|
| |
| 46 |
0 |
| int Agent::set_transaction_name(long transaction_id, const char *name) { |
| 47 |
0 |
| return newrelic_transaction_set_name(transaction_id, name); |
| 48 |
|
| } |
| 49 |
|
| |
| 50 |
0 |
| int Agent::set_transaction_request_url(long transaction_id, const char *request_url) { |
| 51 |
0 |
| return newrelic_transaction_set_request_url(transaction_id, request_url); |
| 52 |
|
| } |
| 53 |
|
| |
| 54 |
0 |
| int Agent::set_transaction_max_trace_segments(long transaction_id, int max_trace_segments) { |
| 55 |
0 |
| return newrelic_transaction_set_max_trace_segments(transaction_id, max_trace_segments); |
| 56 |
|
| } |
| 57 |
|
| |
| 58 |
0 |
| int Agent::set_transaction_category(long transaction_id, const char *category) { |
| 59 |
0 |
| return newrelic_transaction_set_category(transaction_id, category); |
| 60 |
|
| } |
| 61 |
|
| |
| 62 |
0 |
| int Agent::set_transaction_type_web(long transaction_id) { |
| 63 |
0 |
| return newrelic_transaction_set_type_web(transaction_id); |
| 64 |
|
| } |
| 65 |
|
| |
| 66 |
0 |
| int Agent::set_transaction_type_other(long transaction_id) { |
| 67 |
0 |
| return newrelic_transaction_set_type_other(transaction_id); |
| 68 |
|
| } |
| 69 |
|
| |
| 70 |
0 |
| int Agent::add_transaction_attribute(long transaction_id, const char *key, const char *value) { |
| 71 |
0 |
| return newrelic_transaction_add_attribute(transaction_id, key, value); |
| 72 |
|
| } |
| 73 |
|
| |
| 74 |
0 |
| int Agent::notice_transaction_error( |
| 75 |
|
| long transaction_id, |
| 76 |
|
| const char *exception_type, |
| 77 |
|
| const char *error_message, |
| 78 |
|
| const char *stack_trace, |
| 79 |
|
| const char *stack_frame_delimiter |
| 80 |
|
| ) { |
| 81 |
0 |
| return newrelic_transaction_notice_error( |
| 82 |
|
| transaction_id, |
| 83 |
|
| exception_type, |
| 84 |
|
| error_message, |
| 85 |
|
| stack_trace, |
| 86 |
|
| stack_frame_delimiter |
| 87 |
0 |
| ); |
| 88 |
|
| } |
| 89 |
|
| |
| 90 |
0 |
| int Agent::end_transaction(long transaction_id) { |
| 91 |
0 |
| return newrelic_transaction_end(transaction_id); |
| 92 |
|
| } |
| 93 |
|
| |
| 94 |
0 |
| int Agent::record_metric(const char *name, double value) { |
| 95 |
0 |
| return newrelic_record_metric(name, value); |
| 96 |
|
| } |
| 97 |
|
| |
| 98 |
0 |
| int Agent::record_cpu_usage(double cpu_user_time_seconds, double cpu_usage_percent) { |
| 99 |
0 |
| return newrelic_record_cpu_usage(cpu_user_time_seconds, cpu_usage_percent); |
| 100 |
|
| } |
| 101 |
|
| |
| 102 |
0 |
| int Agent::record_memory_usage(double memory_megabytes) { |
| 103 |
0 |
| return newrelic_record_memory_usage(memory_megabytes); |
| 104 |
|
| } |
| 105 |
|
| |
| 106 |
0 |
| long Agent::begin_generic_segment( |
| 107 |
|
| long transaction_id, |
| 108 |
|
| long parent_segment_id, |
| 109 |
|
| const char *name) { |
| 110 |
0 |
| return newrelic_segment_generic_begin( |
| 111 |
|
| transaction_id, |
| 112 |
|
| parent_segment_id, |
| 113 |
|
| name |
| 114 |
0 |
| ); |
| 115 |
|
| } |
| 116 |
|
| |
| 117 |
0 |
| long Agent::begin_datastore_segment( |
| 118 |
|
| long transaction_id, |
| 119 |
|
| long parent_segment_id, |
| 120 |
|
| const char *table, |
| 121 |
|
| const char *operation, |
| 122 |
|
| const char *sql, const char *sql_trace_rollup_name |
| 123 |
|
| ) { |
| 124 |
0 |
| return newrelic_segment_datastore_begin( |
| 125 |
|
| transaction_id, |
| 126 |
|
| parent_segment_id, |
| 127 |
|
| table, |
| 128 |
|
| operation, |
| 129 |
|
| sql, |
| 130 |
|
| sql_trace_rollup_name, |
| 131 |
|
| newrelic_basic_literal_replacement_obfuscator |
| 132 |
0 |
| ); |
| 133 |
|
| } |
| 134 |
|
| |
| 135 |
0 |
| long Agent::begin_external_segment( |
| 136 |
|
| long transaction_id, |
| 137 |
|
| long parent_segment_id, |
| 138 |
|
| const char *host, |
| 139 |
|
| const char *name |
| 140 |
|
| ) { |
| 141 |
0 |
| return newrelic_segment_external_begin( |
| 142 |
|
| transaction_id, |
| 143 |
|
| parent_segment_id, |
| 144 |
|
| host, |
| 145 |
|
| name |
| 146 |
0 |
| ); |
| 147 |
|
| } |
| 148 |
|
| |
| 149 |
0 |
| int Agent::end_segment(long transaction_id, long segment_id) { |
| 150 |
0 |
| return newrelic_segment_end(transaction_id, segment_id); |
| 151 |
|
| } |
| 152 |
|
| |
| 153 |
0 |
| const char* Agent::get_license_key() { |
| 154 |
0 |
| return license_key.c_str(); |
| 155 |
|
| } |
| 156 |
|
| |
| 157 |
0 |
| const char* Agent::get_app_name() { |
| 158 |
0 |
| return app_name.c_str(); |
| 159 |
|
| } |
| 160 |
|
| |
| 161 |
0 |
| const char* Agent::get_app_language() { |
| 162 |
0 |
| return app_language.c_str(); |
| 163 |
|
| } |
| 164 |
|
| |
| 165 |
0 |
| const char* Agent::get_app_language_version() { |
| 166 |
0 |
| return app_language_version.c_str(); |
| 167 |
|
| } |