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

Allow setting numbers as tags #828

Closed
felixbarny opened this issue Apr 12, 2018 · 13 comments · Fixed by #1712
Closed

Allow setting numbers as tags #828

felixbarny opened this issue Apr 12, 2018 · 13 comments · Fixed by #1712
Assignees

Comments

@felixbarny
Copy link
Member

felixbarny commented Apr 12, 2018

Having the ability to set custom number values which are indexed in Elasticsearch allows to create aggregated graphs based on transactions.

For example, you could track the number of search results for a search transaction, along with the search query to get a list of the top searches without results.

@simitt
Copy link
Contributor

simitt commented Apr 12, 2018

Do you mean something similar as marks, which can be nested objects with number values?

This wouldn't be a big issue from a technical point of view (except for the one open issue that we also have with marks #708).

@felixbarny
Copy link
Member Author

Yes, similar to marks, but mark values should always be a timestamp in ms, right? Shouldn't we map it to a date then?

For this, we should pre-define a mapping so that we don't have the issue mentioned in #708. Double would be the most flexible datatype for this I guess.

@simitt
Copy link
Contributor

simitt commented Apr 12, 2018

Are you considering nested objects with double values, or a flat hierarchy as for tags?

@felixbarny
Copy link
Member Author

Just flat key value pairs with double values

@alvarolobato
Copy link

@felixbarny is this related to Open Tracing?

@alvarolobato alvarolobato removed this from the 6.5 milestone Oct 15, 2018
@felixbarny
Copy link
Member Author

OpenTracing allows to set string, boolean and number tags. Converting the numbers to strings does not really break the contract, but it means the users can't create graphs based on the number tags.

Example: the user could add a tag to a checkout cart span which represents the total value of the cart. If we don't support number tags, the user can't create a Kibana visualization with graphs the revenue.

@roncohen
Copy link
Contributor

@felixbarny and I discussed offline and while OT prescribes both:

  • Span.setTag(String key, Number value)
  • Span.setTag(String key, String value)

it doesn't prescribe how the values should be stored or how users should be able to query them. I understand this would be useful, but in order to avoid holding up OT support, let's consider this to be unrelated to OT.

@watson
Copy link
Contributor

watson commented Nov 15, 2018

Side-note: If it's easy to do while we're changing this anyway, I would like to propose that we also support boolean values.

@alvarolobato alvarolobato self-assigned this Nov 20, 2018
@toughrogrammer
Copy link

Is it on working?

@simitt
Copy link
Contributor

simitt commented Dec 21, 2018

We are investigating options to implement this, but it hasn't been implemented yet.

@toughrogrammer
Copy link

toughrogrammer commented Dec 21, 2018

Is there any roadmap about it? Or any other alternative solutions? And can I help anythings about it? :)

@simitt
Copy link
Contributor

simitt commented Dec 22, 2018

@felixbarny I suggest to use a scaled_float with relatively high precision instead of doubles, to reduce storage usage.

Possible solution in ES:

PUT apm-7.0.0-2018.12.22
{
  "mappings": {
    "_doc": {
      "dynamic_templates": [
        {
          "context.tags.keywords": {
            "path_match":   "context.tags.*",
            "match_mapping_type": "string",
            "mapping": {
              "type": "keyword"
            }
          }
        },
        {
          "context.tags.bool": {
            "path_match":   "context.tags.*",
            "match_mapping_type": "boolean",
            "mapping": {
              "type": "boolean"
            }
          }
        },
        {
          "context.tags.scaled_float": {
            "path_match":   "context.tags.*",
            "mapping" : {
              "scaling_factor" : 1000000,
              "type" : "scaled_float"
            }
          }
        }
      ]
    }
  }
}

Insert example doc

POST apm-7.0.0-2018.12.22/_doc
{
  "context": {
    "tags": {
      "ab": "sfmdskmfmsf",
      "cd": "1234",
      "ef": 1234,
      "fg": 234.980,
      "gh": true,
      "hj": "false"
    }
  }
}

Fetching mapping with GET apm*/_mapping returns:

{
  "apm-7.0.0-2018.12.22" : {
    "mappings" : {
      "_doc" : {
        "dynamic_templates" : [
          {
            "context.tags.keywords" : {
              "path_match" : "context.tags.*",
              "match_mapping_type" : "string",
              "mapping" : {
                "type" : "keyword"
              }
            }
          },
          {
            "context.tags.bool" : {
              "path_match" : "context.tags.*",
              "match_mapping_type" : "boolean",
              "mapping" : {
                "type" : "boolean"
              }
            }
          },
          {
            "context.tags.scaled_float" : {
              "path_match" : "context.tags.*",
              "mapping" : {
                "scaling_factor" : 1000000,
                "type" : "scaled_float"
              }
            }
          }
        ],
        "properties" : {
          "context" : {
            "properties" : {
              "tags" : {
                "properties" : {
                  "ab" : {
                    "type" : "keyword"
                  },
                  "cd" : {
                    "type" : "keyword"
                  },
                  "ef" : {
                    "type" : "scaled_float",
                    "scaling_factor" : 1000000.0
                  },
                  "fg" : {
                    "type" : "scaled_float",
                    "scaling_factor" : 1000000.0
                  },
                  "gh" : {
                    "type" : "boolean"
                  },
                  "hj" : {
                    "type" : "keyword"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

simitt added a commit to simitt/apm-server that referenced this issue Dec 22, 2018
Store numbers as scaled_floats, scaling_factor 1000000
fixes elastic#828.
simitt added a commit to simitt/apm-server that referenced this issue Dec 22, 2018
Store numbers as scaled_floats, scaling_factor 1000000
fixes elastic#828.
@simitt
Copy link
Contributor

simitt commented Dec 22, 2018

@toughrogrammer there is WIP PR #1712 which you can follow.

simitt added a commit that referenced this issue Jan 9, 2019
* Allow numbers and boolean values for tags. Store numbers as scaled_floats, scaling_factor 1000000
* Update tags in metricset to behave the same way as transaction.tags

fixes #828.
simitt added a commit to simitt/apm-server that referenced this issue Jan 14, 2019
* Allow numbers and boolean values for tags. Store numbers as scaled_floats, scaling_factor 1000000
* Update tags in metricset to behave the same way as transaction.tags

fixes elastic#828.
simitt added a commit that referenced this issue Jan 14, 2019
* Allow numbers and boolean values for tags. (#1712)

fixes #828.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants