8000 [FEATURE] Initial Tempo Plugin by zhuje · Pull Request #1561 · perses/perses · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[FEATURE] Initial Tempo Plugin #1561

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

Merged
merged 11 commits into from
Nov 29, 2023
Merged

Conversation

zhuje
Copy link
Contributor
@zhuje zhuje commented Oct 31, 2023

Description

This first iteration of the Tempo plugin creates a pluginType called TraceQuery and creates plugin kinds TempoTraceQuery and TempoDatasource. This PR does not include any UI changes that accommodate Tempo data. However, future enhancements should include data visualization (e.g. Scatterplot) for TempoTraceQueries and UI data source editing options for TempoDatasources.

TempoDatasource

Currently, you can not add TempoDatasources via. the Perses UI. However, it can be created through the Perses API.
To demo the creation of a global TempoDatasource:

  1. Create a local tempo instance (here's an example). In this example, Tempo is served from localhost:3200.
  2. POST to /api/v1/globaldatasources
Screenshot 2023-10-31 at 15 54 41

Figure 1. This figure shows the request and response from the Perses API when creating a global TempoDatasource.

Screenshot 2023-10-31 at 15 56 05

Figure 2. The TempoDatasource is now listed as a global data source.

TempoTraceQuery

The following code block is a dashboard definition JSON example for a TempoTraceQuery. The client uses the Grafana Tempo endpoint, /api/search?fooParams to query traces. The query must be written in Trace Query Language (TraceQL). For example "query": "{ duration > 900ms }".

{
  "kind": "Dashboard,",
  "metadata": {
       ...
  },
  "spec" {
      "display": {
             ...
      },
     "panels": {
            "examplePanel" : {
                    ....
             }, 
              "queries": [
                          {
                            "kind": "TraceQuery",
                            "spec": {
                              "plugin": {
                                "kind": "TempoTraceQuery",
                                "spec": {
                                  "datasource": {
                                    "kind": "TempoDatasource",
                                    "name": "TempoLocal"
                                  },
                                  "query": "{ duration > 900ms }"
                                }
                              }
                            }
                          }
              ]
        },
        "layouts": {
             ...
         }
   }
}

After the client makes the request, the response is stored in the DataQueriesProvider. Panels can then retrieve the data using the function useDataQueries() e.g. const { queryResults: traceResults } = useDataQueries('TraceQuery');) Currently, there are no panels that accommodate Tempo data, so there are no screenshots.

Future Enhancements

Future enhancements should include a ScatterPlotPanel and TablePanel to display TempoTraceQuery results. Additionally, editing options will be added to the GlobalDatasource editing panels for TempoDatasources.

Screenshots

No UI Changes.

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the [<catalog_entry>] <commit message> naming convention using one of the following catalog_entry values: FEATURE, ENHANCEMENT, BUGFIX, BREAKINGCHANGE, IGNORE.
  • All commits have DCO signoffs.

UI Changes

  • Changes that impact the UI include screenshots and/or screencasts of the relevant changes.
  • Code follows the UI guidelines.
  • Visual tests are stable and unlikely to be flaky. See Storybook and e2e docs for more details. Common issues include:
    • Is the data inconsistent? You need to mock API requests.
    • Does the time change? You need to use consistent time values or mock time utilities.
    • Does it have loading states? You need to wait for loading to complete.

Copy link
Member
@Nexucis Nexucis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an incredible work @zhuje. Thank you for doing it 🙏. That's awesome !!

@Nexucis
Copy link
Member
Nexucis commented Nov 2, 2023

Could you also add a doc about the Tempo datasource here: https://github.com/perses/perses/tree/main/docs/api/plugin ? Thanks !

Plugin includes: TraceQuery, TempoTraceQuery, TempoDatasource

Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
@zhuje zhuje force-pushed the data-queries-provider3 branch from 33059c0 to fad6d91 Compare November 16, 2023 23:20
@Nexucis
Copy link
Member
Nexucis commented Nov 17, 2023

