-
Notifications
You must be signed in to change notification settings - Fork 66
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
XHR instrumentation experimental package #239
Merged
Merged
Changes from 2 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
a8a1f74
Initial commit of XHR instrumentation package
eskirk c480f9c
Capturing progress on testing out the XHR instrumentation
eskirk fe85096
Capturing progress - instrumenting XHR with event listeners, need par…
eskirk 37103a5
Capturing more progress, adding some TODOs
eskirk 00f3888
One last commit
eskirk b7cf74a
Fixing find + replace issue in jest config
eskirk 4b9b70b
Fixing lint issue in readme
eskirk 3b1bb74
Removing OTel tracing of fetch and XHR from demo app, replacing with …
eskirk a0abf02
Capturing more progress - event listeners are instrumented - needs te…
eskirk 2131914
Small change, adding todo
eskirk 20e78dd
Merge branch 'main' of https://github.com/grafana/faro-web-sdk into e…
eskirk 06b7bf2
Leftover merge conflict
eskirk 0335e57
Couple touch ups, addressing some feedback
eskirk fe5335a
Simplifying code and addressing more comments
eskirk 8ff6620
Adding more testing to XHR instrumentation
eskirk cbc525b
Pleasing the linter
eskirk bd96c9e
Markdown linting
eskirk 7a7cce3
More linting fixes lol
eskirk f5a90bd
Cleaning up package json and yarn lock things
eskirk b120400
Final lint for real
eskirk 794a5a4
Bumping version, remove XHR instrumentation from demo deps
eskirk dbb5dd9
Addressing Marco's suggestions
eskirk fb1dccd
Addressing more Marco feedback
eskirk 18605fc
Remove clashing instrumentations?
eskirk b0ee498
Adding more details to readme
eskirk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
supports es6-module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# @grafana/instrumentation-xhr | ||
|
||
Faro instrumentation of the JavaScript [XMLHttpRequest (XHR)](https://developer.mozilla.org/en-US/docs/Glossary/XMLHttpRequest) API | ||
|
||
❗️*Warning*: this package is experimental and may be subject to frequent and breaking changes. | ||
Use at your own risk.❗️ | ||
|
||
## Installation and Usage | ||
|
||
```ts | ||
// index.ts | ||
import { XHRInstrumentation } from '@grafana/faro-instrumentation-xhr'; | ||
import { getWebInstrumentations, initializeFaro } from '@grafana/faro-react'; | ||
|
||
initializeFaro({ | ||
// ... | ||
instrumentations: [ | ||
// Load the default Web instrumentations | ||
...getWebInstrumentations(), | ||
// Add XHR instrumentation | ||
new XHRInstrumentation(), | ||
], | ||
}); | ||
|
||
// myApi.ts | ||
const req = new XMLHttpRequest(); | ||
req.open("GET", "..."); | ||
req.send(); // use XHR as normal - telemetry data is sent to your Faro endpoint | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const { jestBaseConfig } = require('../../jest.config.base.js'); | ||
|
||
module.exports = { | ||
...jestBaseConfig, | ||
roots: ['experimental/instrumentation-xhr/src'], | ||
testEnvironment: 'jsdom', | ||
setupFiles: ['<rootDir>/experimental/instrumentation-xhr/src/setupTests.ts'], | ||
moduleNameMapper: { | ||
'^@remix-run/router$': '<rootDir>/index.ts', | ||
'^@remix-run/web-blob$': require.resolve('@remix-run/web-blob'), | ||
'^@remix-run/web-xhr$': require.resolve('@remix-run/web-xhr'), | ||
'^@remix-run/web-form-data$': require.resolve('@remix-run/web-form-data'), | ||
'^@remix-run/web-stream$': require.resolve('@remix-run/web-stream'), | ||
'^@web3-storage/multipart-parser$': require.resolve('@web3-storage/multipart-parser'), | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"name": "@grafana/faro-instrumentation-xhr", | ||
"version": "1.0.0", | ||
eskirk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"description": "Faro XHR auto-instrumentation package", | ||
"keywords": [ | ||
"observability", | ||
"apm", | ||
"rum", | ||
"logs", | ||
"traces", | ||
"metrics", | ||
"XMLHttpRequest", | ||
"xhr" | ||
], | ||
"main": "./dist/cjs/index.js", | ||
"module": "./dist/esm/index.js", | ||
"types": "./dist/types/index.d.ts", | ||
"scripts": { | ||
"test": "jest", | ||
"start": "yarn watch", | ||
"build": "run-s build:*", | ||
"build:compile": "run-p build:compile:*", | ||
"build:compile:cjs": "tsc --build tsconfig.cjs.json", | ||
"build:compile:esm": "tsc --build tsconfig.esm.json", | ||
"build:compile:bundle": "run-s build:compile:bundle:*", | ||
"build:compile:bundle:create": "rollup -c ./rollup.config.js", | ||
"build:compile:bundle:remove-extras": "rimraf dist/bundle/dist", | ||
"watch": "run-s watch:compile", | ||
"watch:compile": "yarn build:compile:cjs -w", | ||
"clean": "rimraf dist/ yarn-error.log", | ||
"quality": "run-s quality:*", | ||
"quality:test": "jest", | ||
"quality:format": "prettier --cache --cache-location=../../.cache/prettier/instrumentationXHR --ignore-path ../../.prettierignore -w \"./**/*.{js,jsx,ts,tsx,css,scss,md,yaml,yml,json}\"", | ||
"quality:lint": "run-s quality:lint:*", | ||
"quality:lint:eslint": "eslint --cache --cache-location ../../.cache/eslint/instrumentationXHR --ignore-path ../../.eslintignore \"./**/*.{js,jsx,ts,tsx}\"", | ||
"quality:lint:prettier": "prettier --cache --cache-location=../../.cache/prettier/instrumentationXHR --ignore-path ../../.prettierignore -c \"./**/*.{js,jsx,ts,tsx,css,scss,md,yaml,yml,json}\"", | ||
"quality:lint:md": "markdownlint README.md", | ||
"quality:circular-deps": "madge --circular ." | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/grafana/faro-web-sdk.git", | ||
"directory": "experimental/instrumentation-xhr" | ||
}, | ||
"author": "Grafana Labs", | ||
"license": "Apache-2.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const { getRollupConfigBase } = require('../../rollup.config.base.js'); | ||
|
||
module.exports = getRollupConfigBase('instrumentationXHR'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { XHRInstrumentation } from './instrumentation'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { BaseInstrumentation, VERSION } from '@grafana/faro-core'; | ||
|
||
export class XHRInstrumentation extends BaseInstrumentation { | ||
readonly name = '@grafana/faro-web-sdk:instrumentation-xhr'; | ||
readonly version = VERSION; | ||
|
||
initialize(): void { | ||
console.log('Initializing XHR instrumentation') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": "../../tsconfig.base.cjs.json", | ||
"compilerOptions": { | ||
"declarationDir": "./dist/types", | ||
"outDir": "./dist/cjs", | ||
"rootDir": "./src", | ||
"tsBuildInfoFile": "../../.cache/tsc/instrumentationXHR.cjs.tsbuildinfo" | ||
}, | ||
"include": ["./src"], | ||
"exclude": ["**/*.test.ts"], | ||
"references": [{ "path": "../../packages/core/tsconfig.spec.json" }] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": "../../tsconfig.base.esm.json", | ||
"compilerOptions": { | ||
"declarationDir": "./dist/types", | ||
"outDir": "./dist/esm", | ||
"rootDir": "./src", | ||
"tsBuildInfoFile": "../../.cache/tsc/instrumentationXHR.esm.tsbuildinfo" | ||
}, | ||
"include": ["./src"], | ||
"exclude": ["**/*.test.ts"], | ||
"references": [{ "path": "../../packages/core/tsconfig.spec.json" }] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"noPropertyAccessFromIndexSignature": false | ||
eskirk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
"references": [ | ||
{ "path": "./tsconfig.cjs.json" }, | ||
{ "path": "./tsconfig.esm.json" }, | ||
{ "path": "./tsconfig.spec.json" } | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"extends": "../../tsconfig.base.spec.json", | ||
"compilerOptions": { | ||
"declarationDir": "./dist/types", | ||
"outDir": "./dist/spec", | ||
"rootDir": "../../", | ||
"tsBuildInfoFile": "../../.cache/tsc/instrumentationXHR.spec.tsbuildinfo" | ||
}, | ||
"include": ["./src"], | ||
"references": [{ "path": "../../packages/core/tsconfig.spec.json" }] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: explain the availbale options too.