Skip to content

Commit

Permalink
Web engine (#217)
Browse files Browse the repository at this point in the history
* Changing to webEngine

* Removing error

* Adding CPP

* Adding Otel CPP Version

* Rectifying TestCase

* cpp add

* changing to cpp
  • Loading branch information
kpratyus authored Dec 5, 2022
1 parent 7d108cd commit 79138f3
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 7 deletions.
3 changes: 3 additions & 0 deletions instrumentation/otel-webserver-module/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ project.ext {
props.load(new FileInputStream(file("version.properties")))
moduleVersion = props.get("server-module-version")
moduleRelease = props.get("release")
cppSDKVersion = props.get("CPP-SDK-version")
moduleName = "WebServer Module"
buildType = "Release Build"
fullVersion = "${moduleName} ${moduleVersion} ${moduleRelease} ${headSHA1}: ${buildType}"
Expand Down Expand Up @@ -87,6 +88,7 @@ task generateModuleVersionHeader(type: Copy) {
headSHA1: headSHA1,
moduleVersion: moduleVersion,
moduleRelease: moduleRelease,
cppSDKVersion: cppSDKVersion,
fullVersion: fullVersion)
}

Expand All @@ -100,6 +102,7 @@ task generateVersionFile(type: Copy) {
headSHA1: headSHA1,
moduleVersion: moduleVersion,
moduleRelease: moduleRelease,
cppSDKVersion: cppSDKVersion,
fullVersion: fullVersion)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ namespace sdkwrapper {
const std::string kServiceName = "service.name";
const std::string kServiceNamespace = "service.namespace";
const std::string kServiceInstanceId = "service.instance.id";
const std::string kOtelLibraryName = "telemetry.sdk.language";
const std::string kOtelLibraryVersion = "telemetry.sdk.version";
const std::string kOtelWebEngineName = "webengine.name";
const std::string kOtelWebEngineVersion = "webengine.version";
const std::string kOtelWebEngineDescription = "webengine.description";
const std::string kHttpErrorCode = "HTTP ERROR CODE:";
const std::string kAttrHTTPServerName = "http.server_name";
const std::string kAttrHTTPMethod = "http.method";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,17 @@ SdkHelperFactory::SdkHelperFactory(

// NOTE : resource attribute values are nostd::variant and so we need to explicitely set it to std::string
std::string libraryVersion = MODULE_VERSION;
std::string cppSDKVersion = CPP_SDK_VERSION;

// NOTE : InstrumentationLibrary code is incomplete for the otlp exporter in sdk.
// So, we need to pass libraryName and libraryVersion as resource attributes.
// Ref : https://github.com/open-telemetry/opentelemetry-cpp/blob/main/exporters/otlp/src/otlp_recordable.cc
attributes[kOtelLibraryName] = config->getOtelLibraryName();
attributes[kOtelLibraryVersion] = libraryVersion;

//Library was changed to webengine to comply with specs https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/webengine.md
attributes[kOtelWebEngineName] = config->getOtelLibraryName();
//attributes[kOtelWebEngineVersion] = libraryVersion;

//attributes[kOtelWebEngineDescription] = config->getOtelLibraryName() + " Instrumentation";

auto exporter = GetExporter(config);
auto processor = GetSpanProcessor(config, std::move(exporter));
Expand All @@ -84,9 +89,9 @@ SdkHelperFactory::SdkHelperFactory(
std::move(sampler)
));

mTracer = mTracerProvider->GetTracer(config->getOtelLibraryName(), libraryVersion);
mTracer = mTracerProvider->GetTracer("cpp", cppSDKVersion);
LOG4CXX_INFO(mLogger,
"Tracer created with LibraryName: " << config->getOtelLibraryName() <<
"Tracer created with LibraryName: " << "cpp" <<
" and LibraryVersion " << libraryVersion);

// Adding trace propagator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
#define MODULE_VERSION_ "$moduleVersion"
#define RELEASE_ "$moduleRelease"
#define FULL_MODULE_VERSION_ "$fullVersion"
#define CPP_SDK_VERSION_ "$cppSDKVersion"

static const char MODULE_VERSION[] =
MODULE_VERSION_ RELEASE_ MODULE_SHA1;

static const char FULL_MODULE_VERSION[] =
FULL_MODULE_VERSION_;

static const char CPP_SDK_VERSION[] =
CPP_SDK_VERSION_;

#endif

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void verifyAllTraces() {
}
Assert.assertTrue(span.getJSONObject("tags").get("service.namespace").toString().contentEquals("sample_namespace"));
Assert.assertTrue(span.getJSONObject("localEndpoint").get("serviceName").toString().contentEquals("demoservice"));
Assert.assertTrue(span.getJSONObject("tags").get("telemetry.sdk.language").toString().contentEquals("Apache"));
Assert.assertTrue(span.getJSONObject("tags").get("telemetry.sdk.language").toString().contentEquals("cpp"));
}
}

Expand Down
1 change: 1 addition & 0 deletions instrumentation/otel-webserver-module/version.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
server-module-version=1.0.0
release=GA
nginxSupportedVersions=1.22.0,1.23.0,1.23.1
CPP-SDK-version=1.2.0

0 comments on commit 79138f3

Please sign in to comment.