Skip to content

Update Pyroscope and Tempo instrumentation library versions #1929

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/sources/k6/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ cascade:
github_dir: /docs/sources/k6
replace_dir: docs/k6/
JSLIB_AWS_VERSION: 0.13.0
JSLIB_PYROSCOPE_VERSION: 1.0.2
JSLIB_TEMPO_VERSION: 1.0.1
versioned: true
versioned_next: true
---
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ This example demonstrates how to use the this library to instrument every HTTP r

```javascript
import { check } from 'k6';
import pyroscope from 'https://jslib.k6.io/http-instrumentation-pyroscope/1.0.1/index.js';
import pyroscope from 'https://jslib.k6.io/http-instrumentation-pyroscope/{{< param "JSLIB_PYROSCOPE_VERSION" >}}/index.js';
import http from 'k6/http';

// instrumentHTTP will ensure that all requests made by the http module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This example demonstrates how to instantiate a client and use it to instrument H

```javascript
import { check } from 'k6';
import pyroscope from 'https://jslib.k6.io/http-instrumentation-pyroscope/1.0.1/index.js';
import pyroscope from 'https://jslib.k6.io/http-instrumentation-pyroscope/{{< param "JSLIB_PYROSCOPE_VERSION" >}}/index.js';
import http from 'k6/http';

