pivotal-cf/pcf-metrics-trace-example-node

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

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Build Status

PCF Metrics Node Tracer Example

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.

Creating your own tracer apps

Most of the app code is standard nodejs application code independent of tracing.

To add tracing the following steps are neccesary:

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)

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.