zipkin-instrumentation-vue-resource

Interceptor for vue-resource that instruments outgoing requests
1,952 8
Install
npm install zipkin-instrumentation-vue-resource
Latest Version:0.2.0
Vue:2
License:MIT
Last Updated:Feb 13, 2018
Links: GitHub  ·  npm
Maintainer: elgris

Zipkin instrumentation for vue-resource Build Status npm version

What?

An interceptor for vue-resource that instruments outgoing HTTP requests with Zipkin.

Why?

Sometimes tracing of your backend components is not enough, so you need to do some tracing on frontend side (part of End User Monitoring). This package helps to solve that problem for VueJS with Zipkin.

How?

... to install

npm install --save zipkin-instrumentation-vue-resource

... to add an interceptor

What you need to do is to initialise Zipkin Tracer, because the interceptor does not provide any default for that at the moment.

main.js may contain initialisation logic and may look like this:

// these imports are zipkin-specific
import {
  Tracer,
  BatchRecorder,
  ExplicitContext,
  jsonEncoder
} from 'zipkin'
import {HttpLogger} from 'zipkin-transport-http'
// and here the interceptor is imported
import {zipkinInterceptor} from 'zipkin-instrumentation-vue-resource'

const serviceName = 'myfancywebsite'

// this Tracer communicates to Zipkin through HTTP protocol
const tracer = new Tracer({
  ctxImpl: new ExplicitContext(),
  recorder: new BatchRecorder({
    logger: new HttpLogger({
      // take a look
      endpoint: window.location.protocol + '//' + window.location.host + '/zipkin',
      jsonEncoder: jsonEncoder.JSON_V2
    })
  }),
  localServiceName: serviceName
})

// and here is how the interceptor is created and added to vue-resource's chain
const interceptor = zipkinInterceptor({tracer, serviceName})
Vue.http.interceptors.push(interceptor)

... to send data to Zipkin

Your application can communicate to Zipkin through HTTP, you can do that using Webpack's proxy table. proxyTable in config/index.js may look like this:

  proxyTable: {
      '/zipkin': {
      target: process.env.ZIPKIN_ADDRESS || 'http://127.0.0.1:9411/api/v2/spans',
      pathRewrite: {
          '^/zipkin': ''
      },
      secure: false
      },      
  },

The piece of configuration above redirects all requests to /zipkin path (exactly what the interceptor uses in example above) to your actual Zipkin server running on 127.0.0.1:9411.

Related Packages

@fixwire/vue

Fixwire SDK for Vue: the errors Vue catches, with their component, and vue-route...

394 0
nuxt-frogger

Logging and tracing module for Nuxt applications

7,806 0
@fixwire/nuxt

Fixwire SDK for Nuxt: a module for the browser and the server, with Vue's and Ni...

394 0
@sigtrace/core

Client-side runtime tracer for SigTrace

3,074 3
autotel-web

Ultra-lightweight browser SDK for distributed tracing - propagates W3C tracepare...

8,621 8

Version History

Version Released Vue License
0.2.0 ^2.5.13 MIT
0.1.0 ^2.5.13 MIT