Giter Club home page Giter Club logo

lightstep-ot-simple-sample's Introduction

OpenTracing Browser to Backend Sample

This app is a simple Express app which demonstrates how distributed tracing works using the LightStep Javascript Tracer and OpenTracing instrumentation.

Design

The application defaults to hosting a single user-facing page at localhost:3000. App structure is generated automatically by Express Generator. There is an additional route at localhost:3000/XHR which accepts GET requests and returns a link to the trace for that request in LightStep. The "front-end" includes the minified version of the LightStep Javascript Tracer, and is configured to automatically instrument all XHR requests. The "back-end" utilizes the NPM version of the LightStep Javascript Tracer, and is configured to create a child span for the inbound XHR requests from the "front-end". The OpenTracing SpanContext is propagated using HTTP headers.

Getting Started

You will need to include your LightStep access token before starting the service.

app.js

opentracing.initGlobalTracer(new lightstep.Tracer({
  access_token   : 'access-token-here',
  component_name : 'node-training',
  verbosity : 3
}));

views/index.ejs

<head>
    <title><%= title %></title>
    <link rel='stylesheet' href='/stylesheets/style.css' />
    <script src="/javascripts/opentracing-browser.min.js"></script>
    <script src="/javascripts/lightstep-tracer.min.js" data-init_global_tracer="true" data-access_token="access-token-here" data-component_name="browser-training" data-verbosity=3 data-instrument_page_load="false" data-xhr_instrumentation="true"></script>
  </head>

Starting the service Optional: Nodemon is included in the package.json and nodemon start can be used in substitution for npm start below.

  1. git clone this repo into your workspace
  2. Include the LightStep access token in the two files referenced above
  3. Optional: remove the commented span.setTag line in index.js and include an identifier in the value to make it easy to search for a trace later in LightStep
  4. Install the dependnencies: npm install
  5. Start the service: npm start

lightstep-ot-simple-sample's People

Contributors

parker-edwards avatar

Watchers

James Cloos avatar

lightstep-ot-simple-sample's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.