@types/k6 0.42.0 → 0.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- k6/README.md +1 -1
- k6/experimental/tracing.d.ts +206 -0
- k6/http.d.ts +40 -0
- k6/index.d.ts +2 -1
- k6/package.json +2 -2
k6/README.md
CHANGED
|
@@ -8,7 +8,7 @@ This package contains type definitions for k6 (https://k6.io/docs/).
|
|
|
8
8
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/k6.
|
|
9
9
|
|
|
10
10
|
### Additional Details
|
|
11
|
-
* Last updated:
|
|
11
|
+
* Last updated: Mon, 20 Feb 2023 16:02:34 GMT
|
|
12
12
|
* Dependencies: none
|
|
13
13
|
* Global values: none
|
|
14
14
|
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module provides ways to instrument k6 scripts HTTP calls with tracing information.
|
|
3
|
+
*
|
|
4
|
+
* It most notably exposes an `instrumentHTTP` function that can be used to wrap the `http` module's
|
|
5
|
+
* function calls with tracing information. It also exposes a `Client` class that can be used to
|
|
6
|
+
* instrument HTTP calls in a more fine-grained way.
|
|
7
|
+
*
|
|
8
|
+
* https://k6.io/docs/javascript-api/k6-experimental/tracing/
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { RefinedParams, RefinedResponse, RequestBody, ResponseType } from '../http';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The instrumentHTTP function instruments the k6 http module
|
|
15
|
+
* with tracing capabilities. It will transparently replace each
|
|
16
|
+
* of the k6 http module functions with its instrumented
|
|
17
|
+
* counterpart, in place.
|
|
18
|
+
*
|
|
19
|
+
* instrumentHTTP can only be called in the init context of the script.
|
|
20
|
+
*
|
|
21
|
+
* @param options - The options to use when instrumenting the http module.
|
|
22
|
+
*/
|
|
23
|
+
export function instrumentHTTP(options: Options): void;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Client is an HTTP client class that attaches tracing information
|
|
27
|
+
* to its requests.
|
|
28
|
+
*
|
|
29
|
+
* It lets users include a tracing context in their HTTP requests
|
|
30
|
+
* so that tracing backends (such as Grafana Tempo) can incorporate
|
|
31
|
+
* their results.
|
|
32
|
+
*
|
|
33
|
+
* https://k6.io/docs/javascript-api/k6-experimental/tracing/client/
|
|
34
|
+
*/
|
|
35
|
+
export class Client {
|
|
36
|
+
protected __brand: never;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Instantiates a new tracing Client.
|
|
40
|
+
*
|
|
41
|
+
* @param options - The options to use for this Client.
|
|
42
|
+
*/
|
|
43
|
+
constructor(options: Options);
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Performs a DELETE request instrumented with trace context
|
|
47
|
+
* headers.
|
|
48
|
+
*
|
|
49
|
+
* @param url - Request URL.
|
|
50
|
+
* @param body - Discouraged. Request body. Object form encoded.
|
|
51
|
+
* @param params - Request parameters.
|
|
52
|
+
* @returns Resulting response.
|
|
53
|
+
*/
|
|
54
|
+
del<RT extends ResponseType | undefined>(
|
|
55
|
+
url: string | HttpURL,
|
|
56
|
+
body?: RequestBody | null,
|
|
57
|
+
params?: RefinedParams<RT> | null
|
|
58
|
+
): RefinedResponse<RT>;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Performs a HEAD request instrumented with trace context headers.
|
|
62
|
+
*
|
|
63
|
+
* @param url - Request URL.
|
|
64
|
+
* @param params - Request parameters.
|
|
65
|
+
* @returns Resulting response.
|
|
66
|
+
*/
|
|
67
|
+
head<RT extends ResponseType | undefined>(
|
|
68
|
+
url: string | HttpURL,
|
|
69
|
+
params?: RefinedParams<RT> | null
|
|
70
|
+
): RefinedResponse<RT>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Performs a GET request instrumented with trace context headers.
|
|
74
|
+
*
|
|
75
|
+
* @param url - Request URL.
|
|
76
|
+
* @param params - Request parameters.
|
|
77
|
+
* @returns Resulting response.
|
|
78
|
+
*/
|
|
79
|
+
get<RT extends ResponseType | undefined>(
|
|
80
|
+
url: string | HttpURL,
|
|
81
|
+
params?: RefinedParams<RT> | null
|
|
82
|
+
): RefinedResponse<RT>;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Performs an OPTIONS request instrumented with trace context headers.
|
|
86
|
+
*
|
|
87
|
+
* @param url - Request URL.
|
|
88
|
+
* @param body - Request body. Object form encoded.
|
|
89
|
+
* @param params - Request parameters.
|
|
90
|
+
* @returns Resulting response.
|
|
91
|
+
*/
|
|
92
|
+
options<RT extends ResponseType | undefined>(
|
|
93
|
+
url: string | HttpURL,
|
|
94
|
+
body?: RequestBody | null,
|
|
95
|
+
params?: RefinedParams<RT> | null
|
|
96
|
+
): RefinedResponse<RT>;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Performs a PATCH request instrumented with trace context headers.
|
|
100
|
+
*
|
|
101
|
+
* @param url - Request URL.
|
|
102
|
+
* @param body - Request body. Object form encoded.
|
|
103
|
+
* @param params - Request parameters.
|
|
104
|
+
* @returns Resulting response.
|
|
105
|
+
*/
|
|
106
|
+
patch<RT extends ResponseType | undefined>(
|
|
107
|
+
url: string | HttpURL,
|
|
108
|
+
body?: RequestBody | null,
|
|
109
|
+
params?: RefinedParams<RT> | null
|
|
110
|
+
): RefinedResponse<RT>;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Performs a POST request instrumented with trace context headers.
|
|
114
|
+
*
|
|
115
|
+
* @param url - Request URL.
|
|
116
|
+
* @param body - Request body. Object form encoded.
|
|
117
|
+
* @param params - Request parameters.
|
|
118
|
+
* @returns Resulting response.
|
|
119
|
+
*/
|
|
120
|
+
post<RT extends ResponseType | undefined>(
|
|
121
|
+
url: string | HttpURL,
|
|
122
|
+
body?: RequestBody | null,
|
|
123
|
+
params?: RefinedParams<RT> | null
|
|
124
|
+
): RefinedResponse<RT>;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Performs a PUT request instrumented with trace context headers.
|
|
128
|
+
*
|
|
129
|
+
* @param url - Request URL.
|
|
130
|
+
* @param body - Request body. Object form encoded.
|
|
131
|
+
* @param params - Request parameters.
|
|
132
|
+
* @returns Resulting response.
|
|
133
|
+
*/
|
|
134
|
+
put<RT extends ResponseType | undefined>(
|
|
135
|
+
url: string | HttpURL,
|
|
136
|
+
body?: RequestBody | null,
|
|
137
|
+
params?: RefinedParams<RT> | null
|
|
138
|
+
): RefinedResponse<RT>;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Performs a HTTP request instrumented with trace context headers.
|
|
142
|
+
*
|
|
143
|
+
* @param method - HTTP method.
|
|
144
|
+
* @param url - Request URL.
|
|
145
|
+
* @param body - Request body. Object form encoded.
|
|
146
|
+
* @param params - Request parameters.
|
|
147
|
+
* @returns Resulting response.
|
|
148
|
+
*/
|
|
149
|
+
request<RT extends ResponseType | undefined>(
|
|
150
|
+
method: string,
|
|
151
|
+
url: string | HttpURL,
|
|
152
|
+
body?: RequestBody | null,
|
|
153
|
+
params?: RefinedParams<RT> | null
|
|
154
|
+
): RefinedResponse<RT>;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* The asyncRequest method starts the process of performing a HTTP request
|
|
158
|
+
* asynchronously, returning a promise which is fulfilled once the response
|
|
159
|
+
* is available. The performed request is instrumented with trace context
|
|
160
|
+
* headers.
|
|
161
|
+
*
|
|
162
|
+
* @param method - HTTP method.
|
|
163
|
+
* @param url - Request URL.
|
|
164
|
+
* @param body - Request body. Object form encoded.
|
|
165
|
+
* @param params - Request parameters.
|
|
166
|
+
* @returns Resulting response.
|
|
167
|
+
*/
|
|
168
|
+
asyncRequest<RT extends ResponseType | undefined>(
|
|
169
|
+
method: string,
|
|
170
|
+
url: string | HttpURL,
|
|
171
|
+
body?: RequestBody | null,
|
|
172
|
+
params?: RefinedParams<RT> | null
|
|
173
|
+
): Promise<RefinedResponse<RT>>;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* The Options object allows configuring the tracing instrumentation behavior.
|
|
178
|
+
*
|
|
179
|
+
* https://k6.io/docs/javascript-api/k6-experimental/tracing/options/
|
|
180
|
+
*/
|
|
181
|
+
export interface Options {
|
|
182
|
+
/**
|
|
183
|
+
* The trace context propagation format.
|
|
184
|
+
*
|
|
185
|
+
* Currently supported: `w3c` and `jaeger`.
|
|
186
|
+
*
|
|
187
|
+
* Defaults to `w3c`.
|
|
188
|
+
*/
|
|
189
|
+
propagator: 'w3c' | 'jaeger';
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* The probability of each request having
|
|
193
|
+
* its `sampled` flag set to true.
|
|
194
|
+
* Its value should be within the `0 <= n <= 100` bounds.
|
|
195
|
+
*
|
|
196
|
+
* Defaults to `100`.
|
|
197
|
+
*/
|
|
198
|
+
sampling?: number;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Returned value from http.url method.
|
|
203
|
+
*/
|
|
204
|
+
export interface HttpURL {
|
|
205
|
+
__brand: "http-url";
|
|
206
|
+
}
|
k6/http.d.ts
CHANGED
|
@@ -123,6 +123,26 @@ export function request<RT extends ResponseType | undefined>(
|
|
|
123
123
|
params?: RefinedParams<RT> | null
|
|
124
124
|
): RefinedResponse<RT>;
|
|
125
125
|
|
|
126
|
+
/**
|
|
127
|
+
* Make async request.
|
|
128
|
+
* https://k6.io/docs/javascript-api/k6-http/asyncrequest/
|
|
129
|
+
* @param method - HTTP method.
|
|
130
|
+
* @param url - Request URL.
|
|
131
|
+
* @param body - Request body. Object form encoded.
|
|
132
|
+
* @param params - Request parameters.
|
|
133
|
+
* @returns Resulting response.
|
|
134
|
+
* @example
|
|
135
|
+
* let formData = {name: 'k6'};
|
|
136
|
+
* let headers = { 'Content-Type': 'application/x-www-form-urlencoded' };
|
|
137
|
+
* http.asyncRequest('POST', url, formData, { headers: headers });
|
|
138
|
+
*/
|
|
139
|
+
export function asyncRequest<RT extends ResponseType | undefined>(
|
|
140
|
+
method: string,
|
|
141
|
+
url: string | HttpURL,
|
|
142
|
+
body?: RequestBody | null,
|
|
143
|
+
params?: RefinedParams<RT> | null
|
|
144
|
+
): Promise<RefinedResponse<RT>>;
|
|
145
|
+
|
|
126
146
|
/**
|
|
127
147
|
* Batch multiple HTTP requests together,
|
|
128
148
|
* to issue them in parallel over multiple TCP connections.
|
|
@@ -903,6 +923,26 @@ declare namespace http {
|
|
|
903
923
|
params?: RefinedParams<RT> | null
|
|
904
924
|
): RefinedResponse<RT>;
|
|
905
925
|
|
|
926
|
+
/**
|
|
927
|
+
* Make async request.
|
|
928
|
+
* https://k6.io/docs/javascript-api/k6-http/asyncrequest/
|
|
929
|
+
* @param method - HTTP method.
|
|
930
|
+
* @param url - Request URL.
|
|
931
|
+
* @param body - Request body. Object form encoded.
|
|
932
|
+
* @param params - Request parameters.
|
|
933
|
+
* @returns Resulting response.
|
|
934
|
+
* @example
|
|
935
|
+
* let formData = {name: 'k6'};
|
|
936
|
+
* let headers = { 'Content-Type': 'application/x-www-form-urlencoded' };
|
|
937
|
+
* http.asyncRequest('POST', url, formData, { headers: headers });
|
|
938
|
+
*/
|
|
939
|
+
function asyncRequest<RT extends ResponseType | undefined>(
|
|
940
|
+
method: string,
|
|
941
|
+
url: string | HttpURL,
|
|
942
|
+
body?: RequestBody | null,
|
|
943
|
+
params?: RefinedParams<RT> | null
|
|
944
|
+
): Promise<RefinedResponse<RT>>;
|
|
945
|
+
|
|
906
946
|
/**
|
|
907
947
|
* Creates a URL with set name tag.
|
|
908
948
|
* https://k6.io/docs/using-k6/http-requests/#url-grouping
|
k6/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Type definitions for k6 0.
|
|
1
|
+
// Type definitions for k6 0.43
|
|
2
2
|
// Project: https://k6.io/docs/
|
|
3
3
|
// Definitions by: na-- <https://github.com/na-->
|
|
4
4
|
// Mihail Stoykov <https://github.com/MStoykov>
|
|
@@ -43,6 +43,7 @@ import './metrics';
|
|
|
43
43
|
import './options';
|
|
44
44
|
import './experimental/redis';
|
|
45
45
|
import './experimental/timers';
|
|
46
|
+
import './experimental/tracing';
|
|
46
47
|
import './experimental/websockets';
|
|
47
48
|
import './ws';
|
|
48
49
|
import './net/grpc';
|
k6/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/k6",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.43.0",
|
|
4
4
|
"description": "TypeScript definitions for k6",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/k6",
|
|
6
6
|
"license": "MIT",
|
|
@@ -55,6 +55,6 @@
|
|
|
55
55
|
},
|
|
56
56
|
"scripts": {},
|
|
57
57
|
"dependencies": {},
|
|
58
|
-
"typesPublisherContentHash": "
|
|
58
|
+
"typesPublisherContentHash": "9a5f8c5ed0a28eaa972298a4b9dbd230251a9bde3528c3f1531dfad264024ad0",
|
|
59
59
|
"typeScriptVersion": "4.2"
|
|
60
60
|
}
|