Skip to content

Commit

Permalink
loading app names, which is a proxy to /label-values?label=__name_
Browse files Browse the repository at this point in the history
  • Loading branch information
eh-am committed Apr 4, 2023
1 parent 9d57aed commit bf11af1
Show file tree
Hide file tree
Showing 12 changed files with 145 additions and 15 deletions.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@
"license": "AGPL-3.0-only",
"private": true,
"scripts": {
"type-check": "tsc -p tsconfig.json --noEmit",
"build": "NODE_ENV=production webpack --progress --config scripts/webpack/webpack.prod.js",
"dev": "NODE_ENV=development webpack serve --progress --color --config scripts/webpack/webpack.dev.js"
},
"devDependencies": {
"@types/history": "4.7.11",
"@types/jquery": "^3.5.13",
"@types/react-dom": "^18.0.11",
"@types/react-outside-click-handler": "^1.3.1",
"@emotion/react": "^11.10.6",
"@emotion/styled": "^11.10.6",
"copy-webpack-plugin": "^11.0.0",
"esbuild-loader": "^3.0.1",
"expose-loader": "^4.1.0",
Expand Down
7 changes: 6 additions & 1 deletion public/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ import { Provider } from 'react-redux';
import store, { persistor } from './redux/store';
import '@webapp/../sass/profile.scss';
import '@szhsin/react-menu/dist/index.css';
import Notifications from '@webapp/ui/Notifications';

import { SingleView } from './pages/SingleView';

const root = ReactDOM.createRoot(document.getElementById('reactRoot'));
const container = document.getElementById('reactRoot') as HTMLElement;
const root = ReactDOM.createRoot(container);

root.render(
<Provider store={store}>
<Notifications />

<SingleView />
</Provider>
);
17 changes: 17 additions & 0 deletions public/app/hooks/loadAppNames.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { useEffect } from 'react';
import { useAppDispatch } from '@webapp/redux/hooks';
import { reloadAppNames } from '@webapp/redux/reducers/continuous';

export function loadAppNames() {
const dispatch = useAppDispatch();

useEffect(() => {
async function run() {
await dispatch(reloadAppNames());
}

run();
}, [dispatch]);

return [];
}
2 changes: 2 additions & 0 deletions public/app/overrides/ExportData.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Noop from './Noop';
export default Noop;
3 changes: 3 additions & 0 deletions public/app/overrides/Noop.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function () {
return <div>I am noop!!!!!!</div>;
}
3 changes: 3 additions & 0 deletions public/app/overrides/TimelineChart.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function () {
<></>;
}
32 changes: 32 additions & 0 deletions public/app/overrides/services/appNames.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { App, appsModel } from '@webapp/models/app';
import { Result } from '@webapp/util/fp';
import { z } from 'zod';
import type { ZodError } from 'zod';
import type { RequestError } from '@webapp/services/base';
import { parseResponse, request } from '@webapp/services/base';

export interface FetchAppsError {
message?: string;
}

const appNamesResponse = z.array(z.string()).transform((names) => {
return names.map((name) => {
return {
name,
spyName: 'unknown',
units: 'unknown',
};
});
});

export async function fetchApps(): Promise<
Result<App[], RequestError | ZodError>
> {
const response = await request('/pyroscope/label-values?label=__name__');

if (response.isOk) {
return parseResponse(response, appNamesResponse);
}

return Result.err<App[], RequestError>(response.error);
}
7 changes: 6 additions & 1 deletion public/app/pages/SingleView.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import ContinuousSingleView from '@webapp/pages/ContinuousSingleView';
import { loadAppNames } from '../hooks/loadAppNames';

export { ContinuousSingleView as SingleView };
export function SingleView() {
loadAppNames();

return <ContinuousSingleView />;
}
42 changes: 37 additions & 5 deletions scripts/webpack/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,49 @@ module.exports = {
modules: ['node_modules', path.resolve('public')],

// TODO: unify with tsconfig.json
// When using TsconfigPathsPlugin, paths overrides don't work
// For example, setting a) '@webapp/*' and b) '@webapp/components/ExportData'
// Would end up ignoring b)
alias: {
// Specific Component overrides
'@webapp/components/ExportData': path.resolve(
__dirname,
'../../public/app/overrides/ExportData'
),
'@webapp/services/apps': path.resolve(
__dirname,
'../../public/app/overrides/services/appNames'
),

// Common
'@pyroscope/webapp': path.resolve(
__dirname,
'../../node_modules/pyroscope-oss/webapp'
),
'@pyroscope/flamegraph': path.resolve(
__dirname,
'../../node_modules/pyroscope-oss/packages/pyroscope-flamegraph'
),
'@pyroscope/models': path.resolve(
__dirname,
'../../node_modules/pyroscope-oss/packages/pyroscope-models'
),

'@webapp': path.resolve(
__dirname,
'../../node_modules/pyroscope-oss/webapp/javascript'
),

// Dependencies
...deps,
},
plugins: [
// Use same alias from tsconfig.json
new TsconfigPathsPlugin({
logLevel: 'info',
// TODO: figure out why it could not use the baseUrl from tsconfig.json
baseUrl: path.resolve(__dirname, '../../'),
}),
// new TsconfigPathsPlugin({
// logLevel: 'info',
// // TODO: figure out why it could not use the baseUrl from tsconfig.json
// baseUrl: path.resolve(__dirname, '../../'),
// }),
],
},
ignoreWarnings: [/export .* was not found in/],
Expand Down
3 changes: 3 additions & 0 deletions scripts/webpack/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ module.exports = merge(common, {
mode: 'development',
devServer: {
port: 4040,
proxy: {
'/pyroscope': 'http://localhost:4100',
},
},
optimization: {
runtimeChunk: 'single',
Expand Down
13 changes: 8 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
"plugins": [{ "name": "typescript-plugin-css-modules" }],
"paths": {
"@pyroscope/webapp/*": ["./node_modules/pyroscope-oss/webapp/*"],
"@webapp/*": ["./node_modules/pyroscope-oss/webapp/javascript/*"],
"@webapp/redux/*": ["./node_modules/pyroscope-oss/webapp/javascript/redux/*"],
"@pyroscope/flamegraph/*": ["./node_modules/pyroscope-oss/packages/pyroscope-flamegraph/*"],
"@pyroscope/models/*": ["./node_modules/pyroscope-oss/packages/pyroscope-models/*"]
"@pyroscope/models/*": ["./node_modules/pyroscope-oss/packages/pyroscope-models/*"],
"@webapp/components/ExportData": ["./public/app/overrides/ExportData"],
"@webapp/services/apps": ["./public/app/overrides/services/appNames"],
"@webapp/*": ["./node_modules/pyroscope-oss/webapp/javascript/*"]
},
"target": "es5",
"lib": [
Expand All @@ -31,9 +34,9 @@
"strictNullChecks": true
},
"include": [
"node_modules/pyroscope-oss/lib/",
"node_modules/pyroscope-oss/webapp/javascript/types",
"src"
"./node_modules/pyroscope-oss/lib/",
"./node_modules/pyroscope-oss/webapp/javascript/types",
"public"
]
}

25 changes: 22 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,7 @@
resolved "https://registry.yarnpkg.com/@emotion/memoize/-/memoize-0.8.0.tgz#f580f9beb67176fa57aae70b08ed510e1b18980f"
integrity sha512-G/YwXTkv7Den9mXDO7AhLWkE3q+I92B+VqAE+dYG4NGPaHZGvt3G8Q0p9vmE+sq7rTGphUbAvmQ9YpbfMQGGlA==

"@emotion/react@^11.10.4":
"@emotion/react@^11.10.4", "@emotion/react@^11.10.6":
version "11.10.6"
resolved "https://registry.yarnpkg.com/@emotion/react/-/react-11.10.6.tgz#dbe5e650ab0f3b1d2e592e6ab1e006e75fd9ac11"
integrity sha512-6HT8jBmcSkfzO7mc+N1L9uwvOnlcGoix8Zn7srt+9ga0MjREo6lRpuVX0kzo6Jp6oTqDhREOFsygN6Ew4fEQbw==
Expand Down Expand Up @@ -1192,7 +1192,7 @@
resolved "https://registry.yarnpkg.com/@emotion/sheet/-/sheet-1.2.1.tgz#0767e0305230e894897cadb6c8df2c51e61a6c2c"
integrity sha512-zxRBwl93sHMsOj4zs+OslQKg/uhF38MB+OMKoCrVuS0nyTkqnau+BM3WGEoOptg9Oz45T/aIGs1qbVAsEFo3nA==

"@emotion/styled@^11.10.4":
"@emotion/styled@^11.10.4", "@emotion/styled@^11.10.6":
version "11.10.6"
resolved "https://registry.yarnpkg.com/@emotion/styled/-/styled-11.10.6.tgz#d886afdc51ef4d66c787ebde848f3cc8b117ebba"
integrity sha512-OXtBzOmDSJo5Q0AFemHCfl+bUueT8BIcPSxu0EGTpGk6DmI5dnhSzQANm1e1ze0YZL7TDyAyy6s/b/zmGOS3Og==
Expand Down Expand Up @@ -2733,7 +2733,7 @@
dependencies:
history "*"

"@types/history@^4.7.11":
"@types/history@4.7.11", "@types/history@^4.7.11":
version "4.7.11"
resolved "https://registry.yarnpkg.com/@types/history/-/history-4.7.11.tgz#56588b17ae8f50c53983a524fc3cc47437969d64"
integrity sha512-qjDJRrmvBMiTx+jyLxvLfJU7UznFuokDv4f3WRuriHKERccVpFU+8XMQUAbDzoiJCsmexxRExQeMwwCdamSKDA==
Expand Down Expand Up @@ -2766,6 +2766,13 @@
"@types/through" "*"
rxjs "^7.2.0"

"@types/jquery@^3.5.13":
version "3.5.16"
resolved "https://registry.yarnpkg.com/@types/jquery/-/jquery-3.5.16.tgz#632131baf30951915b0317d48c98e9890bdf051d"
integrity sha512-bsI7y4ZgeMkmpG9OM710RRzDFp+w4P1RGiIt30C1mSBT+ExCleeh4HObwgArnDFELmRrOpXgSYN9VF1hj+f1lw==
dependencies:
"@types/sizzle" "*"

"@types/js-levenshtein@^1.1.0":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@types/js-levenshtein/-/js-levenshtein-1.1.1.tgz#ba05426a43f9e4e30b631941e0aa17bf0c890ed5"
Expand Down Expand Up @@ -2847,6 +2854,13 @@
dependencies:
"@types/react" "*"

"@types/react-outside-click-handler@^1.3.1":
version "1.3.1"
resolved "https://registry.yarnpkg.com/@types/react-outside-click-handler/-/react-outside-click-handler-1.3.1.tgz#e4772ba550e1a548468203194d2615d8f06acdf9"
integrity sha512-0BNan5zIIDyO5k9LFSG+60ZxQ/0wf+LTF9BJx3oOUdOaJlZk6RCe52jRB75mlvLLJx2YLa61+NidOwBfptWMKw==
dependencies:
"@types/react" "*"

"@types/react-redux@^7.1.20":
version "7.1.25"
resolved "https://registry.yarnpkg.com/@types/react-redux/-/react-redux-7.1.25.tgz#de841631205b24f9dfb4967dd4a7901e048f9a88"
Expand Down Expand Up @@ -2936,6 +2950,11 @@
dependencies:
"@types/node" "*"

"@types/sizzle@*":
version "2.3.3"
resolved "https://registry.yarnpkg.com/@types/sizzle/-/sizzle-2.3.3.tgz#ff5e2f1902969d305225a047c8a0fd5c915cebef"
integrity sha512-JYM8x9EGF163bEyhdJBpR2QX1R5naCJHC8ucJylJ3w9/CVBaskdQ8WqBf8MmQrd1kRvp/a4TS8HJ+bxzR7ZJYQ==

"@types/sockjs@^0.3.33":
version "0.3.33"
resolved "https://registry.yarnpkg.com/@types/sockjs/-/sockjs-0.3.33.tgz#570d3a0b99ac995360e3136fd6045113b1bd236f"
Expand Down

0 comments on commit bf11af1

Please sign in to comment.