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

Make types exportable (Bunch of changes) #3

Merged
merged 1 commit into from
Mar 26, 2017

Conversation

robfig
Copy link
Contributor

@robfig robfig commented Mar 20, 2017

Feel free to close if you don't want to merge, but I think these changes make this package a lot more usable for everyone. See the commit message for a summary of the changes

Thanks

Due to the size of the change, I don't expect these changes to be merged
upstream. But a number of them seem essential for actually using the package, so
who knows.

(1) Export some types

In order to support dashboard declaration using the struct literal syntax,
and just to set some properties at all, I exported a number of types:

Board:
- Templating
- Annotation
- Time
- Timepicker
- TemplateVar
- Option
- Current

Panel:
- SeriesOverride
- Tooltip
- Axis

(2) Add omitempty tag to a number of non-required settings (prometheus)

(3) Add the Target member to support Graphite

(4) Use io.Reader as the parameter type to doRequest.

Without that, it panics for GETs otherwise due to a nil-but-not-nil interface.

(5) Concatenate the query string on the path rather than replacing it.

This supports base URLs other than a bare hostname

(6) Remove board member from Row type.

The circular reference made it impossible to declare Boards and Rows using a
struct literal.
@coveralls
Copy link

coveralls commented Mar 20, 2017

Coverage Status

Coverage remained the same at 23.311% when pulling cea3f2c on yext:master into 2ebc9b7 on grafana-tools:master.

@robfig
Copy link
Contributor Author

robfig commented Mar 20, 2017

FYI, this is the kind of use case I had for declaring and then uploading it

var board = &sdk.Board{
	Title: "App Stats",
	Tags:  []string{"app"},
	Templating: sdk.Templating{
		List: []sdk.TemplateVar{
			{Name: "rollup", Type: "interval", Query: "1d,7d,1h", AllFormat: "glob"},
		},
	},
	Time:     sdk.Time{From: "now-7d", To: "now"},
	Editable: true,
	Rows: []*sdk.Row{
		row("Performance / Availability",
			span(6, graph("500s, measured by HAProxy",
				"aliasByNode(summarize(infra.haproxy.backends.{a,b}.http5xx.count, '$rollup'), 4)")),
			top10List("Top 10 500s", "http.appname.*.*.*.5xx.count", "2, 3, 4"),
		),
		row("Performance - Latency Histograms",
			latencyHistogram("app", "action"),
			latencyHistogram("app", "action2"),
		),
	},
}

@grafov grafov self-assigned this Mar 21, 2017
@grafov
Copy link
Member

grafov commented Mar 21, 2017

@robfig thank you! I'll take a look at the code soon.

@grafov grafov changed the title Bunch of changes Make types exportable (Bunch of changes) Mar 21, 2017
@grafov
Copy link
Member

grafov commented Mar 26, 2017

The proposed way for declaring dashboards looks reasonable. And on a first look it breaks nothing in old API. So I accept the changes they really improve the code. Thank you @robfig!

"ExampleNewBoard" test is broken but it is fragile test I'll fix it later.

@grafov grafov merged commit aa7d8fc into grafana-tools:master Mar 26, 2017
grafov added a commit that referenced this pull request Mar 29, 2017
grafov pushed a commit that referenced this pull request Jul 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants