Skip to content
This repository was archived by the owner on Nov 12, 2024. It is now read-only.
This repository was archived by the owner on Nov 12, 2024. It is now read-only.

Refactoring metric structure for more easy usage #79

@nicola-strappazzon

Description

@nicola-strappazzon

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"}}}}}}

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions