diff --git a/.prettierrc.json b/.prettierrc.json index 9d5ce399..e0f4e8aa 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,5 +1,6 @@ { "printWidth": 120, "singleQuote": true, - "trailingComma": "es5" + "trailingComma": "es5", + "endOfLine": "auto" } diff --git a/traceheatmap/README.md b/traceheatmap/README.md new file mode 100644 index 00000000..c3ee5070 --- /dev/null +++ b/traceheatmap/README.md @@ -0,0 +1,41 @@ +# Table Panel Plugin + +### How to install + +This plugin requires react and react-dom 18 + +Install peer dependencies: + +```bash +npm install react@18 react-dom@18 +``` + +Install the plugin: + +```bash +npm install @perses-dev/table-plugin +``` + +## Development + +### Setup + +Install dependencies: + +```bash +npm install +``` + +### Get Started + +Start the dev server: + +```bash +npm run dev +``` + +Build the plugin for distribution: + +```bash +npm run build +``` diff --git a/traceheatmap/cue.mod/module.cue b/traceheatmap/cue.mod/module.cue new file mode 100644 index 00000000..4b774d82 --- /dev/null +++ b/traceheatmap/cue.mod/module.cue @@ -0,0 +1,17 @@ +module: "github.com/perses/plugins/traceheatmap@v0" +language: { + version: "v0.15.1" +} +source: { + kind: "git" +} +deps: { + "github.com/perses/perses/cue@v0": { + v: "v0.53.0" + default: true + } + "github.com/perses/shared/cue@v0": { + v: "v0.53.1" + default: true + } +} \ No newline at end of file diff --git a/traceheatmap/go.mod b/traceheatmap/go.mod new file mode 100644 index 00000000..6f7a0f22 --- /dev/null +++ b/traceheatmap/go.mod @@ -0,0 +1,32 @@ +module github.com/perses/perses/go-sdk/traceheatmap + +go 1.26.1 + +require github.com/perses/perses v0.53.1 + +require ( + github.com/beorn7/perks v1.0.1 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/go-jose/go-jose/v4 v4.1.3 // indirect + github.com/golang-jwt/jwt/v5 v5.3.1 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/jpillora/backoff v1.0.0 // indirect + github.com/kr/text v0.2.0 // indirect + github.com/muhlemmer/gu v0.3.1 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect + github.com/perses/common v0.30.2 // indirect + github.com/prometheus/client_golang v1.23.2 // indirect + github.com/prometheus/client_model v0.6.2 // indirect + github.com/prometheus/common v0.67.5 // indirect + github.com/prometheus/procfs v0.17.0 // indirect + github.com/zitadel/oidc/v3 v3.45.4 // indirect + github.com/zitadel/schema v1.3.2 // indirect + go.yaml.in/yaml/v2 v2.4.3 // indirect + golang.org/x/net v0.49.0 // indirect + golang.org/x/oauth2 v0.35.0 // indirect + golang.org/x/sys v0.41.0 // indirect + golang.org/x/text v0.34.0 // indirect + google.golang.org/protobuf v1.36.11 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/traceheatmap/go.sum b/traceheatmap/go.sum new file mode 100644 index 00000000..1d709f9e --- /dev/null +++ b/traceheatmap/go.sum @@ -0,0 +1,70 @@ +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-jose/go-jose/v4 v4.1.3 h1:CVLmWDhDVRa6Mi/IgCgaopNosCaHz7zrMeF9MlZRkrs= +github.com/go-jose/go-jose/v4 v4.1.3/go.mod h1:x4oUasVrzR7071A4TnHLGSPpNOm2a21K9Kf04k1rs08= +github.com/golang-jwt/jwt/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY= +github.com/golang-jwt/jwt/v5 v5.3.1/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= +github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/muhlemmer/gu v0.3.1 h1:7EAqmFrW7n3hETvuAdmFmn4hS8W+z3LgKtrnow+YzNM= +github.com/muhlemmer/gu v0.3.1/go.mod h1:YHtHR+gxM+bKEIIs7Hmi9sPT3ZDUvTN/i88wQpZkrdM= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/nexucis/lamenv v0.5.2 h1:tK/u3XGhCq9qIoVNcXsK9LZb8fKopm0A5weqSRvHd7M= +github.com/nexucis/lamenv v0.5.2/go.mod h1:HusJm6ltmmT7FMG8A750mOLuME6SHCsr2iFYxp5fFi0= +github.com/perses/common v0.30.2 h1:RAiVxUpX76lTCb4X7pfcXSvYdXQmZwKi4oDKAEO//u0= +github.com/perses/common v0.30.2/go.mod h1:DFtur1QPah2/ChXbKKhw7djYdwNgz27s5fPKpiK0Xao= +github.com/perses/perses v0.53.1 h1:9VY/6p9QWrZwPSV7qiwTMSOsgcB37Lb1AXKT0ORXc6I= +github.com/perses/perses v0.53.1/go.mod h1:ro8fsgBkHYOdrL/MV+fdP9mflKzYCy/+gcbxiaReI/A= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o= +github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg= +github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk= +github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE= +github.com/prometheus/common v0.67.5 h1:pIgK94WWlQt1WLwAC5j2ynLaBRDiinoAb86HZHTUGI4= +github.com/prometheus/common v0.67.5/go.mod h1:SjE/0MzDEEAyrdr5Gqc6G+sXI67maCxzaT3A2+HqjUw= +github.com/prometheus/procfs v0.17.0 h1:FuLQ+05u4ZI+SS/w9+BWEM2TXiHKsUQ9TADiRH7DuK0= +github.com/prometheus/procfs v0.17.0/go.mod h1:oPQLaDAMRbA+u8H5Pbfq+dl3VDAvHxMUOVhe0wYB2zw= +github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= +github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +github.com/zitadel/oidc/v3 v3.45.4 h1:GKyWaPRVQ8sCu9XgJ3NgNGtG52FzwVJpzXjIUG2+YrI= +github.com/zitadel/oidc/v3 v3.45.4/go.mod h1:XALmFXS9/kSom9B6uWin1yJ2WTI/E4Ti5aXJdewAVEs= +github.com/zitadel/schema v1.3.2 h1:gfJvt7dOMfTmxzhscZ9KkapKo3Nei3B6cAxjav+lyjI= +github.com/zitadel/schema v1.3.2/go.mod h1:IZmdfF9Wu62Zu6tJJTH3UsArevs3Y4smfJIj3L8fzxw= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0= +go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8= +golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o= +golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8= +golang.org/x/oauth2 v0.35.0 h1:Mv2mzuHuZuY2+bkyWXIHMfhNdJAdwW3FuWeCPYN5GVQ= +golang.org/x/oauth2 v0.35.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA= +golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k= +golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk= +golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA= +google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= +google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/traceheatmap/jest.config.ts b/traceheatmap/jest.config.ts new file mode 100644 index 00000000..5190fb4d --- /dev/null +++ b/traceheatmap/jest.config.ts @@ -0,0 +1,23 @@ +// Copyright The Perses Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import type { Config } from '@jest/types'; +import shared from '../jest.shared'; + +const jestConfig: Config.InitialOptions = { + ...shared, + + setupFilesAfterEnv: [...(shared.setupFilesAfterEnv ?? []), '/src/setup-tests.ts'], +}; + +export default jestConfig; diff --git a/traceheatmap/package.json b/traceheatmap/package.json new file mode 100644 index 00000000..031ed606 --- /dev/null +++ b/traceheatmap/package.json @@ -0,0 +1,49 @@ +{ + "name": "@perses-dev/traceheatmap-plugin", + "version": "0.1.0", + "repository": { + "type": "git", + "url": "git+https://github.com/perses/plugins.git" + }, + "bugs": { + "url": "https://github.com/perses/plugins/issues" + }, + "scripts": { + "dev": "rsbuild dev", + "build": "npm run build-mf && concurrently \"npm:build:*\"", + "build-mf": "rsbuild build", + "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", + "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", + "build:types": "tsc --project tsconfig.build.json", + "lint": "eslint src --ext .ts,.tsx", + "test": "cross-env LC_ALL=C TZ=UTC jest", + "type-check": "tsc --noEmit" + }, + "main": "lib/cjs/index.js", + "module": "lib/index.js", + "types": "lib/index.d.ts", + "peerDependencies": { + "@perses-dev/core": "^0.53.0", + "echarts": "5.5.0", + "lodash": "^4.17.21" + }, + "files": [ + "lib/**/*", + "__mf/**/*", + "mf-manifest.json", + "mf-stats.json" + ], + "perses": { + "plugins": [ + { + "kind": "Panel", + "spec": { + "display": { + "name": "TraceHeatmap" + }, + "name": "TraceHeatmap" + } + } + ] + } +} diff --git a/traceheatmap/rsbuild.config.ts b/traceheatmap/rsbuild.config.ts new file mode 100644 index 00000000..d1102b0e --- /dev/null +++ b/traceheatmap/rsbuild.config.ts @@ -0,0 +1,35 @@ +// Copyright The Perses Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { pluginReact } from '@rsbuild/plugin-react'; +import { createConfigForPlugin } from '../rsbuild.shared'; + +export default createConfigForPlugin({ + name: 'TraceHeatmap', + rsbuildConfig: { + server: { port: 3014 }, + plugins: [pluginReact()], + }, + moduleFederation: { + exposes: { + './TraceHeatmap': './src/TraceHeatmap.ts', + }, + shared: { + react: { requiredVersion: '18.2.0', singleton: true }, + 'react-dom': { requiredVersion: '18.2.0', singleton: true }, + echarts: { singleton: true }, + lodash: { singleton: true }, + '@perses-dev/core': { singleton: true }, + }, + }, +}); diff --git a/traceheatmap/schemas/traceheatmap.cue b/traceheatmap/schemas/traceheatmap.cue new file mode 100644 index 00000000..23ed0153 --- /dev/null +++ b/traceheatmap/schemas/traceheatmap.cue @@ -0,0 +1,30 @@ +// Copyright The Perses Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package model + +import ( + "strings" +) + +kind: "TraceHeatmap" +spec: { + distributionSettings: { + unit: "ms" + bins: int & <=100 | *20 + scale: "linear" | "logarithmic" | *"linear" + min: number | *0 + max: number & <=5000 | *2000 + overflowStrategy: "clamp" | "filter" | *"clamp" + } +} diff --git a/traceheatmap/sdk/go/options.go b/traceheatmap/sdk/go/options.go new file mode 100644 index 00000000..e4a86542 --- /dev/null +++ b/traceheatmap/sdk/go/options.go @@ -0,0 +1,82 @@ +// Copyright The Perses Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package traceheatmap + +import "fmt" + +func WithBins(bins int) Option { + return func(builder *Builder) error { + if bins < 0 { + return fmt.Errorf("bins must be a positive integer, got %d", bins) + } + if bins > 100 { + return fmt.Errorf("bins cannot exceed 100 for performance reasons") + } + + builder.DistributionSettings.Bins = bins + return nil + } +} + +func WithScale(scale string) Option { + return func(builder *Builder) error { + if scale != ScaleLinear && scale != ScaleLogarithmic { + return fmt.Errorf("invalid scale %q: must be either %q or %q", scale, ScaleLinear, ScaleLogarithmic) + } + builder.DistributionSettings.Scale = scale + return nil + } +} + +func WithMin(min int) Option { + return func(builder *Builder) error { + if min < 0 { + return fmt.Errorf("min must be a positive integer, got %d", min) + } + + if min >= builder.DistributionSettings.Max { + return fmt.Errorf("min can not be gte max (%d), got %d", builder.DistributionSettings.Max, min) + } + + builder.DistributionSettings.Min = min + return nil + } +} + +func WithMax(max int) Option { + return func(b *Builder) error { + if max <= 0 { + return fmt.Errorf("max must be a none-zero positive integer, got %d", max) + } + if max <= b.DistributionSettings.Min { + return fmt.Errorf("max (%d) must be greater than min (%d)", max, b.DistributionSettings.Min) + } + if max > 5000 { + return fmt.Errorf("max cannot exceed 5000ms") + } + b.DistributionSettings.Max = max + return nil + } +} + +func WithOverflowStrategy(strategy string) Option { + return func(b *Builder) error { + if strategy != OverflowClamp && strategy != OverflowFilter { + return fmt.Errorf("invalid overflow strategy %q: must be either %q or %q", + strategy, OverflowClamp, OverflowFilter) + } + b.DistributionSettings.OverflowStrategy = strategy + return nil + } +} diff --git a/traceheatmap/sdk/go/traceheatmap.go b/traceheatmap/sdk/go/traceheatmap.go new file mode 100644 index 00000000..33c6a0d4 --- /dev/null +++ b/traceheatmap/sdk/go/traceheatmap.go @@ -0,0 +1,80 @@ +// Copyright The Perses Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package traceheatmap + +import "github.com/perses/perses/go-sdk/panel" + +const PluginKind = "TraceHeatmap" + +const ( + ScaleLinear = "linear" + ScaleLogarithmic = "logarithmic" + OverflowClamp = "clamp" + OverflowFilter = "filter" +) + +type DistributionSettings struct { + Unit string `json:"unit" yaml:"unit"` + Bins int `json:"bins" yaml:"bins"` + Scale string `json:"scale" yaml:"scale"` + Min int `json:"min" yaml:"min"` + Max int `json:"max" yaml:"max"` + OverflowStrategy string `json:"overflowStrategy" yaml:"overflowStrategy"` +} + +type Spec struct { + DistributionSettings DistributionSettings `json:"distributionSettings" yaml:"distributionSettings"` +} + +type Builder struct { + Spec `json:",inline" yaml:",inline"` +} + +type Option func(plugin *Builder) error + +func create(options ...Option) (Builder, error) { + builder := &Builder{ + Spec: Spec{ + DistributionSettings: DistributionSettings{ + Unit: "ms", + Bins: 25, + Scale: "linear", + Min: 0, + Max: 2000, + OverflowStrategy: "clamp", + }, + }, + } + + for _, opt := range options { + if err := opt(builder); err != nil { + return *builder, err + } + } + + return *builder, nil +} + +func TraceHeatmap(options ...Option) panel.Option { + return func(builder *panel.Builder) error { + plugin, err := create(options...) + if err != nil { + return err + } + + builder.Spec.Plugin.Kind = PluginKind + builder.Spec.Plugin.Spec = plugin.Spec + return nil + } +} diff --git a/traceheatmap/src/TraceHeatMap.ts b/traceheatmap/src/TraceHeatMap.ts new file mode 100644 index 00000000..1c17a503 --- /dev/null +++ b/traceheatmap/src/TraceHeatMap.ts @@ -0,0 +1,27 @@ +// Copyright The Perses Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { PanelPlugin } from '@perses-dev/plugin-system'; + +import { createInitialTraceHeatmapOptions, TraceHeatmapOptions, TraceHeatmapProps } from './models'; +import { TraceHeatmapPanel, DistributionSettingsEditor } from './components'; + +/** + * The core TimeSeriesTable panel plugin for Perses. + */ +export const Table: PanelPlugin = { + PanelComponent: TraceHeatmapPanel, + supportedQueryTypes: ['TraceQuery'], + panelOptionsEditorComponents: [{ label: 'Distribution Settings Editor', content: DistributionSettingsEditor }], + createInitialOptions: createInitialTraceHeatmapOptions, +}; diff --git a/traceheatmap/src/bootstrap.tsx b/traceheatmap/src/bootstrap.tsx new file mode 100644 index 00000000..06f1ffc5 --- /dev/null +++ b/traceheatmap/src/bootstrap.tsx @@ -0,0 +1,18 @@ +// Copyright The Perses Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import React from 'react'; +import ReactDOM from 'react-dom/client'; + +const root = ReactDOM.createRoot(document.getElementById('root')!); +root.render(); diff --git a/traceheatmap/src/components/DistributionSettings.tsx b/traceheatmap/src/components/DistributionSettings.tsx new file mode 100644 index 00000000..5ab8d6d7 --- /dev/null +++ b/traceheatmap/src/components/DistributionSettings.tsx @@ -0,0 +1,18 @@ +// Copyright The Perses Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { ReactElement } from 'react'; + +export const DistributionSettingsEditor = (): ReactElement => { + return <>; +}; diff --git a/traceheatmap/src/components/TraceHeatmapPanel.tsx b/traceheatmap/src/components/TraceHeatmapPanel.tsx new file mode 100644 index 00000000..91432275 --- /dev/null +++ b/traceheatmap/src/components/TraceHeatmapPanel.tsx @@ -0,0 +1,23 @@ +// Copyright The Perses Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { PanelProps } from '@perses-dev/plugin-system'; +import { TraceData } from '@perses-dev/core'; +import { ReactElement } from 'react'; +import { TraceHeatmapOptions } from '../models'; + +export type TableProps = PanelProps; + +export const TraceHeatmapPanel = (): ReactElement | null => { + return <>; +}; diff --git a/traceheatmap/src/components/index.ts b/traceheatmap/src/components/index.ts new file mode 100644 index 00000000..7af84ead --- /dev/null +++ b/traceheatmap/src/components/index.ts @@ -0,0 +1,2 @@ +export * from './TraceHeatmapPanel'; +export * from './DistributionSettings'; diff --git a/traceheatmap/src/env.d.ts b/traceheatmap/src/env.d.ts new file mode 100644 index 00000000..01f4e730 --- /dev/null +++ b/traceheatmap/src/env.d.ts @@ -0,0 +1,14 @@ +// Copyright The Perses Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/// diff --git a/traceheatmap/src/getPluginModule.ts b/traceheatmap/src/getPluginModule.ts new file mode 100644 index 00000000..ee2f25a7 --- /dev/null +++ b/traceheatmap/src/getPluginModule.ts @@ -0,0 +1,30 @@ +// Copyright The Perses Authors +// Licensed under the Apache License, Version 2.0 (the \"License\"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an \"AS IS\" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import packageJson from '../package.json'; + +/** + * Returns the plugin module information from package.json + */ +export function getPluginModule(): PluginModuleResource { + const { name, version, perses } = packageJson; + return { + kind: 'PluginModule', + metadata: { + name, + version, + }, + spec: perses as PluginModuleSpec, + }; +} diff --git a/traceheatmap/src/index-federation.ts b/traceheatmap/src/index-federation.ts new file mode 100644 index 00000000..df7f0bd8 --- /dev/null +++ b/traceheatmap/src/index-federation.ts @@ -0,0 +1,14 @@ +// Copyright The Perses Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import('./bootstrap'); diff --git a/traceheatmap/src/index.ts b/traceheatmap/src/index.ts new file mode 100644 index 00000000..9ddb7aaa --- /dev/null +++ b/traceheatmap/src/index.ts @@ -0,0 +1,17 @@ +// Copyright The Perses Authors +// Licensed under the Apache License, Version 2.0 (the \"License\"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an \"AS IS\" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +export { getPluginModule } from './getPluginModule'; +export * from './models'; +export * from './components'; +export * from './TraceHeatmap'; diff --git a/traceheatmap/src/models/index.ts b/traceheatmap/src/models/index.ts new file mode 100644 index 00000000..7f0c724f --- /dev/null +++ b/traceheatmap/src/models/index.ts @@ -0,0 +1,15 @@ +// Copyright The Perses Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +export * from './model'; +export * from './traceheatmap-model'; diff --git a/traceheatmap/src/models/model.ts b/traceheatmap/src/models/model.ts new file mode 100644 index 00000000..61aab520 --- /dev/null +++ b/traceheatmap/src/models/model.ts @@ -0,0 +1,19 @@ +// Copyright The Perses Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { PanelProps } from '@perses-dev/plugin-system'; + +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +interface TraceHeatmapOptions {} + +export type TraceHeatmapProps = PanelProps; diff --git a/traceheatmap/src/models/traceheatmap-model.ts b/traceheatmap/src/models/traceheatmap-model.ts new file mode 100644 index 00000000..cad04737 --- /dev/null +++ b/traceheatmap/src/models/traceheatmap-model.ts @@ -0,0 +1,38 @@ +// Copyright The Perses Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +export interface DistributionSettings { + unit: 'ms'; + bins: number; + scale: 'linear' | 'logarithmic'; + min: number; + max: number; + overflowStrategy: 'clamp' | 'filter'; +} + +export interface TraceHeatmapOptions { + distributionSettings: DistributionSettings; +} + +export function createInitialTraceHeatmapOptions(): TraceHeatmapOptions { + return { + distributionSettings: { + unit: 'ms', + bins: 20, + scale: 'linear', + min: 0, + max: 5000, + overflowStrategy: 'clamp', + }, + }; +} diff --git a/traceheatmap/tsconfig.json b/traceheatmap/tsconfig.json new file mode 100644 index 00000000..98221344 --- /dev/null +++ b/traceheatmap/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "outDir": "./dist/lib", + "rootDir": "./src" + }, + "include": ["src"] +}