Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Apache Hook translate_name in otel-webserver-module #277

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<processRequestHooks> otel_header_parser_hooks;
static const std::vector<HookContainer::otel_endpoint_indexes> otel_header_parser_indexes;
Expand All @@ -206,6 +212,8 @@ class ApacheHooksForStage
static const std::vector<HookContainer::otel_endpoint_indexes> otel_handler_indexes;
static const std::vector<processRequestHooks> otel_log_transaction_hooks;
static const std::vector<HookContainer::otel_endpoint_indexes> otel_log_transaction_indexes;
static const std::vector<processRequestHooks> otel_translate_name_hooks;
static const std::vector<HookContainer::otel_endpoint_indexes> otel_translate_name_indexes;

template<typename T, typename S>
static void insertHooksForStage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -1300,13 +1309,15 @@ 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(
r,
HookContainer::OTEL_ENDPOINT_LOG_TRANSACTION4);
return DECLINED;
}

int ApacheHooksForStage::otel_hook_log_transaction5(request_rec* r)
{
ApacheHooks::otel_startInteraction(
Expand All @@ -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)
{
Expand Down Expand Up @@ -1542,3 +1594,15 @@ const std::vector<HookContainer::otel_endpoint_indexes> ApacheHooksForStage::ote
,HookContainer::OTEL_ENDPOINT_LOG_TRANSACTION3
,HookContainer::OTEL_ENDPOINT_LOG_TRANSACTION4
,HookContainer::OTEL_ENDPOINT_LOG_TRANSACTION5};
const std::vector<ApacheHooksForStage::processRequestHooks> 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<HookContainer::otel_endpoint_indexes> 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};