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

Refactoring metric structure for more easy usage #79

Open
nstrappazzonc opened this issue Aug 17, 2019 · 0 comments
Open

Refactoring metric structure for more easy usage #79

nstrappazzonc opened this issue Aug 17, 2019 · 0 comments
Assignees

Comments

@nstrappazzonc
Copy link
Contributor

nstrappazzonc commented Aug 17, 2019

Example:

package main

import (
	"fmt"
)

func main() {
	tags := make(map[string]string)
	tags["schema"] = "identity"
	tags["table"] = "user"

	fields := make(map[string]interface{})
	fields["percentage"] = 10

	item := make(map[string]interface{})
	item["tags"] = tags
	item["fields"] = fields

	metric := make(map[string][]map[string]interface{})
	
	metric["mysql_overflow"] = append(metric["mysql_overflow"], item)
	
	metrics := make(map[string][]map[string][]map[string]interface{})
	metrics["127.0.0.1"] = append(metrics["127.0.0.1"], metric)

	fmt.Println(fmt.Sprintf("%#v", metrics))
}

Output

map[string][]map[string][]map[string]interface {}{
  "127.0.0.1":[]map[string][]map[string]interface {}{
    map[string][]map[string]interface {}{
      "mysql_overflow":[]map[string]interface {}{
        map[string]interface {}{
          "fields":map[string]interface {}{"percentage":10},
          "tags":map[string]string{
            "schema":"identity",
            "table":"user"}}}}}}
@nstrappazzonc nstrappazzonc self-assigned this Aug 17, 2019
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

No branches or pull requests

1 participant