Name: pcf-metrics-trace-example-node
Owner: Pivotal Cloud Foundry
Description: null
Created: 2017-02-01 18:14:24.0
Updated: 2018-03-06 04:16:58.0
Pushed: 2018-02-07 21:14:53.0
Homepage: null
Size: 167
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
This is a nodejs repository with three apps: shopping-cart, orders, and payments. These apps use Zipkin to trace the calls between them. The traces can then be viewed in PCF-Metrics.
Most of the app code is standard nodejs application code independent of tracing.
To add tracing the following steps are neccesary:
rt express from 'express'
rt {expressMiddleware as zipkin} from 'zipkin-instrumentation-express';
const app = new Express();
const ctxImpl = new ExplicitContext(); const recorder = new ConsoleRecorder(); const tracer = new Tracer({ctxImpl, recorder});
app.use(zipkin({tracer, serviceName: 'my service'}));
strument http requests that use fetch. Install and use [zipkin-instrumentation-fetch](https://github.com/openzipkin/zipkin-js/tree/master/packages/zipkin-instrumentation-fetch).
nt Span Id will show up in the router logs even without this property.
sing the example apps
DEPLOY
se the script, you must login as a user that has the ability to assign space permissions and make spaces.
ill create a given shopping-cart, orders, and payments app that can be used to preview an example trace.
eploy, use the script `./scripts/deploy.sh`.
the `SUFFIX` ENV var to a unique identifier for your tracer applications.
For example
cf login SUFFIX=test ./scripts/deploy.sh
CURL APPS
the `/checkout` endpoint for the given shopping cart app.
For example
curl shopping-cart-test.cfapps.io/checkout
CLEANUP
leanup, use the script `./scripts/cleanup.sh`.
the `SUFFIX` ENV var to the same identifier used for deployment.
For example
cf login SUFFIX=test ./scripts/cleanup.sh
Viewing in PCF-Metrics
iew the trace in PCF-Metrics, go to the shopping-cart app in PCF-Metrics.
the log corresponding to the /checkout endpoint and click the 'View in Trace Explorer' icon.
For example
trics-trace-example](metrics-trace-example.png)