Skip to content

Commit c1386bf

Browse files
authored
Merge pull request #20 from browserup/add-trace-spans-to-har
Add trace spans to har that we can grab in grid to use when filing urls, steps.
2 parents 8e3cf82 + c2248fa commit c1386bf

File tree

589 files changed

+38994
-23442
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

589 files changed

+38994
-23442
lines changed

CLAUDE.md

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,26 @@ This is a customized fork of the mitmproxy project, maintained by a company name
22
is used to man-in-the-middle connections to provide debugging info, allow for security research
33
and other uses.
44

5-
Browserup uses the mitmproxy to capture traffic from within containers that are run during a load test.
6-
This captured traffic, through mitmproxy addons, is used to build a HAR (HTTP Archive) file. The HAR
7-
file is made available via an API. The API is also used to control the proxy, and to add custom metrics
8-
to a har at runtime, as well as adding verifications for HAR content. Clients for
9-
this API are generated in multiple languages via the open api specification. The clients live in /clients
10-
which should be ignored, as they are generated files.
11-
12-
Browserup extends mitmproxy's mitmdump executable with addons
13-
The most important code for browserup live in mitmproxy/addons/browserup
5+
The Browserup proxy fork uses a variation of the mitmproxy's "mitmdump" (no UI) mode to capture traffic from within containers that are run during a load test.
6+
This captured traffic, captured through mitmproxy addons, is
7+
used to build a HAR (HTTP Archive) file. The HAR file is made available via an API. The HAR also gets decorated with custom data, which start with an underscore.
8+
9+
The proxy offers an API that is also used to control the proxy, and to add custom metrics to a har at runtime, as well as adding verifications for HAR
10+
content. Clients for this API are generated in multiple languages via the open api specification. The clients live in /clients which should be ignored, as
11+
they are generated files.
12+
13+
Unusually, the schema .json files are regenerated when the tests are run. The definitions of the schemas are in mitmproxy/addons/browserup/har/har_schemas.py.
14+
They are defined in marshmallow.
15+
16+
The command to run the tests is: tox -e py
17+
18+
The command to check the linting, which we should do after all changes are done is:
19+
tox -e lint
20+
21+
22+
The BrowserUp proxy extends mitmproxy's mitmdump executable with addons. The most important code for browserup lives in the subfolder mitmproxy/addons/browserup.
23+
It is implemented almost entirely by changes and additions to addons. It is undesirable to change files outside of this path, and the corresponding test path, as that
24+
makes it difficult to take merges from the upstream mitmproxy project.
25+
26+
It is also ok to change items in the subfolder mitmproxy/tools/browserup_proxy.py as new
27+
addons are added. This is where they are loaded.

