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

Add Tricharts #227

Merged
merged 7 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.95.4
1.95.5
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ endif
LIGHTSTEP_ORG="terraform-provider" \
LIGHTSTEP_PROJECT="terraform-provider-test" \
LIGHTSTEP_API_BASE_URL="https://api.lightstep.com" \
TF_ACC_TERRAFORM_PATH=$(which terraform) \
TF_ACC_PROVIDER_NAMESPACE=hashicorp \
TF_ACC_PROVIDER_HOST=registry.opentofu.org \
go test -v ./lightstep

.PHONY: test-local
Expand All @@ -63,6 +66,9 @@ test-local:
LIGHTSTEP_PROJECT="terraform-provider-test" \
LIGHTSTEP_API_RATE_LIMIT=100 \
LIGHTSTEP_API_BASE_URL="https://api.lightstep.com" \
TF_ACC_TERRAFORM_PATH=$(which terraform) \
TF_ACC_PROVIDER_NAMESPACE=hashicorp \
TF_ACC_PROVIDER_HOST=registry.opentofu.org \
go test -v ./lightstep -test.run TestAccSAMLGroupMappings

.PHONY: test-staging
Expand All @@ -73,6 +79,9 @@ test-staging:
LIGHTSTEP_ORG="terraform-provider" \
LIGHTSTEP_PROJECT="terraform-provider-test" \
LIGHTSTEP_API_BASE_URL="https://api-staging.lightstep.com" \
TF_ACC_TERRAFORM_PATH=$(which terraform) \
TF_ACC_PROVIDER_NAMESPACE=hashicorp \
TF_ACC_PROVIDER_HOST=registry.opentofu.org \
go test -v ./lightstep

.PHONY: ensure-clean-repo
Expand Down
1 change: 1 addition & 0 deletions lightstep/resource_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func getUnifiedQuerySchemaMap() map[string]*schema.Schema {
"pie",
"table",
"traces_list",
"trichart",
}, false),
},
// See https://github.com/hashicorp/terraform-plugin-sdk/issues/155
Expand Down
56 changes: 56 additions & 0 deletions lightstep/resource_dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,53 @@ chart {
`, displayType, displayTypeOptions)
}

func makeTrichartDisplay() string {
return fmt.Sprintf(`
resource "lightstep_dashboard" "test_display_type_options" {
project_name = "` + testProject + `"
dashboard_name = "test trichart"

group {
rank = 0
title = ""
visibility_type = "implicit"

chart {
name = "Chart #123"
type = "timeseries"
rank = 0
x_pos = 4
y_pos = 0
width = 4
height = 4

query {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any validation that the user actually added 3 queries, or does the FE degrade gracefully when they fail to do so? id be happy with either/both but am less thrilled about neither

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The FE will show an invalid query error if there are not 3 queries and give an example of a valid query. Not ideal but consistent with other query/viz pairings.

query_name = "error_ratio"
display = "trichart"
display_type_options = { display_type = trichart }
hidden = false
query_string = "with\n errors = spans count\n | delta\n | filter service == "web" && error == true\n | group_by [], sum;\n total = spans count\n | delta\n | filter service == "web"\n | group_by [], sum;\n join errors / total, errors=0, total=0"
}
query {
query_name = "latency"
display = "trichart"
display_type_options = { display_type = trichart }
hidden = false
query_string = "spans latency | delta | filter service == "web" | group_by [], sum | point percentile(value, 99.0)"
}
query {
query_name = "rate"
display = "trichart"
display_type_options = { display_type = trichart }
hidden = false
query_string = "spans count | rate | filter service == "web" | group_by [], sum"
}
}
}
}
`)
}

func TestDisplayTypeOptionsError(t *testing.T) {
var dashboard client.UnifiedDashboard

Expand Down Expand Up @@ -1062,6 +1109,15 @@ func TestDisplayTypeOptions(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "group.0.chart.0.query.0.display_type_options.0.y_axis_max", "100"),
),
},
{
Config: makeTrichartDisplay(),
Check: resource.ComposeTestCheckFunc(
testAccCheckMetricDashboardExists(resourceName, &dashboard),
resource.TestCheckResourceAttr(resourceName, "dashboard_name", "test trichart"),
resource.TestCheckResourceAttr(resourceName, "group.0.chart.0.query.0.display", "trichart"),
resource.TestCheckResourceAttr(resourceName, "group.0.chart.0.query.0.display_type_options.0.display_type", "trichart"),
),
},
{
Config: makeDisplayTypeConfig("dependency_map", strings.TrimSpace(`
display_type_options {
Expand Down
Loading