Skip to content
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
2 changes: 2 additions & 0 deletions instrumentation/otel-webserver-module/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Monitoring individual modules is crucial to the instrumentation of Apache web se
|*ApacheModuleSegmentType* | | OPTIONAL: Specify the string (FIRST/LAST/CUSTOM) to be filtered for Span Name Creation|
|*ApacheModuleSegmentParameter* | | OPTIONAL: Specify the segment count or segment numbers that you want to display for Span Creation|
|*ApacheModuleOtelExporterHeaders* | | OPTIONAL: OTEL Exporter header info or Metadata like API key for OTLP endpoint. a list of key value pairs, and these are expected to be represented in a format matching to the W3C Correlation-Context, except that additional semi-colon delimited metadata is not supported, i.e.: key1=value1,key2=value2. |
|*ApacheModuleOtelExporterOtlpProtocol* | http/protobuf | OPTIONAL: OTLP export protocol. Supported values are "grpc", "http/protobuf", and "http/json". Can also be set via OTEL_EXPORTER_OTLP_TRACES_PROTOCOL or OTEL_EXPORTER_OTLP_PROTOCOL environment variables. |

A sample configuration is mentioned in [opentelemetry_module.conf](https://github.com/open-telemetry/opentelemetry-cpp-contrib/blob/main/instrumentation/otel-webserver-module/opentelemetry_module.conf)

Expand Down Expand Up @@ -176,6 +177,7 @@ Currently, Nginx Webserver module monitores some fixed set of modules, which get
|*NginxModuleRequestHeaders* | | OPTIONAL: Specify the request headers to be captured in the span attributes. The headers are Case-Sensitive and should be comma-separated. e.g.```NginxModuleRequestHeaders Accept-Charset,Accept-Encoding,User-Agent;```|
|*NginxModuleResponseHeaders* | | OPTIONAL: Specify the response headers to be captured in the span attributes. The headers are Case-Sensitive and should be comma-separated. e.g.```NginxModuleResponseHeaders Content-Length,Content-Type;```|
|*NginxModuleOtelExporterOtlpHeaders* | | OPTIONAL: OTEL exporter headers like Meta data related exposrted end point. a list of key value pairs, and these are expected to be represented in a format matching to the W3C Correlation-Context, except that additional semi-colon delimited metadata is not supported, i.e.: key1=value1,key2=value2.|
|*NginxModuleOtelExporterOtlpProtocol* | http/protobuf | OPTIONAL: OTLP export protocol. Supported values are "grpc", "http/protobuf", and "http/json". Can also be set via OTEL_EXPORTER_OTLP_TRACES_PROTOCOL or OTEL_EXPORTER_OTLP_PROTOCOL environment variables.|
|*NginxModuleTrustIncomingSpans* | ON | OPTIONAL: Specify if you want to correlate Nginx instrumented traces and spans with incoming requests.|
|*NginxModuleAttributes* | | OPTIONAL: Can be used to pass additionalccustom attributes to the span, nginx variables are also supported. All elements must be separated by a space, and different attribute key value pairs must be separated by a comma( even the comma needs to be separated by space). e.g. ```NginxModuleAttributes Key1 Value1 , Key2 $request_uri;``` |
|*NginxModuleIgnorePaths* | | OPTIONAL: Request URIs matching the Regex will not be monitored. Multiple space separated Regex can be provided( `'\'` symbol needs to be used carefully, Nginx treats `'\'` as a escape sequence, thus if the Regex sequence contains a `'\'`, it need to be replaced by `'\\'`, likewise if sequence contains `'\\'`, it need to be written as `'\\\\'` e.g. `.*\.html` -> `.*\\.html` ) e.g. ```NginxModuleIgnorePaths .*\\.html /test_.*;```|
Expand Down
2 changes: 2 additions & 0 deletions instrumentation/otel-webserver-module/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ task stageLibrary(type: Copy) {
from("${modDepDir}/opentelemetry/${cppSDKVersion}/lib/libopentelemetry_otlp_recordable.so") { it.into "sdk_lib/lib" }
from("${modDepDir}/opentelemetry/${cppSDKVersion}/lib/libopentelemetry_exporter_ostream_span.so") { it.into "sdk_lib/lib" }
from("${modDepDir}/opentelemetry/${cppSDKVersion}/lib/libopentelemetry_exporter_otlp_grpc.so") { it.into "sdk_lib/lib" }
from("${modDepDir}/opentelemetry/${cppSDKVersion}/lib/libopentelemetry_exporter_otlp_http.so") { it.into "sdk_lib/lib" }
from("${modDepDir}/opentelemetry/${cppSDKVersion}/lib/libopentelemetry_http_client_curl.so") { it.into "sdk_lib/lib" }
from("dist/opentelemetry_sdk_log4cxx.xml.template") { it.into "conf" }
from("dist/install.${scriptExt}") { it.fileMode 0700 }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ NginxModuleEnabled ON;
#NginxModule Otel Exporter details
NginxModuleOtelSpanExporter otlp;
NginxModuleOtelExporterEndpoint docker.for.mac.localhost:4317;
#NginxModuleOtelExporterOtlpProtocol http/protobuf;
#NginxModuleOtelExporterOtlpHeaders Authorization=AuthorizationToken;
# SSL Certificates
#NginxModuleOtelSslEnabled ON
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class otel_cfg
const char* getOtelExporterOtlpHeaders() { return otelExporterOtlpHeaders; }
int otelExporterOtlpHeadersInitialized() { return otelExporterOtlpHeaders_initialized; }

const char* getOtelExporterOtlpProtocol() { return otelExporterOtlpProtocol; }
int otelExporterOtlpProtocolInitialized() { return otelExporterOtlpProtocol_initialized; }

int getOtelSslEnabled() { return otelSslEnabled; }
int getOtelSslEnabledInitialized() { return otelSslEnabled_initialized; }

Expand Down Expand Up @@ -129,6 +132,9 @@ class otel_cfg
const char *otelExporterOtlpHeaders; // OPTIONAL: AppDynamics Custom metadata for OTEL Exporter EX: OTEL_EXPORTER_OTLP_HEADERS="api-key=key,other-config-value=value"
int otelExporterOtlpHeaders_initialized;

const char *otelExporterOtlpProtocol; // OPTIONAL: OTLP export protocol: grpc, http/protobuf, http/json (default: http/protobuf)
int otelExporterOtlpProtocol_initialized;

int otelSslEnabled; // OPTIONAL: Decision whether connection to the Exporter endpoint is secured
int otelSslEnabled_initialized;

Expand Down Expand Up @@ -231,6 +237,7 @@ class ApacheConfigHandlers
static const char* otel_set_otelExporterType(cmd_parms *cmd, void *conf, const char *arg);
static const char* otel_set_otelExporterEndpoint(cmd_parms *cmd, void *conf, const char *arg);
static const char* otel_set_otelExporterOtlpHeaders(cmd_parms *cmd, void *conf, const char *arg);
static const char* otel_set_otelExporterOtlpProtocol(cmd_parms *cmd, void *conf, const char *arg);
static const char* otel_set_otelSslEnabled(cmd_parms *cmd, void *conf, const char *arg);
static const char* otel_set_otelSslCertificatePath(cmd_parms *cmd, void *conf, const char *arg);
static const char* otel_set_otelProcessorType(cmd_parms *cmd, void *conf, const char *arg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ApacheHooks
static const char* OTEL_INTERACTION_HANDLE_KEY;
static const char* OTEL_REQ_HANDLE_KEY;
static const int LOWEST_HTTP_ERROR_CODE = 400;
static const int CONFIG_COUNT = 17; // Number of key value pairs in config
static const int CONFIG_COUNT = 18; // Number of key value pairs in config
static const std::initializer_list<const char*> httpHeaders;
static void registerHooks(apr_pool_t *p);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#define OTEL_SDK_ENV_OTEL_EXPORTER_TYPE "OTEL_SDK_ENV_OTEL_EXPORTER_TYPE"
#define OTEL_SDK_ENV_OTEL_EXPORTER_ENDPOINT "OTEL_SDK_ENV_OTEL_EXPORTER_ENDPOINT" /*required*/
#define OTEL_SDK_ENV_OTEL_EXPORTER_OTLPHEADERS "OTEL_SDK_ENV_OTEL_EXPORTER_OTLPHEADERS" /*optional*/
#define OTEL_SDK_ENV_OTEL_EXPORTER_OTLP_PROTOCOL "OTEL_SDK_ENV_OTEL_EXPORTER_OTLP_PROTOCOL" /*optional: grpc, http/protobuf, http/json*/
#define OTEL_SDK_ENV_OTEL_SSL_ENABLED "OTEL_SDK_ENV_OTEL_SSL_ENABLED" /*optional*/
#define OTEL_SDK_ENV_OTEL_SSL_CERTIFICATE_PATH "OTEL_SDK_ENV_OTEL_SSL_CERTIFICATE_PATH" /*optional*/
#define OTEL_SDK_ENV_OTEL_PROCESSOR_TYPE "OTEL_SDK_ENV_OTEL_PROCESSOR_TYPE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class TenantConfig
const std::string& getOtelExporterType() const {return otelExporterType;}
const std::string& getOtelExporterEndpoint() const {return otelExporterEndpoint;}
const std::string& getOtelExporterOtlpHeaders() const {return otelExporterOtlpHeaders;}
const std::string& getOtelExporterOtlpProtocol() const {return otelExporterOtlpProtocol;}
const std::string& getOtelProcessorType() const {return otelProcessorType;}
const std::string& getOtelPropagatorType() const {return otelPropagatorType;}
const unsigned getOtelMaxQueueSize() const {return otelMaxQueueSize;}
Expand All @@ -64,6 +65,7 @@ class TenantConfig
void setOtelExporterType(const std::string& otelExporterType) { this->otelExporterType = otelExporterType; }
void setOtelExporterEndpoint(const std::string& otelExporterEndpoint) { this->otelExporterEndpoint = otelExporterEndpoint; }
void setOtelExporterOtlpHeaders(const std::string& otelExporterOtlpHeaders) { this->otelExporterOtlpHeaders = otelExporterOtlpHeaders; }
void setOtelExporterOtlpProtocol(const std::string& otelExporterOtlpProtocol) { this->otelExporterOtlpProtocol = otelExporterOtlpProtocol; }
void setOtelProcessorType(const std::string& otelProcessorType) { this->otelProcessorType = otelProcessorType; }
void setOtelPropagatorType(const std::string& otelPropagatorType) { this->otelPropagatorType = otelPropagatorType; }
void setOtelMaxQueueSize(const unsigned int otelMaxQueueSize) { this->otelMaxQueueSize = otelMaxQueueSize; }
Expand All @@ -85,6 +87,7 @@ class TenantConfig
std::string otelExporterType;
std::string otelExporterEndpoint;
std::string otelExporterOtlpHeaders;
std::string otelExporterOtlpProtocol;
bool otelSslEnabled;
std::string otelSslCertPath;
std::string otelPropagatorType;
Expand All @@ -110,6 +113,7 @@ inline std::ostream& operator<< (std::ostream &os, const otel::core::TenantConfi
<< "\n OtelLibraryVersion " << config.getOtelLibraryVersion()
<< "\n OtelExporterType " << config.getOtelExporterType()
<< "\n OtelExporterEndpoint " << config.getOtelExporterEndpoint()
<< "\n OtelExporterOtlpProtocol " << config.getOtelExporterOtlpProtocol()
<< "\n OtelProcessorType " << config.getOtelProcessorType()
<< "\n OtelPropagatorType " << config.getOtelPropagatorType()
<< "\n OtelSamplerType " << config.getOtelSamplerType()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ LoadFile /opt/opentelemetry-webserver-sdk/sdk_lib/lib/libopentelemetry_trace.so
LoadFile /opt/opentelemetry-webserver-sdk/sdk_lib/lib/libopentelemetry_otlp_recordable.so
LoadFile /opt/opentelemetry-webserver-sdk/sdk_lib/lib/libopentelemetry_exporter_ostream_span.so
LoadFile /opt/opentelemetry-webserver-sdk/sdk_lib/lib/libopentelemetry_exporter_otlp_grpc.so
LoadFile /opt/opentelemetry-webserver-sdk/sdk_lib/lib/libopentelemetry_exporter_otlp_http.so
LoadFile /opt/opentelemetry-webserver-sdk/sdk_lib/lib/libopentelemetry_http_client_curl.so

#Load the ApacheModule SDK
LoadFile /opt/opentelemetry-webserver-sdk/sdk_lib/lib/libopentelemetry_webserver_sdk.so
Expand All @@ -14,6 +16,7 @@ ApacheModuleEnabled ON
#ApacheModule Otel Exporter details
ApacheModuleOtelSpanExporter otlp
ApacheModuleOtelExporterEndpoint collector:4317
#ApacheModuleOtelExporterOtlpProtocol http/protobuf
#ApacheModuleOtelExporterHeaders api-key=abc123

# SSL Certificates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ const char* ApacheConfigHandlers::otel_set_otelExporterOtlpHeaders(cmd_parms *cm
return helperChar(cmd, cfg, arg, cfg->otelExporterOtlpHeaders, cfg->otelExporterOtlpHeaders_initialized, "otel_set_otelExporterOtlpHeaders");
}

// char *otelExporterOtlpProtocol;
// int otelExporterOtlpProtocol_initialized;
const char* ApacheConfigHandlers::otel_set_otelExporterOtlpProtocol(cmd_parms *cmd, void *conf, const char *arg)
{
otel_cfg* cfg = (otel_cfg*) conf;
return helperChar(cmd, cfg, arg, cfg->otelExporterOtlpProtocol, cfg->otelExporterOtlpProtocol_initialized, "otel_set_otelExporterOtlpProtocol");
}

// char *otelSslEnabled;
// int otelSslEnabled_initialized;
const char* ApacheConfigHandlers::otel_set_otelSslEnabled(cmd_parms *cmd, void *conf, const char *arg)
Expand Down Expand Up @@ -444,6 +452,10 @@ void otel_cfg::init()
otelExporterOtlpHeaders = "";
otelExporterOtlpHeaders_initialized = 0;

// otelExporterOtlpProtocol Optional: OTLP export protocol: grpc, http/protobuf, http/json
otelExporterOtlpProtocol = "";
otelExporterOtlpProtocol_initialized = 0;

// otelSslEnabled OPTIONAL: Decides whether the connection to the endpoint is secured
otelSslEnabled = 0;
otelSslEnabled_initialized = 0;
Expand Down Expand Up @@ -657,6 +669,11 @@ void* ApacheConfigHandlers::otel_merge_dir_config(apr_pool_t* p, void* parent_co
apr_pstrdup(p, nconf->otelSslCertificatePath) : apr_pstrdup(p, pconf->otelSslCertificatePath);
merged_config->otelSslCertificatePath_initialized = 1;

// otelExporterOtlpProtocol OPTIONAL: OTLP export protocol: grpc, http/protobuf, http/json
merged_config->otelExporterOtlpProtocol = nconf->otelExporterOtlpProtocol_initialized ?
apr_pstrdup(p, nconf->otelExporterOtlpProtocol) : apr_pstrdup(p, pconf->otelExporterOtlpProtocol);
merged_config->otelExporterOtlpProtocol_initialized = 1;

// otelExporterType OPTIONAL: Type of exporter to be configured in TracerProvider of OTel SDK embedded into Agent
merged_config->otelExporterType = nconf->otelExporterType_initialized ?
apr_pstrdup(p, nconf->otelExporterType) : apr_pstrdup(p, pconf->otelExporterType);
Expand Down Expand Up @@ -786,6 +803,9 @@ otel_cfg* ApacheConfigHandlers::getProcessConfig(const request_rec* r)
process_cfg->otelExporterOtlpHeaders = apr_pstrdup(r->server->process->pool, our_config->otelExporterOtlpHeaders);
process_cfg->otelExporterOtlpHeaders_initialized = our_config->otelExporterOtlpHeaders_initialized;

process_cfg->otelExporterOtlpProtocol = apr_pstrdup(r->server->process->pool, our_config->otelExporterOtlpProtocol);
process_cfg->otelExporterOtlpProtocol_initialized = our_config->otelExporterOtlpProtocol_initialized;

process_cfg->otelSslEnabled = our_config->otelSslEnabled;
process_cfg->otelSslEnabled_initialized = our_config->otelSslEnabled_initialized;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,11 +426,16 @@ bool ApacheHooks::initialize_opentelemetry(const request_rec *r)
env_config[ix].value = our_config->getSegmentParameter();
++ix;

// Segment Parameter
// OTLP Headers
env_config[ix].name = OTEL_SDK_ENV_OTEL_EXPORTER_OTLPHEADERS;
env_config[ix].value = our_config->getOtelExporterOtlpHeaders();
++ix;

// OTLP Protocol
env_config[ix].name = OTEL_SDK_ENV_OTEL_EXPORTER_OTLP_PROTOCOL;
env_config[ix].value = our_config->getOtelExporterOtlpProtocol();
++ix;

// !!!
// Remember to update the apr_pcalloc call size if we add another parameter to the input array!
// !!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ static const command_rec otel_cmds[] =
NULL,
OR_ALL,
"AppDynamics Otel export Headers key value pairs"),
AP_INIT_TAKE1(
"apacheModuleOtelExporterOtlpProtocol",
(CMD_HAND_TYPE)ApacheConfigHandlers::otel_set_otelExporterOtlpProtocol,
NULL,
OR_ALL,
"OTLP export protocol: grpc, http/protobuf, or http/json (default: http/protobuf)"),
AP_INIT_TAKE1(
"apacheModuleOtelSslEnabled",
(CMD_HAND_TYPE)ApacheConfigHandlers::otel_set_otelSslEnabled,
Expand Down
2 changes: 2 additions & 0 deletions instrumentation/otel-webserver-module/src/build.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
'$(ANSDK_DIR)/opentelemetry/$(CPP_SDK_VERSION)/lib/libopentelemetry_otlp_recordable.so',
'$(ANSDK_DIR)/opentelemetry/$(CPP_SDK_VERSION)/lib/libopentelemetry_exporter_ostream_span.so',
'$(ANSDK_DIR)/opentelemetry/$(CPP_SDK_VERSION)/lib/libopentelemetry_exporter_otlp_grpc.so',
'$(ANSDK_DIR)/opentelemetry/$(CPP_SDK_VERSION)/lib/libopentelemetry_exporter_otlp_http.so',
'$(ANSDK_DIR)/opentelemetry/$(CPP_SDK_VERSION)/lib/libopentelemetry_http_client_curl.so',
'$(BOOST_LIB)',
'$(LINKER_FLAGS)',
'$(LIBRARY_FLAGS)',
Expand Down
15 changes: 15 additions & 0 deletions instrumentation/otel-webserver-module/src/core/api/ApiUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ OTEL_SDK_STATUS_CODE ApiUtils::ReadSettingsFromReader(
std::string otelExporterType;
std::string otelExporterEndpoint;
std::string otelExporterOtlpHeaders;
std::string otelExporterOtlpProtocol;
bool otelSslEnabled;
std::string otelSslCertPath;
std::string otelLibraryName;
Expand Down Expand Up @@ -263,13 +264,27 @@ OTEL_SDK_STATUS_CODE ApiUtils::ReadSettingsFromReader(
reader.ReadOptional(
std::string(OTEL_SDK_ENV_OTEL_EXPORTER_OTLPHEADERS), otelExporterOtlpHeaders);

reader.ReadOptional(
std::string(OTEL_SDK_ENV_OTEL_EXPORTER_OTLP_PROTOCOL), otelExporterOtlpProtocol);

// Fall back to standard OTel environment variable if not set via module config
if (otelExporterOtlpProtocol.empty()) {
char* envProtocol = getenv("OTEL_EXPORTER_OTLP_TRACES_PROTOCOL");
if (!envProtocol) {
envProtocol = getenv("OTEL_EXPORTER_OTLP_PROTOCOL");
}
if (envProtocol) {
otelExporterOtlpProtocol = envProtocol;
}
}

tenantConfig.setServiceNamespace(serviceNamespace);
tenantConfig.setServiceName(serviceName);
tenantConfig.setServiceInstanceId(serviceInstanceId);
tenantConfig.setOtelExporterType(otelExporterType);
tenantConfig.setOtelExporterEndpoint(otelExporterEndpoint);
tenantConfig.setOtelExporterOtlpHeaders(otelExporterOtlpHeaders);
tenantConfig.setOtelExporterOtlpProtocol(otelExporterOtlpProtocol);
tenantConfig.setOtelLibraryName(otelLibraryName);
tenantConfig.setOtelProcessorType(otelProcessorType);
tenantConfig.setOtelPropagatorType(otelPropagatorType);
Expand Down
Loading
Loading