@zhuje you have a conflict, would you mind to sync with the main branch please ?

Plugin includes: TraceQuery, TempoTraceQuery, TempoDatasource

Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
@zhuje
Copy link
Contributor Author
zhuje commented Nov 20, 2023

Could you also add a doc about the Tempo datasource here: https://github.com/perses/perses/tree/main/docs/api/plugin ?

I'll create a separate PR for this.

…l '*' files within /ui to be a 'workspace'.

-- TESTING to be squashed later.

Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
@zhuje zhuje force-pushed the data-queries-provider3 branch from e26201c to 9c09512 Compare November 20, 2023 22:14
    -- TEST to be squashed later

Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
@zhuje zhuje force-pushed the data-queries-provider3 branch from 696a5de to 82b022a Compare November 20, 2023 23:19
Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
…nt for dev purposes

commit message to be squashed later

Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
@zhuje zhuje force-pushed the data-queries-provider3 branch from 030a413 to 8584533 Compare November 21, 2023 02:31
Copy link
Member
@Nexucis Nexucis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me !

Once the react tests are fixed, it will be good to merge on my side !

@Nexucis
Copy link
Member
Nexucis commented Nov 21, 2023

@sjcobb @nicolastakashi @jgbernalp @celian-garcia maybe you will have others things to say here :)

{
"name": "@perses-dev/tempo-plugin",
"version": "0.41.1",
"description": "The plugin feature in Perses",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"description": "The plugin feature in Perses",
"description": "A Perses plugin to interact with Tempo traces",

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do, good catch.

@jgbernalp
Copy link
Contributor

LGTM, just a minor suggestion

Copy link
Member
@celian-garcia celian-garcia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great ! Thank you @zhuje! I wrote a few comments 👍

For everyone: What is the rule for the files extensions .ts vs .tsx. I think that some files have the .tsx extensio 57A6 n where they don't contain html. Is it a problem?


const getQueryType = useCallback(
(pluginKind: string) => {
if (isLoading) {
return undefined;
}
if (isTraceQueryPluginLoading) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you need to use there one or the other "isLoading" depending on the pluginKind ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I'll make a switch statement to check which pluginKind it is and return the corresponding isLoading state. For example:

    switch (pluginKind) {
      case 'PrometheusTimeSeriesQuery':
        return isTimeSeriesQueryLoading
      case 'TempoTraceQuery':
        return isTraceQueryPluginLoading
    }

@@ -60,26 +60,37 @@ export function transformQueryResults(results: UseQueryResult[], definitions: Qu

export function useQueryType(): (pluginKind: string) => string | undefined {
const { data: timeSeriesQueryPlugins, isLoading } = useListPluginMetadata('TimeSeriesQuery');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the readability, can we rename isLoading to isTimeSeriesQueryLoading?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, makes sense.

@zhuje zhuje closed this Nov 21, 2023
@zhuje zhuje reopened this Nov 21, 2023
Nexucis and others added 2 commits November 22, 2023 16:39
Signed-off-by: Augustin Husson <augustin.husson@amadeus.com>
@zhuje
Copy link
Contributor Author
zhuje commented Nov 27, 2023

Great ! Thank you @zhuje! I wrote a few comments 👍

For everyone: What is the rule for the files extensions .ts vs .tsx. I think that some files have the .tsx extension where they don't contain html. Is it a problem?

I had the same question for ".ts vs .tsx". I found this answer on StackOverflow. Generally, I followed the format of the Prometheus plugin, so whatever extension they used for a particular component/file I also used.

…oading status

- Update description on Tempo plugin's package.json

Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
Resolve merge conflict in ui > core > src > model > index.ts by accepting both exports * from './http-proxy' and './kind'

Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
@zhuje zhuje closed this Nov 28, 2023
@zhuje zhuje reopened this Nov 28, 2023
@Nexucis
Copy link
Member
Nexucis commented Nov 29, 2023

Awesome! Thank you for taking the time to fix everything @zhuje !!

@Nexucis Nexucis merged commit d6caa22 into perses:main Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0