datadog

package module
v0.0.0-...-8930d5f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

README

xk6-datadog-api-client

This is a k6 extension using the xk6 system.

❗ This is a proof of concept, isn't supported by the k6 team, and may break in the future. USE AT YOUR OWN RISK!

Build

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

Then:

  1. Install xk6:
$ go install go.k6.io/xk6/cmd/xk6@latest
  1. Build the binary:
$ xk6 build --with github.com/medinae/xk6-datadog-api-client@latest

Example

import datadog from 'k6/x/datadog-api-client';

const client = datadog.newClient("<your-api-key>", "<your-app-key>");

export default function() {
    var trafficData = client.detTrafficData("vendor-search");

    console.log(`Global RPM is ${trafficData.globalRPM}`)
    console.log(`Max ratio is ${trafficData.maxRatio}`)

    Object.entries(trafficData.loadRatio).forEach(entry => {
        const [resource, ratio] = entry;
        console.log(`Ratio for resource ${resource} is ${ratio}`);
      });
}

Result output:

$ ./k6 run script.js

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

  execution: local
     script: ../example.js
     output: -

  scenarios: (100.00%) 1 scenario, 1 max VUs, 10m30s max duration (incl. graceful stop):
           * default: 1 iterations for each of 1 VUs (maxDuration: 10m0s, gracefulStop: 30s)

INFO[0001] service_ingest.kb.avg{availability-zone:us-east-1b} with 16 data points  source=console
INFO[0001] unit=KiB avg=358.32016603090034 min=0 max=497.97467041015625  source=console
INFO[0001] service_ingest.kb.avg{availability-zone:us-east-1a} with 16 data points  source=console
INFO[0001] unit=KiB avg=372.6228407504512 min=0 max=519.2804870605469  source=console
INFO[0001] service_ingest.kb.avg{availability-zone:us-east-1c} with 16 data points  source=console
INFO[0001] unit=KiB avg=258.3870323896408 min=0 max=548.156005859375  source=console
INFO[0001] docker.thread.count{*} with 179 data points   source=console
INFO[0001] unit=unknown avg=11.463663193997492 min=11.303571428571429 max=11.71875  source=console

running (00m00.9s), 0/1 VUs, 1 complete and 0 interrupted iterations
default ✓ [======================================] 1 VUs  00m00.9s/10m0s  1/1 iters, 1 per VU

    data_received........: 0 B 0 B/s
    data_sent............: 0 B 0 B/s
    iteration_duration...: avg=905.32ms min=905.32ms med=905.32ms max=905.32ms p(90)=905.32ms p(95)=905.32ms
    iterations...........: 1   1.080766/s

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the Datadog client wrapper.

func (*Client) GetTrafficData

func (c *Client) GetTrafficData(service string) TrafficStats

GetTrafficData queries and returns service traffic stats and distribution.

type Datadog

type Datadog struct {
}

Datadog is the k6 datadog extension.

func (*Datadog) NewClient

func (r *Datadog) NewClient(apiKey string, appKey string) *Client

NewClient creates a new Datadog client with the provided options.

type TrafficStats

type TrafficStats struct {
	GlobalRpm         uint
	MaxRatio          uint
	LoadRatio         map[string]uint
	TrafficTimeSeries []TrafficTimeSeries
}

TrafficStats is used to return the response to the user.

type TrafficTimeSeries

type TrafficTimeSeries struct {
	Resource   string
	TimeSeries []uint
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL