2
2
3
3
#include < datadog/telemetry/telemetry.h>
4
4
5
+ #include < exception>
6
+
5
7
#include " datadog_context.h"
6
8
#include " ngx_http_datadog_module.h"
9
+ #include " telemetry_util.h"
7
10
8
11
extern " C" {
9
12
#include < ngx_config.h>
@@ -29,8 +32,6 @@ static bool is_datadog_tracing_enabled(
29
32
return loc_conf->enable_tracing && core_loc_conf->log_subrequest ;
30
33
}
31
34
}
32
- #define CURRENT_FRAME \
33
- std::format (" {}:{} in {}" , __FILE__, __LINE__, __PRETTY_FUNCTION__)
34
35
35
36
ngx_int_t on_enter_block (ngx_http_request_t *request) noexcept try {
36
37
auto core_loc_conf = static_cast <ngx_http_core_loc_conf_t *>(
@@ -54,7 +55,7 @@ ngx_int_t on_enter_block(ngx_http_request_t *request) noexcept try {
54
55
try {
55
56
context->on_change_block (request, core_loc_conf, loc_conf);
56
57
} catch (const std::exception &e) {
57
- telemetry::report_error_log (e.what ());
58
+ telemetry::report_error_log (e.what (), CURRENT_FRAME (request) );
58
59
// The DatadogContext may be broken, destroy it so that we don't
59
60
// attempt to continue tracing.
60
61
destroy_datadog_context (request);
@@ -63,7 +64,7 @@ ngx_int_t on_enter_block(ngx_http_request_t *request) noexcept try {
63
64
}
64
65
return NGX_DECLINED;
65
66
} catch (const std::exception &e) {
66
- telemetry::report_error_log (e.what ());
67
+ telemetry::report_error_log (e.what (), CURRENT_FRAME (request) );
67
68
ngx_log_error (NGX_LOG_ERR, request->connection ->log , 0 ,
68
69
" Datadog instrumentation failed for request %p: %s" , request,
69
70
e.what ());
@@ -86,7 +87,7 @@ ngx_int_t on_access(ngx_http_request_t *request) noexcept try {
86
87
}
87
88
return NGX_DECLINED;
88
89
} catch (const std::exception &e) {
89
- telemetry::report_error_log (e.what ());
90
+ telemetry::report_error_log (e.what (), CURRENT_FRAME (request) );
90
91
ngx_log_error (NGX_LOG_ERR, request->connection ->log , 0 ,
91
92
" Datadog instrumentation failed for request %p: %s" , request,
92
93
e.what ());
@@ -100,7 +101,7 @@ ngx_int_t on_log_request(ngx_http_request_t *request) noexcept {
100
101
try {
101
102
context->on_log_request (request);
102
103
} catch (const std::exception &e) {
103
- telemetry::report_error_log (e.what ());
104
+ telemetry::report_error_log (e.what (), CURRENT_FRAME (request) );
104
105
ngx_log_error (NGX_LOG_ERR, request->connection ->log , 0 ,
105
106
" Datadog instrumentation failed for request %p: %s" , request,
106
107
e.what ());
@@ -117,7 +118,7 @@ ngx_int_t on_header_filter(ngx_http_request_t *request) noexcept {
117
118
try {
118
119
return context->on_header_filter (request);
119
120
} catch (const std::exception &e) {
120
- telemetry::report_error_log (e.what ());
121
+ telemetry::report_error_log (e.what (), CURRENT_FRAME (request) );
121
122
ngx_log_error (NGX_LOG_ERR, request->connection ->log , 0 ,
122
123
" Datadog instrumentation failed for request %p: %s" , request,
123
124
e.what ());
@@ -142,7 +143,7 @@ ngx_int_t request_body_filter(ngx_http_request_t *request,
142
143
try {
143
144
return context->request_body_filter (request, chain);
144
145
} catch (const std::exception &e) {
145
- telemetry::report_error_log (e.what ());
146
+ telemetry::report_error_log (e.what (), CURRENT_FRAME (request) );
146
147
ngx_log_error (NGX_LOG_ERR, request->connection ->log , 0 ,
147
148
" Datadog instrumentation failed in request body filter for "
148
149
" request %p: %s" ,
@@ -166,7 +167,7 @@ ngx_int_t on_output_body_filter(ngx_http_request_t *request,
166
167
try {
167
168
return context->on_output_body_filter (request, chain);
168
169
} catch (const std::exception &e) {
169
- telemetry::report_error_log (e.what ());
170
+ telemetry::report_error_log (e.what (), CURRENT_FRAME (request) );
170
171
ngx_log_error (NGX_LOG_ERR, request->connection ->log , 0 ,
171
172
" Datadog instrumentation failed for request %p: %s" , request,
172
173
e.what ());
0 commit comments