Skip to content

Commit

Permalink
Add link to GitHub source code for all jslib libraries (#1757)
Browse files Browse the repository at this point in the history
* Add link to GitHub source code for all jslib libraries

* Apply suggestions from code review

Co-authored-by: Olha Yevtushenko <[email protected]>

* Remove duplicate weight property

* Apply to v0.54.x

---------

Co-authored-by: Olha Yevtushenko <[email protected]>
  • Loading branch information
heitortsergent and yorugac authored Oct 3, 2024
1 parent 0b1c4d2 commit 7d7085a
Show file tree
Hide file tree
Showing 12 changed files with 118 additions and 77 deletions.
8 changes: 8 additions & 0 deletions docs/sources/next/javascript-api/jslib/aws/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,12 @@ title: aws

<!-- TODO: Add content -->

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

The source code for this library can be found in the [grafana/k6-jslib-aws](https://github.com/grafana/k6-jslib-aws) GitHub repository.

{{< /admonition >}}

The `aws` module is an external JavaScript library that helps interact with a subset of AWS services in the context of k6 test scripts.

{{< section >}}
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
---
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

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

With jslib, you can _instrument_ HTTP requests in a way that lets you tag Grafana Cloud Profiles with relevant information generated from k6 tests.
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-pyroscope) GitHub repository.

{{< /admonition >}}

The `http-instrumentation-pyroscope` module allows you to _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.

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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ weight: 04

# HTTP instrumentation for Tempo

With this jslib, you can _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/).
{{< 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.

{{< /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'`


## About trace contexts

A _trace context_ is a set of standardized HTTP headers added to a request that lets a tracing system correlate it with other requests as they navigate through a system. The trace context specifications, such as the supported [W3C Trace Context](https://www.w3.org/TR/trace-context/) and [Jaeger Trace Context](https://www.jaegertracing.io/docs/1.21/client-libraries/#propagation-format), define specific header names and an encoding format for the header values.
Expand Down
28 changes: 13 additions & 15 deletions docs/sources/next/javascript-api/jslib/httpx/_index.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
---
title: "httpx"
description: "httpx is a wrapper library around the native k6 http module"
weight: 02
title: 'httpx'
description: 'httpx is a wrapper library around the native k6 http module'
weight: 02
---

# httpx

The `httpx` module is an external JavaScript library that wraps around the native [k6/http](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-http) module.
It's a http client with features that are not yet available in the native module.
{{< admonition type="note" >}}

- ability to set http options globally (such as timeout)
- ability to set default tags and headers that will be used for all requests
- more user-friendly arguments to request functions (get, post, put take the same arguments)
The source code for this library can be found in the [grafana/k6-jslib-httpx](https://github.com/k6io/k6-jslib-httpx) GitHub repository.

httpx module integrates well with the expect library.
{{< /admonition >}}

The source code is [on GitHub](https://github.com/k6io/k6-jslib-httpx).
Please request features and report bugs through [GitHub issues](https://github.com/k6io/k6-jslib-httpx/issues).
The `httpx` module is an external JavaScript library that wraps around the native [k6/http](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-http) module.
It's an HTTP client with features that are not yet available in the native module.

{{< admonition type="caution" >}}
- Ability to set HTTP options globally (such as timeout).
- Ability to set default tags and headers that will be used for all requests.
- More user-friendly arguments to request functions (get, post, put take the same arguments).

**This library is in active development.**
The `httpx` module integrates well with the expect library.

This library is stable enough to be useful, but pay attention to the new versions released on [jslib.k6.io](https://jslib.k6.io).
{{< admonition type="caution" >}}

This documentation is for the only last version only. If you discover that some of the following doesn't work, you might be using an older version.
This library is in active development. It's stable enough to be useful, but you can watch the [GitHub repository](https://github.com/k6io/k6-jslib-httpx) to be notified when a new version is released.

{{< /admonition >}}

Expand Down
25 changes: 13 additions & 12 deletions docs/sources/next/javascript-api/jslib/k6chaijs/_index.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
---
title: "k6chaijs"
description: "Assertion library for k6"
weight: 03
title: 'k6chaijs'
description: 'Assertion library for k6'
weight: 03
---

# k6chaijs

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

The source code for this library can be found in the [grafana/k6-jslib-k6chaijs](https://github.com/grafana/k6-jslib-k6chaijs) GitHub repository.

{{< /admonition >}}

`k6chaijs` is a library to provide BDD assertions in k6 based on [ChaiJS](https://www.chaijs.com/). You can use `k6chaijs` as an alternative to [check](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6/check) and [group](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6/group).

With this library, you get the following:

- BDD style of assertions for more expressive language
- chainable assertions
- more powerful assertions functions such as: `deep`, `nested`, `ordered`, etc.
- automatic assertion messages
- [exception handling](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6chaijs/error-handling) for better test stability
- Chainable assertions
- More powerful assertions functions such as: `deep`, `nested`, `ordered`, etc.
- Automatic assertion messages
- [Exception handling](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6chaijs/error-handling) for better test stability

## Installation

There's nothing to install. This library is hosted on [jslib](https://jslib.k6.io/) and can be imported in the k6 script directly.

{{< code >}}
This library is hosted on [jslib](https://jslib.k6.io/) and can be imported in directly in your k6 script.

```javascript
import { describe, expect } from 'https://jslib.k6.io/k6chaijs/4.3.4.3/index.js';
```

{{< /code >}}

Alternatively, you can use a copy of this file stored locally. The source code is available on [GitHub](https://github.com/grafana/k6-jslib-k6chaijs).

## Example
Expand Down
9 changes: 6 additions & 3 deletions docs/sources/next/javascript-api/jslib/utils/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ weight: 04

# utils

The `utils` module contains number of small utility functions useful in every day load testing.
{{< admonition type="note" >}}

The source code for this library can be found in the [grafana/k6-jslib-utils](https://github.com/k6io/k6-jslib-utils) GitHub repository.

> ⭐️ Source code available on [GitHub](https://github.com/k6io/k6-jslib-utils).
> Please request features and report bugs through [GitHub issues](https://github.com/k6io/k6-jslib-utils/issues).
{{< /admonition >}}

The `utils` module contains number of small utility functions useful in every day load testing.

| Function | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
Expand Down
8 changes: 8 additions & 0 deletions docs/sources/v0.54.x/javascript-api/jslib/aws/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,12 @@ title: aws

<!-- TODO: Add content -->

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

The source code for this library can be found in the [grafana/k6-jslib-aws](https://github.com/grafana/k6-jslib-aws) GitHub repository.

{{< /admonition >}}

The `aws` module is an external JavaScript library that helps interact with a subset of AWS services in the context of k6 test scripts.

{{< section >}}
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,23 @@ 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.
{{< 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-pyroscope) GitHub repository.

{{< /admonition >}}

The `http-instrumentation-pyroscope` module allows you to _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.

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.
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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ weight: 04

# HTTP instrumentation for Tempo

With this jslib, you can _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/).
{{< 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.

{{< /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`

Expand Down
28 changes: 13 additions & 15 deletions docs/sources/v0.54.x/javascript-api/jslib/httpx/_index.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
---
title: "httpx"
description: "httpx is a wrapper library around the native k6 http module"
weight: 02
title: 'httpx'
description: 'httpx is a wrapper library around the native k6 http module'
weight: 02
---

# httpx

The `httpx` module is an external JavaScript library that wraps around the native [k6/http](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-http) module.
It's a http client with features that are not yet available in the native module.
{{< admonition type="note" >}}

- ability to set http options globally (such as timeout)
- ability to set default tags and headers that will be used for all requests
- more user-friendly arguments to request functions (get, post, put take the same arguments)
The source code for this library can be found in the [grafana/k6-jslib-httpx](https://github.com/k6io/k6-jslib-httpx) GitHub repository.

httpx module integrates well with the expect library.
{{< /admonition >}}

The source code is [on GitHub](https://github.com/k6io/k6-jslib-httpx).
Please request features and report bugs through [GitHub issues](https://github.com/k6io/k6-jslib-httpx/issues).
The `httpx` module is an external JavaScript library that wraps around the native [k6/http](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-http) module.
It's an HTTP client with features that are not yet available in the native module.

{{< admonition type="caution" >}}
- Ability to set HTTP options globally (such as timeout).
- Ability to set default tags and headers that will be used for all requests.
- More user-friendly arguments to request functions (get, post, put take the same arguments).

**This library is in active development.**
The `httpx` module integrates well with the expect library.

This library is stable enough to be useful, but pay attention to the new versions released on [jslib.k6.io](https://jslib.k6.io).
{{< admonition type="caution" >}}

This documentation is for the only last version only. If you discover that some of the following doesn't work, you might be using an older version.
This library is in active development. It's stable enough to be useful, but you can watch the [GitHub repository](https://github.com/k6io/k6-jslib-httpx) to be notified when a new version is released.

{{< /admonition >}}

Expand Down
25 changes: 13 additions & 12 deletions docs/sources/v0.54.x/javascript-api/jslib/k6chaijs/_index.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
---
title: "k6chaijs"
description: "Assertion library for k6"
weight: 03
title: 'k6chaijs'
description: 'Assertion library for k6'
weight: 03
---

# k6chaijs

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

The source code for this library can be found in the [grafana/k6-jslib-k6chaijs](https://github.com/grafana/k6-jslib-k6chaijs) GitHub repository.

{{< /admonition >}}

`k6chaijs` is a library to provide BDD assertions in k6 based on [ChaiJS](https://www.chaijs.com/). You can use `k6chaijs` as an alternative to [check](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6/check) and [group](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6/group).

With this library, you get the following:

- BDD style of assertions for more expressive language
- chainable assertions
- more powerful assertions functions such as: `deep`, `nested`, `ordered`, etc.
- automatic assertion messages
- [exception handling](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6chaijs/error-handling) for better test stability
- Chainable assertions
- More powerful assertions functions such as: `deep`, `nested`, `ordered`, etc.
- Automatic assertion messages
- [Exception handling](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6chaijs/error-handling) for better test stability

## Installation

There's nothing to install. This library is hosted on [jslib](https://jslib.k6.io/) and can be imported in the k6 script directly.

{{< code >}}
This library is hosted on [jslib](https://jslib.k6.io/) and can be imported in directly in your k6 script.

```javascript
import { describe, expect } from 'https://jslib.k6.io/k6chaijs/4.3.4.3/index.js';
```

{{< /code >}}

Alternatively, you can use a copy of this file stored locally. The source code is available on [GitHub](https://github.com/grafana/k6-jslib-k6chaijs).

## Example
Expand Down
9 changes: 6 additions & 3 deletions docs/sources/v0.54.x/javascript-api/jslib/utils/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ weight: 04

# utils

The `utils` module contains number of small utility functions useful in every day load testing.
{{< admonition type="note" >}}

The source code for this library can be found in the [grafana/k6-jslib-utils](https://github.com/k6io/k6-jslib-utils) GitHub repository.

> ⭐️ Source code available on [GitHub](https://github.com/k6io/k6-jslib-utils).
> Please request features and report bugs through [GitHub issues](https://github.com/k6io/k6-jslib-utils/issues).
{{< /admonition >}}

The `utils` module contains number of small utility functions useful in every day load testing.

| Function | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
Expand Down

0 comments on commit 7d7085a

Please sign in to comment.