Repository: honeycombio/terraform-provider-honeycombio
Pull request #559 (2024-10-09 12:53:51)

chore: r/dataset_definition - add log_severity and log_message
Adds the two new log-related dataset definitions to `r/dataset_definition`.

---
- To see the specific tasks where the Asana app for GitHub is being used, see below:
  - https://app.asana.com/0/0/1208492094472237

codecov-commenter: ## [Codecov](https://app.codecov.io/gh/honeycombio/terraform-provider-honeycombio/pull/559?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=honeycombio) Report
Attention: Patch coverage is `28.57143%` with `10 lines` in your changes missing coverage. Please review.
> Project coverage is 78.57%. Comparing base [(`22d582d`)](https://app.codecov.io/gh/honeycombio/terraform-provider-honeycombio/commit/22d582d6d500e099c523b8411644cebc6f4db938?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=honeycombio) to head [(`83d449a`)](https://app.codecov.io/gh/honeycombio/terraform-provider-honeycombio/commit/83d449ac7bb7f400509f18ec9071d6912dfd3c00?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=honeycombio).

| [Files with missing lines](https://app.codecov.io/gh/honeycombio/terraform-provider-honeycombio/pull/559?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=honeycombio) | Patch % | Lines |
|---|---|---|
| [honeycombio/resource\_dataset\_definition.go](https://app.codecov.io/gh/honeycombio/terraform-provider-honeycombio/pull/559?src=pr&el=tree&filepath=honeycombio%2Fresource_dataset_definition.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=honeycombio#diff-aG9uZXljb21iaW8vcmVzb3VyY2VfZGF0YXNldF9kZWZpbml0aW9uLmdv) | 0.00% | [8 Missing :warning: ](https://app.codecov.io/gh/honeycombio/terraform-provider-honeycombio/pull/559?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=honeycombio) |
| [client/dataset\_definitions.go](https://app.codecov.io/gh/honeycombio/terraform-provider-honeycombio/pull/559?src=pr&el=tree&filepath=client%2Fdataset_definitions.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=honeycombio#diff-Y2xpZW50L2RhdGFzZXRfZGVmaW5pdGlvbnMuZ28=) | 66.66% | [2 Missing :warning: ](https://app.codecov.io/gh/honeycombio/terraform-provider-honeycombio/pull/559?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=honeycombio) |

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##             main     #559      +/-   ##
==========================================
- Coverage   78.82%   78.57%   -0.25%     
==========================================
  Files          86       86              
  Lines        6119     6133      +14     
==========================================
- Hits         4823     4819       -4     
- Misses        962      977      +15     
- Partials      334      337       +3     
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/honeycombio/terraform-provider-honeycombio/pull/559?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=honeycombio).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=honeycombio).


Patch:
diff --git a/client/dataset_definitions.go b/client/dataset_definitions.go
index 6c415bd..9e24f05 100644
--- a/client/dataset_definitions.go
+++ b/client/dataset_definitions.go
@@ -47,6 +47,8 @@ type DatasetDefinition struct {
 	AnnotationType *DefinitionColumn `json:"annotation_type,omitempty"`
 	LinkTraceID    *DefinitionColumn `json:"link_trace_id,omitempty"`
 	LinkSpanID     *DefinitionColumn `json:"link_span_id,omitempty"`
+	LogMessage     *DefinitionColumn `json:"log_message,omitempty"`
+	LogSeverity    *DefinitionColumn `json:"log_severity,omitempty"`
 	Status         *DefinitionColumn `json:"status,omitempty"`
 	TraceID        *DefinitionColumn `json:"trace_id,omitempty"`
 	User           *DefinitionColumn `json:"user,omitempty"`
@@ -72,6 +74,8 @@ func DatasetDefinitionFields() []string {
 		"annotation_type",
 		"link_trace_id",
 		"link_span_id",
+		"log_message",
+		"log_severity",
 		"status",
 		"trace_id",
 		"user",
@@ -92,6 +96,8 @@ func DatasetDefinitionDefaults() map[string][]string {
 		"annotation_type": {"meta.annotation_type"},
 		"link_trace_id":   {"trace.link.trace_id"},
 		"link_span_id":    {"trace.link.span_id", "trace.span_id"},
+		"log_message":     {"body"},
+		"log_severity":    {"severity"},
 		"status":          {"response.status_code", "http.status_code", "elb_status_code"},
 		"trace_id":        {"http.status_code", "trace.trace_id", "traceId"},
 		"user":            {"user.id", "user.email", "request.user.id", "request.user.username"},
@@ -117,6 +123,8 @@ func (s *datasetDefinitions) ResetAll(ctx context.Context, dataset string) error
 		AnnotationType: EmptyDatasetDefinition(),
 		LinkTraceID:    EmptyDatasetDefinition(),
 		LinkSpanID:     EmptyDatasetDefinition(),
+		LogMessage:     EmptyDatasetDefinition(),
+		LogSeverity:    EmptyDatasetDefinition(),
 		Status:         EmptyDatasetDefinition(),
 		TraceID:        EmptyDatasetDefinition(),
 		User:           EmptyDatasetDefinition(),
diff --git a/docs/resources/dataset_definitions.md b/docs/resources/dataset_definitions.md
index 0428dc3..ec2efab 100644
--- a/docs/resources/dataset_definitions.md
+++ b/docs/resources/dataset_definitions.md
@@ -33,6 +33,8 @@ Definition Name    | Description
 `annotation_type`  | Metadata: Annotation Type
 `link_span_id`     | Metadata: Link Span ID
 `link_trace_id`    | Metadata: Link Trace ID
+`log_message`      | Log Event Message
+`log_severity`     | Log Event Severity
 `name`             | Name
 `parent_id`        | Parent Span ID
 `route`            | Route
diff --git a/honeycombio/resource_dataset_definition.go b/honeycombio/resource_dataset_definition.go
index 65d4ce1..3f2c4a0 100644
--- a/honeycombio/resource_dataset_definition.go
+++ b/honeycombio/resource_dataset_definition.go
@@ -151,6 +151,10 @@ func extractDatasetDefinitionColumnByName(dd *honeycombio.DatasetDefinition, nam
 		return dd.LinkTraceID
 	case "link_span_id":
 		return dd.LinkSpanID
+	case "log_message":
+		return dd.LogMessage
+	case "log_severity":
+		return dd.LogSeverity
 	case "status":
 		return dd.Status
 	case "trace_id":
@@ -188,6 +192,10 @@ func expandDatasetDefinition(name, value string) *honeycombio.DatasetDefinition
 		definition.LinkTraceID = &honeycombio.DefinitionColumn{Name: value}
 	case "link_span_id":
 		definition.LinkSpanID = &honeycombio.DefinitionColumn{Name: value}
+	case "log_message":
+		definition.LogMessage = &honeycombio.DefinitionColumn{Name: value}
+	case "log_severity":
+		definition.LogSeverity = &honeycombio.DefinitionColumn{Name: value}
 	case "status":
 		definition.Status = &honeycombio.DefinitionColumn{Name: value}
 	case "trace_id":


Test patch:
diff --git a/client/dataset_definitions_test.go b/client/dataset_definitions_test.go
index e943be6..7573e69 100644
--- a/client/dataset_definitions_test.go
+++ b/client/dataset_definitions_test.go
@@ -39,8 +39,9 @@ func TestDatasetDefinitions(t *testing.T) {
 		{KeyName: "request.user.username", Type: client.ToPtr(client.ColumnTypeString)},
 		{KeyName: "trace.link.trace_id", Type: client.ToPtr(client.ColumnTypeString)},
 		{KeyName: "trace.link.span_id", Type: client.ToPtr(client.ColumnTypeString)},
+		{KeyName: "body", Type: client.ToPtr(client.ColumnTypeString)},
+		{KeyName: "severity", Type: client.ToPtr(client.ColumnTypeString)},
 	} {
-		//nolint:errcheck
 		// ignore errors, we don't care if the column already exists
 		c.Columns.Create(ctx, dataset, &col)
 	}
@@ -55,7 +56,6 @@ func TestDatasetDefinitions(t *testing.T) {
 	require.NoError(t, err)
 
 	// reset all defs and remove test helpers at end of test run
-	//nolint:errcheck
 	t.Cleanup(func() {
 		c.DatasetDefinitions.ResetAll(ctx, dataset)
 		c.Columns.Delete(ctx, dataset, testCol.ID)
@@ -79,6 +79,8 @@ func TestDatasetDefinitions(t *testing.T) {
 		assert.Contains(t, definitionDefaults["annotation_type"], result.AnnotationType.Name)
 		assert.Contains(t, definitionDefaults["link_trace_id"], result.LinkTraceID.Name)
 		assert.Contains(t, definitionDefaults["link_span_id"], result.LinkSpanID.Name)
+		assert.Contains(t, definitionDefaults["log_message"], result.LogMessage.Name)
+		assert.Contains(t, definitionDefaults["log_severity"], result.LogSeverity.Name)
 		assert.Contains(t, definitionDefaults["status"], result.Status.Name)
 		assert.Contains(t, definitionDefaults["trace_id"], result.TraceID.Name)
 		assert.Contains(t, definitionDefaults["user"], result.User.Name)