A sample node js app that sends XHR to an OpenTelemetry instrumented java backend.
Prereq : need to have npm, java and maven installed
This starts a test nodejs app on localhost:1234 with the opentelemetry browser instrumentation. For now we are only testing auto w3c trace context injection for xml http request. (auto injection works, but it only injects traceparent
header, what we want is our FS uid/page url as tracestate
header. Currenly only hard coded in the javascript that makes the call)
git clone https://github.com/patsonluk/opentelemetry-playground.git
cd opentelemetry-playground
npm install --save @opentelemetry/api @opentelemetry/sdk-trace-web @opentelemetry/instrumentation-document-load @opentelemetry/context-zone @opentelemetry/instrumentation-xml-http-request
npx parcel index.html
- In another terminal,
cd jetty-helloworld-webapp
MAVEN_OPTS="-javaagent:../opentelemetry-javaagent.jar" mvn jetty:run-war -Djetty.port=9999
- A java app server should be bound to localhost:9999. There's only one endpoint that would trigger a DB read and a test exception
localhost:9999/test-servlet
ℹ️ If using the test Java agent exporter below, then start the java app with this instead MAVEN_OPTS="-javaagent:../opentelemetry-javaagent.jar -Dotel.traces.exporter=fullstory -Dotel.javaagent.extensions=../fs-opentelemetry-exporter/target/fs-opentelemetry-exporter-1.0-SNAPSHOT-jar-with-dependencies.jar -Dotel.exporter.fullstory.api-key=<staging API key>" mvn jetty:run-war -Djetty.port=9999
Follow this https://github.com/patsonluk/opentelemetry-collector/blob/main/README.md
This is NOT going to be our final approach, but adding a java agent exporter for quick test. We probably want to setup an Otel collector and provide our exporter implementation so we are not tied to any server language/agent. https://opentelemetry.io/docs/collector/
cd fs-opentelemetry-exporter
mvn clean package
- This builds our exporter in
target/fs-opentelemetry-exporter-1.0-SNAPSHOT-jar-with-dependencies.jar
ℹ️ This used to be 8080 but it appears to conflict with some ports for FS service restarts
At this point you should have 2 apps running, the localhost:1234 should have both Fullstory recording and OT instrumetnation enabled. And the localhost:9999 should have OT java agent instrumentation.
Visit localhost:1234 with the developer tool in browser, goto the network tab, click on the Click me
button on the page. You should observe an outbound xml http call to localhost:9999/test-servlet. Inspect the request header, you should see the traceparent
being injected by the OT instrumentation, and tracestate
(not injected by OT now, but ideally it should!) with FS identities
It should have 500 response code, as localhost:9999/test-servlet simulates Db reads and unhandled exception.
Now goto the corresponding FS account on staging, we should be able to see the FS session and some server events in there. there could be time drift and throttling/quota issue