Giter VIP home page Giter VIP logo

xk6-distributed-tracing's Introduction

xk6-distributed-tracing

⚠️ This is a proof of concept ⚠️
It won't be supported by the k6 team.
It may also break in the future as xk6 evolves.

This extension adds distributed tracing support to k6! That means, that if you're testing a system that is instrumented, you can use this extension to start the traces on k6.

It is implemented using the xk6 extension system.

Example trace Trace started on k6

Features

The extension is built on top of OpenTelemetry, and gives k6:

  • An instrumented HTTP client.
  • The hability to:
    • Export spans (your tracing data).
      • Supported exporters: jaeger, zipkin, otlp, noop, stdout
    • Propagate context.
      • Supported protocols: w3c, b3, jaeger, ot

Build

To build a k6 binary with this extension, first ensure you have the prerequisites:

Then:

  1. Download xk6:
$ go install go.k6.io/xk6/cmd/xk6@latest
  1. Build the binary:
$ xk6 build --with github.com/k6io/xk6-distributed-tracing@latest

Example

import tracing, { Http } from 'k6/x/tracing';
import { sleep } from 'k6';

export let options = {
  vus: 1,
  duration: '10s',
};

export function setup() {
  console.log(`Running xk6-distributed-tracing v${tracing.version}`, tracing);
}

export default function() {
  const http = new Http({
    exporter: "jaeger",
    propagator: "w3c",
    endpoint: "http://localhost:14268/api/traces"
  });
  const r = http.get('https://test-api.k6.io');
  console.log(`trace_id=${r.trace_id}`);
  sleep(1);
}

export function teardown(){
  // Cleanly shutdown and flush telemetry when k6 exits.
  tracing.shutdown();
}

Result output:

$ ./k6 run script.js

          /\      |‾‾| /‾‾/   /‾‾/   
     /\  /  \     |  |/  /   /  /    
    /  \/    \    |     (   /   ‾‾\  
   /          \   |  |\  \ |  (‾)  | 
  / __________ \  |__| \__\ \_____/ .io

  execution: local
     script: script.js
     output: -

  scenarios: (100.00%) 1 scenario, 1 max VUs, 40s max duration (incl. graceful stop):
           * default: 1 looping VUs for 10s (gracefulStop: 30s)

INFO[0000] Running xk6-distributed-tracing v0.0.2  source=console                
INFO[0000] trace-id=743fff0b96778539acb7139e72ea1e33
INFO[0001] trace-id=365f4637a52526db1de2d30a5568ca3a
INFO[0002] trace-id=c49e1df945049c5c3c8b59acc84d7d3b
INFO[0003] trace-id=53e1937d56aa172b46d2310e3380dfe9
INFO[0004] trace-id=d61e8757d35c9ca1780b88977ac56d72
INFO[0005] trace-id=358e794ed636d268a918dcd2f3f9db0a
INFO[0006] trace-id=992a959e09ee84f3905a215bec8b53a0
INFO[0007] trace-id=aee11c64de11744ab5b66d5dd8ed361b
INFO[0008] trace-id=c4dc45d857e99ede2bb902666457239d
INFO[0009] trace-id=7623d10293d9f03c15deb8055935664e

running (10.1s), 0/1 VUs, 10 complete and 0 interrupted iterations
default ✓ [======================================] 1 VUs  10s

     █ setup

     data_received..............: 1.6 kB 156 B/s
     data_sent..................: 1.7 kB 165 B/s
     http_req_blocked...........: avg=223.43µs min=146.53µs med=217.39µs max=314.54µs p(90)=276.68µs p(95)=295.61µs
     http_req_connecting........: avg=137.18µs min=87.22µs  med=130.17µs max=196.38µs p(90)=184.38µs p(95)=190.38µs
     http_req_duration..........: avg=6.58ms   min=5.07ms   med=6.45ms   max=7.91ms   p(90)=7.83ms   p(95)=7.87ms  
     http_req_receiving.........: avg=187.27µs min=94.29µs  med=171.7µs  max=295.67µs p(90)=293.28µs p(95)=294.48µs
     http_req_sending...........: avg=128.07µs min=94.64µs  med=121.77µs max=175.65µs p(90)=160.41µs p(95)=168.03µs
     http_req_tls_handshaking...: avg=0s       min=0s       med=0s       max=0s       p(90)=0s       p(95)=0s      
     http_req_waiting...........: avg=6.27ms   min=4.83ms   med=6.13ms   max=7.64ms   p(90)=7.56ms   p(95)=7.6ms   
     http_reqs..................: 10     0.991797/s
     iteration_duration.........: avg=916.48ms min=65.67µs  med=1s       max=1s       p(90)=1s       p(95)=1s      
     iterations.................: 10     0.991797/s
     vus........................: 1      min=1 max=1
     vus_max....................: 1      min=1 max=1

xk6-distributed-tracing's People

Contributors

dgzlopes avatar mstoykov avatar olegbespalov avatar simskij avatar

Watchers

 avatar  avatar

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.