browserup-proxy.schema.json

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"url": "logo.png"
2626
},
2727
"title": "BrowserUp MitmProxy",
28-
"version": "1.24"
28+
"version": "1.25"
2929
},
3030
"paths": {
3131
"/har": {
@@ -387,52 +387,60 @@
387387
"type": "object",
388388
"properties": {
389389
"onContentLoad": {
390-
"type": "number",
390+
"type": "integer",
391391
"description": "onContentLoad per the browser"
392392
},
393393
"onLoad": {
394-
"type": "number",
394+
"type": "integer",
395395
"description": "onLoad per the browser"
396396
},
397397
"_firstInputDelay": {
398-
"type": "number",
398+
"type": "integer",
399399
"description": "firstInputDelay from the browser"
400400
},
401401
"_firstPaint": {
402-
"type": "number",
402+
"type": "integer",
403403
"description": "firstPaint from the browser"
404404
},
405405
"_cumulativeLayoutShift": {
406-
"type": "number",
406+
"type": "integer",
407407
"description": "cumulativeLayoutShift metric from the browser"
408408
},
409409
"_largestContentfulPaint": {
410-
"type": "number",
410+
"type": "integer",
411411
"description": "largestContentfulPaint from the browser"
412412
},
413413
"_domInteractive": {
414-
"type": "number",
414+
"type": "integer",
415415
"description": "domInteractive from the browser"
416416
},
417417
"_firstContentfulPaint": {
418-
"type": "number",
418+
"type": "integer",
419419
"description": "firstContentfulPaint from the browser"
420420
},
421421
"_dns": {
422-
"type": "number",
422+
"type": "integer",
423423
"description": "dns lookup time from the browser"
424424
},
425425
"_ssl": {
426-
"type": "number",
426+
"type": "integer",
427427
"description": "Ssl connect time from the browser"
428428
},
429429
"_timeToFirstByte": {
430-
"type": "number",
430+
"type": "integer",
431431
"description": "Time to first byte of the page's first request per the browser"
432432
},
433433
"_href": {
434434
"type": "string",
435435
"description": "Top level href, including hashtag, etc per the browser"
436+
},
437+
"_span_id": {
438+
"type": "string",
439+
"description": "W3C Trace Context span ID for this page"
440+
},
441+
"_parent_id": {
442+
"type": "string",
443+
"description": "W3C Trace Context parent span ID (typically the HAR log span ID)"
436444
}
437445
}
438446
},
@@ -602,7 +610,7 @@
602610
"description": "Name of Custom Metric to add to the page under _metrics"
603611
},
604612
"value": {
605-
"type": "number",
613+
"type": "integer",
606614
"format": "double",
607615
"description": "Value for the metric"
608616
}
@@ -856,6 +864,14 @@
856864
"$ref": "#/components/schemas/HarEntry"
857865
}
858866
},
867+
"_trace_id": {
868+
"type": "string",
869+
"description": "W3C Trace Context trace ID for distributed tracing"
870+
},
871+
"_span_id": {
872+
"type": "string",
873+
"description": "W3C Trace Context span ID for this HAR trace root"
874+
},
859875
"comment": {
860876
"type": "string"
861877
}
@@ -1314,6 +1330,18 @@
13141330
"$ref": "#/components/schemas/WebSocketMessage"
13151331
}
13161332
},
1333+
"_span_id": {
1334+
"type": "string",
1335+
"description": "W3C Trace Context span ID for this entry"
1336+
},
1337+
"_parent_id": {
1338+
"type": "string",
1339+
"description": "W3C Trace Context parent span ID (typically the page span ID)"
1340+
},
1341+
"_trace_id": {
1342+
"type": "string",
1343+
"description": "W3C Trace Context trace ID for distributed tracing"
1344+
},
13171345
"connection": {
13181346
"type": "string"
13191347
},
@@ -1367,6 +1395,14 @@
13671395
},
13681396
"default": []
13691397
},
1398+
"_span_id": {
1399+
"type": "string",
1400+
"description": "W3C Trace Context span ID for this page"
1401+
},
1402+
"_parent_id": {
1403+
"type": "string",
1404+
"description": "W3C Trace Context parent span ID (typically the HAR log span ID)"
1405+
},
13701406
"pageTimings": {
13711407
"$ref": "#/components/schemas/PageTimings"
13721408
},

clients/build-clients.sh

Lines changed: 47 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,53 @@
11
#!/bin/bash
22

3-
# requires openapi-generator installed
3+
# requires openapi-generator installed and accessible in your PATH
44

