Skip to content

Commit

Permalink
"azurerm_spring_cloud_service" - supports property sample_rate (#11106)
Browse files Browse the repository at this point in the history
  • Loading branch information
njuCZ authored Mar 30, 2021
1 parent 8dbe40a commit 7b607c0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,13 @@ func resourceSpringCloudService() *schema.Resource {
Type: schema.TypeString,
Required: true,
},

"sample_rate": {
Type: schema.TypeFloat,
Optional: true,
Default: 10,
ValidateFunc: validation.FloatBetween(0, 100),
},
},
},
},
Expand Down Expand Up @@ -605,6 +612,7 @@ func expandSpringCloudTrace(input []interface{}) *appplatform.MonitoringSettingP
return &appplatform.MonitoringSettingProperties{
TraceEnabled: utils.Bool(true),
AppInsightsInstrumentationKey: utils.String(v["instrumentation_key"].(string)),
AppInsightsSamplingRate: utils.Float(v["sample_rate"].(float64)),
}
}

Expand Down Expand Up @@ -814,12 +822,16 @@ func flattenSpringCloudTrace(input *appplatform.MonitoringSettingProperties) []i

enabled := false
instrumentationKey := ""
samplingRate := 0.0
if input.TraceEnabled != nil {
enabled = *input.TraceEnabled
}
if input.AppInsightsInstrumentationKey != nil {
instrumentationKey = *input.AppInsightsInstrumentationKey
}
if input.AppInsightsSamplingRate != nil {
samplingRate = *input.AppInsightsSamplingRate
}

if !enabled {
return []interface{}{}
Expand All @@ -828,6 +840,7 @@ func flattenSpringCloudTrace(input *appplatform.MonitoringSettingProperties) []i
return []interface{}{
map[string]interface{}{
"instrumentation_key": instrumentationKey,
"sample_rate": samplingRate,
},
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ resource "azurerm_spring_cloud_service" "test" {
trace {
instrumentation_key = azurerm_application_insights.test.instrumentation_key
sample_rate = 20
}
tags = {
Expand Down
3 changes: 3 additions & 0 deletions website/docs/r/spring_cloud_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ resource "azurerm_spring_cloud_service" "example" {
trace {
instrumentation_key = azurerm_application_insights.example.instrumentation_key
sample_rate = 10.0
}
tags = {
Expand Down Expand Up @@ -147,6 +148,8 @@ The `trace` block supports the following:

* `instrumentation_key` - (Required) The Instrumentation Key used for Application Insights.

* `sample_rate` - (Optional) The sampling rate of Application Insights Agent. Must be between `0.0` and `100.0`. Defaults to `10.0`.

## Attributes Reference

The following attributes are exported:
Expand Down

0 comments on commit 7b607c0

Please sign in to comment.