Skip to content

Commit 0706c80

Browse files
timvtinsaTimothé Verstraete
authored andcommitted
feat(otel-webserver-module): Support Apache Hook translate_name
1 parent e664863 commit 0706c80

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

instrumentation/otel-webserver-module/include/apache/ApacheHooks.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class ApacheHooks
7474
static int otel_hook_interaction_end_quick_handler(request_rec *r, int i);
7575
static void otel_hook_interaction_end_insert_filter(request_rec *r);
7676
static int otel_hook_interaction_end_log_transaction(request_rec *r);
77+
static int otel_hook_interaction_end_translate_name(request_rec *r);
7778
};
7879

7980
class ApacheHooksForStage
@@ -185,6 +186,11 @@ class ApacheHooksForStage
185186
static int otel_hook_log_transaction3(request_rec* r);
186187
static int otel_hook_log_transaction4(request_rec* r);
187188
static int otel_hook_log_transaction5(request_rec* r);
189+
static int otel_hook_translate_name1(request_rec* r);
190+
static int otel_hook_translate_name2(request_rec* r);
191+
static int otel_hook_translate_name3(request_rec* r);
192+
static int otel_hook_translate_name4(request_rec* r);
193+
static int otel_hook_translate_name5(request_rec* r);
188194

189195
static const std::vector<processRequestHooks> otel_header_parser_hooks;
190196
static const std::vector<HookContainer::otel_endpoint_indexes> otel_header_parser_indexes;
@@ -206,6 +212,8 @@ class ApacheHooksForStage
206212
static const std::vector<HookContainer::otel_endpoint_indexes> otel_handler_indexes;
207213
static const std::vector<processRequestHooks> otel_log_transaction_hooks;
208214
static const std::vector<HookContainer::otel_endpoint_indexes> otel_log_transaction_indexes;
215+
static const std::vector<processRequestHooks> otel_translate_name_hooks;
216+
static const std::vector<HookContainer::otel_endpoint_indexes> otel_translate_name_indexes;
209217

210218
template<typename T, typename S>
211219
static void insertHooksForStage(

instrumentation/otel-webserver-module/include/apache/HookContainer.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ class HookContainer
106106
,OTEL_ENDPOINT_LOG_TRANSACTION3
107107
,OTEL_ENDPOINT_LOG_TRANSACTION4
108108
,OTEL_ENDPOINT_LOG_TRANSACTION5
109+
,OTEL_ENDPOINT_TRANSLATE_NAME1
110+
,OTEL_ENDPOINT_TRANSLATE_NAME2
111+
,OTEL_ENDPOINT_TRANSLATE_NAME3
112+
,OTEL_ENDPOINT_TRANSLATE_NAME4
113+
,OTEL_ENDPOINT_TRANSLATE_NAME5
109114

110115
,OTEL_MAX_ENDPOINTS
111116
};

instrumentation/otel-webserver-module/src/apache/ApacheHooks.cpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ void ApacheHooks::registerHooks(apr_pool_t *p)
8686
ap_hook_fixups(ApacheHooks::otel_hook_interaction_end, NULL, NULL, APR_HOOK_REALLY_FIRST - 2);
8787
ap_hook_handler(ApacheHooks::otel_hook_interaction_end, NULL, NULL, APR_HOOK_REALLY_FIRST - 2);
8888
ap_hook_log_transaction(ApacheHooks::otel_hook_interaction_end_log_transaction, NULL, NULL, APR_HOOK_REALLY_FIRST - 2);
89+
ap_hook_translate_name(ApacheHooks::otel_hook_interaction_end, NULL, NULL, APR_HOOK_REALLY_FIRST - 2);
8990

9091
// Stage Hooks
9192
// TODO: Decide among the following stages at what all we need the modules to be instrumented,
@@ -170,6 +171,14 @@ void ApacheHooks::registerHooks(apr_pool_t *p)
170171
ApacheHooksForStage::otel_log_transaction_indexes,
171172
ApacheHooks::otel_hook_interaction_end,
172173
"log_transaction");
174+
ApacheHooksForStage::insertHooksForStage(
175+
p,
176+
ap_hook_get_translate_name,
177+
ap_hook_translate_name,
178+
ApacheHooksForStage::otel_translate_name_hooks,
179+
ApacheHooksForStage::otel_translate_name_indexes,
180+
ApacheHooks::otel_hook_interaction_end,
181+
"translate_name");
173182
}
174183

