From 0706c80e3a3b5f75b3e68bf3e48f22d263ac5c43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9=20VERSTRAETE?= Date: Thu, 27 Apr 2023 09:27:24 +0200 Subject: [PATCH] feat(otel-webserver-module): Support Apache Hook translate_name --- .../include/apache/ApacheHooks.h | 8 +++ .../include/apache/HookContainer.h | 5 ++ .../src/apache/ApacheHooks.cpp | 64 +++++++++++++++++++ 3 files changed, 77 insertions(+) diff --git a/instrumentation/otel-webserver-module/include/apache/ApacheHooks.h b/instrumentation/otel-webserver-module/include/apache/ApacheHooks.h index 0b3f13198..64583f68b 100644 --- a/instrumentation/otel-webserver-module/include/apache/ApacheHooks.h +++ b/instrumentation/otel-webserver-module/include/apache/ApacheHooks.h @@ -74,6 +74,7 @@ class ApacheHooks static int otel_hook_interaction_end_quick_handler(request_rec *r, int i); static void otel_hook_interaction_end_insert_filter(request_rec *r); static int otel_hook_interaction_end_log_transaction(request_rec *r); + static int otel_hook_interaction_end_translate_name(request_rec *r); }; class ApacheHooksForStage @@ -185,6 +186,11 @@ class ApacheHooksForStage static int otel_hook_log_transaction3(request_rec* r); static int otel_hook_log_transaction4(request_rec* r); static int otel_hook_log_transaction5(request_rec* r); + static int otel_hook_translate_name1(request_rec* r); + static int otel_hook_translate_name2(request_rec* r); + static int otel_hook_translate_name3(request_rec* r); + static int otel_hook_translate_name4(request_rec* r); + static int otel_hook_translate_name5(request_rec* r); static const std::vector otel_header_parser_hooks; static const std::vector otel_header_parser_indexes; @@ -206,6 +212,8 @@ class ApacheHooksForStage static const std::vector otel_handler_indexes; static const std::vector otel_log_transaction_hooks; static const std::vector otel_log_transaction_indexes; + static const std::vector otel_translate_name_hooks; + static const std::vector otel_translate_name_indexes; template static void insertHooksForStage( diff --git a/instrumentation/otel-webserver-module/include/apache/HookContainer.h b/instrumentation/otel-webserver-module/include/apache/HookContainer.h index a15b782bd..981c8d40b 100644 --- a/instrumentation/otel-webserver-module/include/apache/HookContainer.h +++ b/instrumentation/otel-webserver-module/include/apache/HookContainer.h @@ -106,6 +106,11 @@ class HookContainer ,OTEL_ENDPOINT_LOG_TRANSACTION3 ,OTEL_ENDPOINT_LOG_TRANSACTION4 ,OTEL_ENDPOINT_LOG_TRANSACTION5 + ,OTEL_ENDPOINT_TRANSLATE_NAME1 + ,OTEL_ENDPOINT_TRANSLATE_NAME2 + ,OTEL_ENDPOINT_TRANSLATE_NAME3 + ,OTEL_ENDPOINT_TRANSLATE_NAME4 + ,OTEL_ENDPOINT_TRANSLATE_NAME5 ,OTEL_MAX_ENDPOINTS }; diff --git a/instrumentation/otel-webserver-module/src/apache/ApacheHooks.cpp b/instrumentation/otel-webserver-module/src/apache/ApacheHooks.cpp index 1bb575575..2eb93db98 100644 --- a/instrumentation/otel-webserver-module/src/apache/ApacheHooks.cpp +++ b/instrumentation/otel-webserver-module/src/apache/ApacheHooks.cpp @@ -86,6 +86,7 @@ void ApacheHooks::registerHooks(apr_pool_t *p) ap_hook_fixups(ApacheHooks::otel_hook_interaction_end, NULL, NULL, APR_HOOK_REALLY_FIRST - 2); ap_hook_handler(ApacheHooks::otel_hook_interaction_end, NULL, NULL, APR_HOOK_REALLY_FIRST - 2); ap_hook_log_transaction(ApacheHooks::otel_hook_interaction_end_log_transaction, NULL, NULL, APR_HOOK_REALLY_FIRST - 2); + ap_hook_translate_name(ApacheHooks::otel_hook_interaction_end, NULL, NULL, APR_HOOK_REALLY_FIRST - 2); // Stage Hooks // 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) ApacheHooksForStage::otel_log_transaction_indexes, ApacheHooks::otel_hook_interaction_end, "log_transaction"); + ApacheHooksForStage::insertHooksForStage( + p, + ap_hook_get_translate_name, + ap_hook_translate_name, + ApacheHooksForStage::otel_translate_name_hooks, + ApacheHooksForStage::otel_translate_name_indexes, + ApacheHooks::otel_hook_interaction_end, + "translate_name"); } apr_status_t ApacheHooks::otel_output_filter(ap_filter_t* f, apr_bucket_brigade* bb) @@ -1300,6 +1309,7 @@ int ApacheHooksForStage::otel_hook_log_transaction3(request_rec* r) HookContainer::OTEL_ENDPOINT_LOG_TRANSACTION3); return DECLINED; } + int ApacheHooksForStage::otel_hook_log_transaction4(request_rec* r) { ApacheHooks::otel_startInteraction( @@ -1307,6 +1317,7 @@ int ApacheHooksForStage::otel_hook_log_transaction4(request_rec* r) HookContainer::OTEL_ENDPOINT_LOG_TRANSACTION4); return DECLINED; } + int ApacheHooksForStage::otel_hook_log_transaction5(request_rec* r) { ApacheHooks::otel_startInteraction( @@ -1315,6 +1326,47 @@ int ApacheHooksForStage::otel_hook_log_transaction5(request_rec* r) return DECLINED; } +int ApacheHooksForStage::otel_hook_translate_name1(request_rec* r) +{ + ApacheHooks::otel_startInteraction( + r, + HookContainer::OTEL_ENDPOINT_TRANSLATE_NAME1); + return DECLINED; +} + +int ApacheHooksForStage::otel_hook_translate_name2(request_rec* r) +{ + ApacheHooks::otel_startInteraction( + r, + HookContainer::OTEL_ENDPOINT_TRANSLATE_NAME2); + return DECLINED; +} + +int ApacheHooksForStage::otel_hook_translate_name3(request_rec* r) +{ + ApacheHooks::otel_startInteraction( + r, + HookContainer::OTEL_ENDPOINT_TRANSLATE_NAME3); + return DECLINED; +} + +int ApacheHooksForStage::otel_hook_translate_name4(request_rec* r) +{ + ApacheHooks::otel_startInteraction( + r, + HookContainer::OTEL_ENDPOINT_TRANSLATE_NAME4); + return DECLINED; +} + +int ApacheHooksForStage::otel_hook_translate_name5(request_rec* r) +{ + ApacheHooks::otel_startInteraction( + r, + HookContainer::OTEL_ENDPOINT_TRANSLATE_NAME5); + return DECLINED; +} + + // These hooks are for stopping interactions after a module int ApacheHooks::otel_hook_interaction_end(request_rec *r) { @@ -1542,3 +1594,15 @@ const std::vector ApacheHooksForStage::ote ,HookContainer::OTEL_ENDPOINT_LOG_TRANSACTION3 ,HookContainer::OTEL_ENDPOINT_LOG_TRANSACTION4 ,HookContainer::OTEL_ENDPOINT_LOG_TRANSACTION5}; +const std::vector ApacheHooksForStage::otel_translate_name_hooks = + {otel_hook_translate_name1 + ,otel_hook_translate_name2 + ,otel_hook_translate_name3 + ,otel_hook_translate_name4 + ,otel_hook_translate_name5}; +const std::vector ApacheHooksForStage::otel_translate_name_indexes = + {HookContainer::OTEL_ENDPOINT_TRANSLATE_NAME1 + ,HookContainer::OTEL_ENDPOINT_TRANSLATE_NAME2 + ,HookContainer::OTEL_ENDPOINT_TRANSLATE_NAME3 + ,HookContainer::OTEL_ENDPOINT_TRANSLATE_NAME4 + ,HookContainer::OTEL_ENDPOINT_TRANSLATE_NAME5};