Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
Skip the calls if Grafana not set (#72)
Browse files Browse the repository at this point in the history
* skip links if Grafana API was not set

* skip annotations and links if Grafana client was not set
  • Loading branch information
skudasov authored Apr 11, 2024
1 parent 00cd831 commit 1e8b251
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ func (m *Profile) Run(wait bool) (*Profile, error) {
}

func (m *Profile) printDashboardLink() {
if m.grafanaAPI == nil {
log.Warn().Msg("Grafana API not set, skipping dashboard link print")
return
}
d, _, err := m.grafanaAPI.GetDashboard(m.grafanaOpts.AnnotateDashboardUID)
if err != nil {
log.Warn().Msgf("could not get dashboard link: %s", err)
Expand All @@ -85,6 +89,10 @@ func (m *Profile) printDashboardLink() {
}

func (m *Profile) annotateRunStartOnGrafana() {
if m.grafanaAPI == nil {
log.Warn().Msg("Grafana API not set, skipping annotations")
return
}
var sb strings.Builder
sb.WriteString("<body>")
sb.WriteString("<h4>Test Started</h4>")
Expand All @@ -111,6 +119,10 @@ func (m *Profile) annotateRunStartOnGrafana() {
}

func (m *Profile) annotateRunEndOnGrafana() {
if m.grafanaAPI == nil {
log.Warn().Msg("Grafana API not set, skipping annotations")
return
}
var sb strings.Builder
sb.WriteString("<body>")
sb.WriteString("<h4>Test Ended</h4>")
Expand Down

0 comments on commit 1e8b251

Please sign in to comment.