// Explicitly instantiating a Pyroscope client allows to distinguish
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ For details about propagation, refer to [About baggage header](https://grafana.c

## Parameters

| Name | Type | Description |
| :-------- | :--------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `generateHeaders` | `function(method, body, params) headersMap` | A function taking the request method, body and params and returning a map of headers that will be attached. By default adding baggage header as explained in the [about baggage header]((https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/http-instrumentation-pyroscope#about-baggage-header)) |
| Name | Type | Description |
| :---------------- | :------------------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `generateHeaders` | `function(method, body, params) headersMap` | A function taking the request method, body and params and returning a map of headers that will be attached. By default adding baggage header as explained in the [about baggage header](<(https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/http-instrumentation-pyroscope#about-baggage-header)>) |

## Example

Expand All @@ -28,7 +28,7 @@ This example demonstrates how to use the this library to instrument every HTTP r

```javascript
import { check } from 'k6';
import pyroscope from 'https://jslib.k6.io/http-instrumentation-pyroscope/1.0.1/index.js';
import pyroscope from 'https://jslib.k6.io/http-instrumentation-pyroscope/{{< param "JSLIB_PYROSCOPE_VERSION" >}}/index.js';
import http from 'k6/http';

// instrumentHTTP will ensure that all requests made by the `http` module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ weight: 04

{{< admonition type="note" >}}

The source code for this library can be found in the [grafana/jslib.k6.io](https://github.com/grafana/jslib.k6.io/tree/main/lib/http-instrumentation-tempo/1.0.0) GitHub repository.
The source code for this library can be found in the [grafana/jslib.k6.io](https://github.com/grafana/jslib.k6.io/tree/main/lib/http-instrumentation-tempo) GitHub repository.

{{< /admonition >}}

The `http-instrumentation-tempo` module allows you to _instrument_ HTTP requests so that they emit traces as the test runs. Use it to include a tracing context in HTTP requests, which can then be used by a tracing backend such as [Grafana Tempo](https://grafana.com/docs/grafana-cloud/testing/k6/analyze-results/integration-with-grafana-cloud-traces/).

## Migration from `k6/experimental/tracing`

This jslib is a drop in replacement, so all you need to migrate to it is to replace `'k6/experimental/tracing'` import with `'https://jslib.k6.io/http-instrumentation-tempo/1.0.0/index.js'`
This jslib is a drop in replacement, so all you need to migrate to it is to replace `'k6/experimental/tracing'` import with `'https://jslib.k6.io/http-instrumentation-tempo/{{< param "JSLIB_TEMPO_VERSION" >}}/index.js'`

## About trace contexts

Expand All @@ -42,7 +42,7 @@ This example demonstrates how to use the tracing API to instrument every HTTP re

```javascript
import { check } from 'k6';
import tempo from 'https://jslib.k6.io/http-instrumentation-tempo/1.0.0/index.js';
import tempo from 'https://jslib.k6.io/http-instrumentation-tempo/{{< param "JSLIB_TEMPO_VERSION" >}}/index.js';
import http from 'k6/http';

// instrumentHTTP will ensure that all requests made by the http module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This example demonstrates how to instantiate a tracing client and use it to inst

```javascript
import { check } from 'k6';
import tempo from 'https://jslib.k6.io/http-instrumentation-tempo/1.0.0/index.js';
import tempo from 'https://jslib.k6.io/http-instrumentation-tempo/{{< param "JSLIB_TEMPO_VERSION" >}}/index.js';
import http from 'k6/http';

// Explicitly instantiating a tempo client allows to distinguish
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ This example demonstrates how to call the `instrumentHTTP` function in the scrip

```javascript
import { check } from 'k6';
import tempo from 'https://jslib.k6.io/http-instrumentation-tempo/1.0.0/index.js';
import tempo from 'https://jslib.k6.io/http-instrumentation-tempo/{{< param "JSLIB_TEMPO_VERSION" >}}/index.js';
import http from 'k6/http';

// instrumentHTTP will ensure that all requests made by the http module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ This example demonstrates how to use the this library to instrument every HTTP r

```javascript
import { check } from 'k6';
import pyroscope from 'https://jslib.k6.io/http-instrumentation-pyroscope/1.0.1/index.js';
import pyroscope from 'https://jslib.k6.io/http-instrumentation-pyroscope/{{< param "JSLIB_PYROSCOPE_VERSION" >}}/index.js';
import http from 'k6/http';

// instrumentHTTP will ensure that all requests made by the http module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This example demonstrates how to instantiate a client and use it to instrument H

```javascript
import { check } from 'k6';
import pyroscope from 'https://jslib.k6.io/http-instrumentation-pyroscope/1.0.1/index.js';
import pyroscope from 'https://jslib.k6.io/http-instrumentation-pyroscope/{{< param "JSLIB_PYROSCOPE_VERSION" >}}/index.js';
import http from 'k6/http';

// Explicitly instantiating a Pyroscope client allows to distinguish
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ This example demonstrates how to use the this library to instrument every HTTP r

```javascript
import { check } from 'k6';
import pyroscope from 'https://jslib.k6.io/http-instrumentation-pyroscope/1.0.1/index.js';
import pyroscope from 'https://jslib.k6.io/http-instrumentation-pyroscope/{{< param "JSLIB_PYROSCOPE_VERSION" >}}/index.js';
import http from 'k6/http';

// instrumentHTTP will ensure that all requests made by the `http` module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ This example demonstrates how to use the tracing API to instrument every HTTP re

```javascript
import { check } from 'k6';
import tempo from 'https://jslib.k6.io/http-instrumentation-tempo/1.0.0/index.js';
import tempo from 'https://jslib.k6.io/http-instrumentation-tempo/{{< param "JSLIB_TEMPO_VERSION" >}}/index.js';
import http from 'k6/http';

// instrumentHTTP will ensure that all requests made by the http module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ This example demonstrates how to instantiate a tracing client and use it to inst

```javascript
import { check } from 'k6';
import tempo from 'https://jslib.k6.io/http-instrumentation-tempo/1.0.0/index.js';
import tempo from 'https://jslib.k6.io/http-instrumentation-tempo/{{< param "JSLIB_TEMPO_VERSION" >}}/index.js';
import http from 'k6/http';

// Explicitly instantiating a tempo client allows to distinguish
Expand Down Expand Up @@ -82,6 +82,6 @@ The following table lists the `Client` methods which have an equivalent in the s

`Client` instances support being reconfigured using the following API:

| Method | Description |
| :-------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Method | Description |
| :-------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Client.configure(options)` | Reconfigures the tracing client instance with the provided [`Options`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/http-instrumentation-tempo/options) |
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ From that point forward, all requests made by the HTTP module from that point fo

## Parameters

| Name | Type | Description |
| :-------- | :--------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Name | Type | Description |
| :-------- | :------------------------------------------------------------------------------------------------------------ | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `options` | [`Options`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/http-instrumentation-tempo/options) | Configures the tracing behavior with the provided [`Options`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/http-instrumentation-tempo/options) object. |

## Example
Expand All @@ -27,7 +27,7 @@ This example demonstrates how to call the `instrumentHTTP` function in the scrip

```javascript
import { check } from 'k6';
import tempo from 'https://jslib.k6.io/http-instrumentation-tempo/1.0.0/index.js';
import tempo from 'https://jslib.k6.io/http-instrumentation-tempo/{{< param "JSLIB_TEMPO_VERSION" >}}/index.js';
import http from 'k6/http';

// instrumentHTTP will ensure that all requests made by the http module
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
---
title: HTTP instrumentation for Pyroscope
menuTitle: http-instrumentation-pyroscope
description: "k6 Pyroscope instrumentation API"
description: 'k6 Pyroscope instrumentation API'
weight: 04
---

# HTTP instrumentation for Pyroscope


With jslib, you can _instrument_ HTTP requests in a way that lets you tag Grafana Cloud Profiles with relevant information generated from k6 tests.

## About baggage header

The _baggage header_ is a standardized HTTP header used to propagate distributed context. The [W3C specification](https://www.w3.org/TR/baggage/) goes into more detail on the specifics, but like many other headers, the baggage header is a list of key-value pairs.
The _baggage header_ is a standardized HTTP header used to propagate distributed context. The [W3C specification](https://www.w3.org/TR/baggage/) goes into more detail on the specifics, but like many other headers, the baggage header is a list of key-value pairs.

This module, by default, adds three key-value pairs:

1. Scenario name
2. Name of the request (URL if not set)
3. Value of `__ENV.K6_CLOUDRUN_TEST_RUN_ID`, which is set automatically in Grafana Cloud k6.


## API

| Class/Function | Description |
| :--------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------ |
| [instrumentHTTP](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/http-instrumentation-pyroscope/instrumenthttp) | Instruments the k6 http module with baggage header. |
| Class/Function | Description |
| :---------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------- |
| [instrumentHTTP](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/http-instrumentation-pyroscope/instrumenthttp) | Instruments the k6 http module with baggage header. |
| [Client](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/http-instrumentation-pyroscope/client) | Configurable Client that exposes instrumented HTTP operations. |

## Example
Expand All @@ -36,7 +34,7 @@ This example demonstrates how to use the this library to instrument every HTTP r

```javascript
import { check } from 'k6';
import pyroscope from 'https://jslib.k6.io/http-instrumentation-pyroscope/1.0.1/index.js';
import pyroscope from 'https://jslib.k6.io/http-instrumentation-pyroscope/{{< param "JSLIB_PYROSCOPE_VERSION" >}}/index.js';
import http from 'k6/http';

// instrumentHTTP will ensure that all requests made by the http module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This example demonstrates how to instantiate a client and use it to instrument H

```javascript
import { check } from 'k6';
import pyroscope from 'https://jslib.k6.io/http-instrumentation-pyroscope/1.0.1/index.js';
import pyroscope from 'https://jslib.k6.io/http-instrumentation-pyroscope/{{< param "JSLIB_PYROSCOPE_VERSION" >}}/index.js';
import http from 'k6/http';

// Explicitly instantiating a Pyroscope client allows to distinguish
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ For details about propagation, refer to [About baggage header](https://grafana.c

## Parameters

| Name | Type | Description |
| :-------- | :--------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `generateHeaders` | `function(method, body, params) headersMap` | A function taking the request method, body and params and returning a map of headers that will be attached. By default adding baggage header as explained in the [about baggage header]((https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/http-instrumentation-pyroscope#about-baggage-header)) |
| Name | Type | Description |
| :---------------- | :------------------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `generateHeaders` | `function(method, body, params) headersMap` | A function taking the request method, body and params and returning a map of headers that will be attached. By default adding baggage header as explained in the [about baggage header](<(https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/http-instrumentation-pyroscope#about-baggage-header)>) |

## Example

Expand All @@ -28,7 +28,7 @@ This example demonstrates how to use the this library to instrument every HTTP r

```javascript
import { check } from 'k6';
import pyroscope from 'https://jslib.k6.io/http-instrumentation-pyroscope/1.0.1/index.js';
import pyroscope from 'https://jslib.k6.io/http-instrumentation-pyroscope/{{< param "JSLIB_PYROSCOPE_VERSION" >}}/index.js';
import http from 'k6/http';

// instrumentHTTP will ensure that all requests made by the `http` module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ With this jslib, you can _instrument_ HTTP requests so that they emit traces as

## Migration from `k6/experimental/tracing`

This jslib is a drop in replacement, so all you need to migrate to it is to replace `'k6/experimental/tracing'` import with `'https://jslib.k6.io/http-instrumentation-tempo/1.0.0/index.js'`
This jslib is a drop in replacement, so all you need to migrate to it is to replace `'k6/experimental/tracing'` import with `'https://jslib.k6.io/http-instrumentation-tempo/{{< param "JSLIB_TEMPO_VERSION" >}}/index.js'`

## About trace contexts

Expand All @@ -34,7 +34,7 @@ This example demonstrates how to use the tracing API to instrument every HTTP re

```javascript
import { check } from 'k6';
import tempo from 'https://jslib.k6.io/http-instrumentation-tempo/1.0.0/index.js';
import tempo from 'https://jslib.k6.io/http-instrumentation-tempo/{{< param "JSLIB_TEMPO_VERSION" >}}/index.js';
import http from 'k6/http';

// instrumentHTTP will ensure that all requests made by the http module
Expand Down
Loading
Loading