WIP: make nginx-otel module cmake-free

Use `s/gHttpModule/ngx_otel_module/g' to make the module
linkable.
Update library dependency list with `-lgrpc++' to fix build.
This commit is contained in:
Sergey A. Osokin 2023-09-17 15:48:25 -04:00
parent f58abc0101
commit dc52126d09
2 changed files with 15 additions and 16 deletions

9
config
View file

@ -223,7 +223,7 @@ ngx_feature_name=""
ngx_feature_run=no
ngx_feature_incs="#include <grpc/support/log.h>"
ngx_feature_path="/usr/include"
ngx_feature_libs="-lgrpc -lgpr"
ngx_feature_libs="-lgrpc -lgpr -lgrpc++"
ngx_feature_test="gpr_log_verbosity_init();"
autocppfeature
@ -236,19 +236,18 @@ if [ $ngx_found = no ]; then
ngx_feature_path="/usr/local/include"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lgrpc -lgpr"
ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lgrpc -lgpr -lgrpc++"
else
ngx_feature_libs="-L/usr/local/lib -lgrpc -lgpr"
ngx_feature_libs="-L/usr/local/lib -lgrpc -lgpr -lgrpc++"
fi
autocppfeature
fi
if [ $ngx_found = yes ]; then
ngx_module_libs="$ngx_module_libs -lgrpc -lgpr"
ngx_module_libs="$ngx_module_libs -lgrpc -lgpr -lgrpc++"
fi
#ngx_module_libs="$ngx_module_libs -lupb -lz -lm -lrt -lssl -lcrypto"
ngx_module_libs="$ngx_module_libs -lz -lm -lrt -lssl -lcrypto"
. auto/module

View file

@ -11,7 +11,7 @@ extern "C" {
#include "trace_context.hpp"
#include "batch_exporter.hpp"
extern ngx_module_t gHttpModule;
extern ngx_module_t ngx_otel_module;
namespace {
@ -143,7 +143,7 @@ ngx_str_t toNgxStr(StrView str)
LocationConf* getLocationConf(ngx_http_request_t* r)
{
return (LocationConf*)ngx_http_get_module_loc_conf(r, gHttpModule);
return (LocationConf*)ngx_http_get_module_loc_conf(r, ngx_otel_module);
}
void cleanupOtelCtx(void* data)
@ -152,7 +152,7 @@ void cleanupOtelCtx(void* data)
OtelCtx* getOtelCtx(ngx_http_request_t* r)
{
auto ctx = (OtelCtx*)ngx_http_get_module_ctx(r, gHttpModule);
auto ctx = (OtelCtx*)ngx_http_get_module_ctx(r, ngx_otel_module);
// restore module context if it was reset by e.g. internal redirect
if (ctx == NULL && (r->internal || r->filter_finalize)) {
@ -160,7 +160,7 @@ OtelCtx* getOtelCtx(ngx_http_request_t* r)
for (auto cln = r->pool->cleanup; cln; cln = cln->next) {
if (cln->handler == cleanupOtelCtx) {
ctx = (OtelCtx*)cln->data;
ngx_http_set_ctx(r, ctx, gHttpModule);
ngx_http_set_ctx(r, ctx, ngx_otel_module);
break;
}
}
@ -181,7 +181,7 @@ OtelCtx* createOtelCtx(ngx_http_request_t* r)
storage->handler = cleanupOtelCtx;
auto ctx = new (storage->data) OtelCtx{};
ngx_http_set_ctx(r, ctx, gHttpModule);
ngx_http_set_ctx(r, ctx, ngx_otel_module);
return ctx;
}
@ -550,7 +550,7 @@ ngx_int_t initModule(ngx_conf_t* cf)
ngx_int_t initWorkerProcess(ngx_cycle_t* cycle)
{
auto mcf = (MainConf*)ngx_http_cycle_get_module_main_conf(
cycle, gHttpModule);
cycle, ngx_otel_module);
// no 'http' or 'otel_exporter' blocks
if (mcf == NULL || mcf->endpoint.len == 0) {
@ -584,7 +584,7 @@ ngx_int_t initWorkerProcess(ngx_cycle_t* cycle)
}
auto mcf = (MainConf*)ngx_http_cycle_get_module_main_conf(
ngx_cycle, gHttpModule);
ngx_cycle, ngx_otel_module);
ngx_add_timer(ev, mcf->interval);
};
@ -833,7 +833,7 @@ char* mergeLocationConf(ngx_conf_t* cf, void* parent, void* child)
conf->spanAttrs = prev->spanAttrs;
}
auto mcf = (MainConf*)ngx_http_conf_get_module_main_conf(cf, gHttpModule);
auto mcf = (MainConf*)ngx_http_conf_get_module_main_conf(cf, ngx_otel_module);
if (mcf->endpoint.len == 0 && conf->trace) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
@ -844,7 +844,7 @@ char* mergeLocationConf(ngx_conf_t* cf, void* parent, void* child)
return NGX_CONF_OK;
}
ngx_http_module_t gHttpModuleCtx = {
ngx_http_module_t ngx_otel_moduleCtx = {
addVariables, /* preconfiguration */
initModule, /* postconfiguration */
@ -860,9 +860,9 @@ ngx_http_module_t gHttpModuleCtx = {
}
ngx_module_t gHttpModule = {
ngx_module_t ngx_otel_module = {
NGX_MODULE_V1,
&gHttpModuleCtx, /* module context */
&ngx_otel_moduleCtx, /* module context */
gCommands, /* module directives */
NGX_HTTP_MODULE, /* module type */
NULL, /* init master */