55
DIR="$(dirname "${BASH_SOURCE[0]}")"
6-
7-
# we need to regenerate the schema in the top level dir
8-
9-
rm -rf markdown && npx openapi-generator-cli generate \
10-
-g markdown -i "${DIR}/../browserup-proxy.schema.json" \
11-
-o markdown
12-
13-
rm -rf csharp && npx openapi-generator-cli generate \
14-
--package-name BrowserUpMitmProxyClient \
15-
-g csharp-netcore -i "${DIR}/../browserup-proxy.schema.json" \
16-
-o csharp -c config-csharp.yaml
17-
18-
rm -rf java && npx openapi-generator-cli generate \
19-
--package-name BrowserUpMitmProxyClient \
20-
-g java -i "${DIR}/../browserup-proxy.schema.json" \
21-
-o java -c config-java.yaml
22-
23-
rm -rf javascript && npx openapi-generator-cli generate \
24-
--package-name BrowserUpMitmProxyClient \
25-
-g javascript -i "${DIR}/../browserup-proxy.schema.json" \
26-
-o javascript -c config-javascript.yaml
27-
28-
rm -rf python && npx openapi-generator-cli generate \
29-
--package-name BrowserUpMitmProxyClient \
30-
-g python -i "${DIR}/../browserup-proxy.schema.json" \
31-
-o python -c config-python.yaml
32-
33-
rm -rf ruby && npx openapi-generator-cli generate \
34-
--package-name BrowserUpMitmProxyClient \
35-
-g ruby -i "${DIR}/../browserup-proxy.schema.json" \
36-
-o ruby -c config-ruby.yaml
6+
SCHEMA="${DIR}/../browserup-proxy.schema.json"
7+
8+
# Generate Markdown documentation
9+
rm -rf markdown && openapi-generator generate \
10+
-g markdown -i "${SCHEMA}" \
11+
-o markdown
12+
13+
# Generate C# (.NET Core) client
14+
rm -rf csharp && openapi-generator generate \
15+
--package-name BrowserUpMitmProxyClient \
16+
-g csharp -i "${SCHEMA}" \
17+
-o csharp -c config-csharp.yaml
18+
19+
# Generate Java client
20+
rm -rf java && openapi-generator generate \
21+
--package-name BrowserUpMitmProxyClient \
22+
-g java -i "${SCHEMA}" \
23+
-o java -c config-java.yaml
24+
25+
# Generate JavaScript client
26+
rm -rf javascript && openapi-generator generate \
27+
--package-name BrowserUpMitmProxyClient \
28+
-g javascript -i "${SCHEMA}" \
29+
-o javascript -c config-javascript.yaml
30+
31+
# Generate Python client
32+
rm -rf python && openapi-generator generate \
33+
--package-name BrowserUpMitmProxyClient \
34+
-g python -i "${SCHEMA}" \
35+
-o python -c config-python.yaml
36+
37+
# Generate Ruby client
38+
rm -rf ruby && openapi-generator generate \
39+
--package-name BrowserUpMitmProxyClient \
40+
-g ruby -i "${SCHEMA}" \
41+
-o ruby -c config-ruby.yaml
42+
43+
rm -rf ruby && openapi-generator generate \
44+
--package-name BrowserUpMitmProxyClient \
45+
-g ruby -i "${SCHEMA}" \
46+
-o ruby -c config-ruby.yaml
47+
48+
rm -rf go && openapi-generator generate \
49+
--package-name BrowserUpMitmProxyClient \
50+
-g go -i "${SCHEMA}" \
51+
-o go -c config-go.yaml
3752

3853
./post-build-java-client.sh

clients/config-go.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Config file for OpenAPI Generator Go client
2+
3+
# The package name for the generated code.
4+
# In Go, package names should be all lower case without special characters.
5+
packageName: browserupmitmproxyclient
6+
7+
# (Optional) Module name for the Go module (go.mod).
8+
moduleName: BrowserUpMitmProxyClient
9+
10+
# Project metadata
11+
projectName: browserup-mitmproxy-client
12+
projectVersion: 1.0.0
13+
projectDescription: "REST client for the BrowserUp Proxy"
14+
licenseName: MIT

clients/config-python.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ infoName: BrowserUp, Inc.
66
packageVersion: "1.0.1"
77

88
packageUrl: https://github.com/browserup/mitmproxy
9-
9+
10+
enablePostProcessFile: true
1011

1112
templateDir: python-overlay
1213
files:

0 commit comments

Comments
 (0)