Skip to content
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

Add scope parameter to /api/search/tags #2282

Merged
merged 24 commits into from
Apr 20, 2023

Conversation

joe-elliott
Copy link
Member

@joe-elliott joe-elliott commented Mar 30, 2023

What this PR does:
This PR

  • adds a ?scope parameter to the /api/search/tags endpoint. This parameter can currently take 3 values (resource, span, and intrinsic) as well as no value which defaults to the old behavior of returning both span and resource tags.
  • removes attributes that are non-existent in traceql such as root.name and root.service.name.
  • Adds a new endpoint /api/v2/search/tags that returns all tags organized by scope.

Note that this PR is blocked by #2244. Marking this as draft until that is merged.

Which issue(s) this PR fixes:
Fixes #2233

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Copy link
Contributor

@knylander-grafana knylander-grafana left a comment

Choose a reason for hiding this comment

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

Thank you for adding documentation! Changes look good. One minor suggestion for a missing comma.

@adrapereira
Copy link

Did you consider a new version of the endpoint where you return a list of available scopes for each tag?

For example:
GET /api/v2/search/tags

[
  { tag: "name", scopes: ["intrinsic"] },
  { tag: "http.status_code", scopes: ["span"] },
  { tag: "service.name", scopes: ["resource", "span"] },
  ...
]

The main advantage is that the client only needs to make one request to get all the information about the available tags and what their scopes are. With the solution from this PR a client would always have to perform three requests to get the full picture, one for each scope.

@joe-elliott
Copy link
Member Author

Did you consider a new version of the endpoint where you return a list of available scopes for each tag?

I did, but I liked not revving the endpoint b/c then I had to write less code :). If I did create a v2 it would likely return something like this though:

{
  "intrinsic": [ "array", "of", "strings"],
  "span": [ "a", "b", "c"],
  "resource": [ "d", "e", "f" ],
  ...
}

would you all prefer this?

@adrapereira
Copy link

Yes, that also works! Is it possible for a tag to be in more than one scope?

@joe-elliott
Copy link
Member Author

joe-elliott commented Mar 31, 2023

Yes, that also works! Is it possible for a tag to be in more than one scope?

Yup, but this would likely occur rarely.

joe-elliott and others added 15 commits April 11, 2023 11:53
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Co-authored-by: Kim Nylander <104772500+knylander-grafana@users.noreply.github.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
@joe-elliott joe-elliott marked this pull request as ready for review April 11, 2023 16:13
@joe-elliott
Copy link
Member Author

@adrapereira added a v2 endpoint. Example:

$ curl -G -s http://localhost:3200/api/v2/search/tags  | jq
{
  "scopes": [
    {
      "name": "span",
      "tags": [
        "article.count",
        "http.flavor",
        "http.method",
      ]
    },
    {
      "name": "resource",
      "tags": [
        "k6",
        "service.name"
      ]
    },
    {
      "name": "intrinsic",
      "tags": [
        "duration",
        "kind",
        "name",
        "status"
      ]
    }
  ]
}

Signed-off-by: Joe Elliott <number101010@gmail.com>
Copy link
Contributor

@knylander-grafana knylander-grafana left a comment

Choose a reason for hiding this comment

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

Doc addition looks good. Thank you.

Signed-off-by: Joe Elliott <number101010@gmail.com>
Copy link
Contributor

@zalegrala zalegrala 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, just a couple comments.

Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Copy link
Contributor

@zalegrala zalegrala left a comment

Choose a reason for hiding this comment

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

Nice work. Looks good to me.

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.

[Trace Explorer] Autocompletion suggests fields span.name and .name but queries fail
4 participants