OCI/APM: Tracing a web app calling a service backed by a serverless function exposed through the APIGW


CONTEXT

Let F be a frontend, B a backend, R a recorder, A an APIGW deployment with a route and F a backend serverless function(Fn). A and B are implemented based on this code. F implemented based on this example. F exposed in APIGW as a route backed by function F

Here is the diagram of resources involved:

CONFIGURATION

Create an APM domain following this post

Grab the Data Upload Endpoint and the autogenerated_public_datakey for later:

Deploy the “Trace a function with APM and add custom child spans using Zipkin” function following instructions here and enable tracing as follows:

Modify the code of the recorder.js function and construct the zipkin endpoint with the values of Data Upload Endpoint and autogenerated_public_datakey to get something like this:

// Send spans to Zipkin asynchronously over HTTP
const zipkinBaseUrl = 'https://aaaa.....aapi.apm-agt.eu-frankfurt-1.oci.oraclecloud.com';

const httpLogger = new HttpLogger({
  endpoint: `${zipkinBaseUrl}/20200101/observations/public-span?dataFormat=zipkin&dataFormatVersion=2&dataKey=QMPW....3D`,
  jsonEncoder: JSON_V2
});

Expose Fn function in APIGW:

TRACING RESULTS

Following the screenshots of the traces generated when calling the different resources

/a request TO frontend

/b request TO frontend

/c request TO frontend

/s1 request to backend

/s2 request to backend

/f3 request to APIGW

CONCLUSION

Tracing capabilities in OCI can make your life easier when building apps distributed across several layers. Cloud native technologies help delivering business needs quicker and with less effort that traditional approaches, anyway tracing can be utilised in both cases.

That’s all, hope it helps! 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.