Skip to content

Commit 72477f8

Browse files
authored
Add boiler plate code for flamegraph and readme about dev setup grafana/phlare#125
2 parents 426690f + 19420c9 commit 72477f8

File tree

14 files changed

+14593
-0
lines changed

14 files changed

+14593
-0
lines changed

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,19 @@ bin
1111
go.work
1212
go.work.sum
1313
.DS_Store
14+
15+
node_modules
16+
17+
# Yarn
18+
**/.yarn/*
19+
!**/.yarn/patches
20+
!**/.yarn/releases
21+
!**/.yarn/plugins
22+
!**/.yarn/sdks
23+
!**/.yarn/versions
24+
.pnp.*
25+
26+
27+
**/dist
28+
29+
.idea

grafana/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
This directory contains Fire datasource and the FlameGraph panel.
2+
3+
To be able to test both in Grafana you have to setup your environment in a specific way.
4+
5+
#### Setup Grafana
6+
- Checkout https://github.com/grafana/grafana/pull/52057 in Grafana repo.
7+
- In grafana repo packages/grafana-data/package.json, change `"@grafana/schema": "9.1.0-pre",` to `"@grafana/schema": "9.0.4",`. We will link @grafana/data later on and the `9.1.0-pre` version would not be recognized from Fire repo
8+
#### Create symbolic links:
9+
- `cd $GRAFANA_REPO/data/plugins`
10+
- `ln -s $FIRE_REPO/grafana/flamegraph`
11+
- `ln -s $FIRE_REPO/grafana/fire-datasource`
12+
13+
#### Setup and build plugins:
14+
- `cd $FIRE_REPO/grafana/flamegraph`
15+
- `yarn link grafana/packages/grafana-data` this will change the `resolutions` part in package.json TODO: check if this can be relative path or how to prevent rewriting this all the time.
16+
- `yarn install`
17+
- `yarn build`
18+
- `cd $FIRE_REPO/grafana/fire-datasource`
19+
- `yarn install`
20+
- `yarn build`
21+
- `mage -v`
22+
- Restart Grafana if it was already running to pick up new plugin state.

grafana/fire-datasource/pkg/plugin/plugin.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ func (d *FireDatasource) query(_ context.Context, pCtx backend.PluginContext, qu
129129

130130
// create data frame response.
131131
frame := data.NewFrame("response")
132+
frame.Meta = &data.FrameMeta{PreferredVisualization: "profile"}
132133

133134
// add fields.
134135
frame.Fields = append(frame.Fields,

grafana/flamegraph/.prettierrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
...require('@grafana/toolkit/src/config/prettier.plugin.config.json'),
3+
};

grafana/flamegraph/.yarn/releases/yarn-3.2.2.cjs

Lines changed: 783 additions & 0 deletions
Large diffs are not rendered by default.

grafana/flamegraph/.yarnrc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
nodeLinker: node-modules
2+
3+
yarnPath: .yarn/releases/yarn-3.2.2.cjs

grafana/flamegraph/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Flame graph panel

grafana/flamegraph/coverage/junit.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuites name="jest tests" tests="0" failures="0" errors="0" time="0.001">
3+
</testsuites>

grafana/flamegraph/jest.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// This file is needed because it is used by vscode and other tools that
2+
// call `jest` directly. However, unless you are doing anything special
3+
// do not edit this file
4+
5+
const standard = require('@grafana/toolkit/src/config/jest.plugin.config');
6+
7+
// This process will use the same config that `yarn test` is using
8+
module.exports = standard.jestConfig();

grafana/flamegraph/package.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "grafana-flamegraph-panel",
3+
"version": "1.0.0",
4+
"description": "",
5+
"scripts": {
6+
"build": "grafana-toolkit plugin:build",
7+
"test": "grafana-toolkit plugin:test",
8+
"dev": "grafana-toolkit plugin:dev",
9+
"watch": "grafana-toolkit plugin:dev --watch",
10+
"sign": "grafana-toolkit plugin:sign",
11+
"start": "yarn watch"
12+
},
13+
"author": "Andrej Ocenas",
14+
"license": "Apache-2.0",
15+
"devDependencies": {
16+
"@grafana/data": "latest",
17+
"@grafana/runtime": "latest",
18+
"@grafana/toolkit": "latest",
19+
"@types/lodash": "4.14.181",
20+
"prettier": "2.6.0",
21+
"ts-node": "9.1.1"
22+
},
23+
"engines": {
24+
"node": ">=14"
25+
},
26+
"dependencies": {
27+
"react": "17.0.2"
28+
},
29+
"packageManager": "[email protected]",
30+
"resolutions": {
31+
"@grafana/data": "portal:/home/andrej/go/src/github.com/grafana/grafana/packages/grafana-data"
32+
}
33+
}

0 commit comments

Comments
 (0)