175184
apr_status_t ApacheHooks::otel_output_filter(ap_filter_t* f, apr_bucket_brigade* bb)
@@ -1300,13 +1309,15 @@ int ApacheHooksForStage::otel_hook_log_transaction3(request_rec* r)
13001309
HookContainer::OTEL_ENDPOINT_LOG_TRANSACTION3);
13011310
return DECLINED;
13021311
}
1312+
13031313
int ApacheHooksForStage::otel_hook_log_transaction4(request_rec* r)
13041314
{
13051315
ApacheHooks::otel_startInteraction(
13061316
r,
13071317
HookContainer::OTEL_ENDPOINT_LOG_TRANSACTION4);
13081318
return DECLINED;
13091319
}
1320+
13101321
int ApacheHooksForStage::otel_hook_log_transaction5(request_rec* r)
13111322
{
13121323
ApacheHooks::otel_startInteraction(
@@ -1315,6 +1326,47 @@ int ApacheHooksForStage::otel_hook_log_transaction5(request_rec* r)
13151326
return DECLINED;
13161327
}
13171328

1329+
int ApacheHooksForStage::otel_hook_translate_name1(request_rec* r)
1330+
{
1331+
ApacheHooks::otel_startInteraction(
1332+
r,
1333+
HookContainer::OTEL_ENDPOINT_TRANSLATE_NAME1);
1334+
return DECLINED;
1335+
}
1336+
1337+
int ApacheHooksForStage::otel_hook_translate_name2(request_rec* r)
1338+
{
1339+
ApacheHooks::otel_startInteraction(
1340+
r,
1341+
HookContainer::OTEL_ENDPOINT_TRANSLATE_NAME2);
1342+
return DECLINED;
1343+
}
1344+
1345+
int ApacheHooksForStage::otel_hook_translate_name3(request_rec* r)
1346+
{
1347+
ApacheHooks::otel_startInteraction(
1348+
r,
1349+
HookContainer::OTEL_ENDPOINT_TRANSLATE_NAME3);
1350+
return DECLINED;
1351+
}
1352+
1353+
int ApacheHooksForStage::otel_hook_translate_name4(request_rec* r)
1354+
{
1355+
ApacheHooks::otel_startInteraction(
1356+
r,
1357+
HookContainer::OTEL_ENDPOINT_TRANSLATE_NAME4);
1358+
return DECLINED;
1359+
}
1360+
1361+
int ApacheHooksForStage::otel_hook_translate_name5(request_rec* r)
1362+
{
1363+
ApacheHooks::otel_startInteraction(
1364+
r,
1365+
HookContainer::OTEL_ENDPOINT_TRANSLATE_NAME5);
1366+
return DECLINED;
1367+
}
1368+
1369+
13181370
// These hooks are for stopping interactions after a module
13191371
int ApacheHooks::otel_hook_interaction_end(request_rec *r)
13201372
{
@@ -1542,3 +1594,15 @@ const std::vector<HookContainer::otel_endpoint_indexes> ApacheHooksForStage::ote
15421594
,HookContainer::OTEL_ENDPOINT_LOG_TRANSACTION3
15431595
,HookContainer::OTEL_ENDPOINT_LOG_TRANSACTION4
15441596
,HookContainer::OTEL_ENDPOINT_LOG_TRANSACTION5};
1597+
const std::vector<ApacheHooksForStage::processRequestHooks> ApacheHooksForStage::otel_translate_name_hooks =
1598+
{otel_hook_translate_name1
1599+
,otel_hook_translate_name2
1600+
,otel_hook_translate_name3
1601+
,otel_hook_translate_name4
1602+
,otel_hook_translate_name5};
1603+
const std::vector<HookContainer::otel_endpoint_indexes> ApacheHooksForStage::otel_translate_name_indexes =
1604+
{HookContainer::OTEL_ENDPOINT_TRANSLATE_NAME1
1605+
,HookContainer::OTEL_ENDPOINT_TRANSLATE_NAME2
1606+
,HookContainer::OTEL_ENDPOINT_TRANSLATE_NAME3
1607+
,HookContainer::OTEL_ENDPOINT_TRANSLATE_NAME4
1608+
,HookContainer::OTEL_ENDPOINT_TRANSLATE_NAME5};

0 commit comments

Comments
 (0)