Skip to content

Commit 6beb01d

Browse files
authored
Add enrichment for error.grouping_name (#105)
1 parent 5b1b18a commit 6beb01d

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

enrichments/trace/config/config.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ type SpanEventConfig struct {
8888
ErrorID AttributeConfig `mapstructure:"error_id"`
8989
ErrorExceptionHandled AttributeConfig `mapstructure:"error_exception_handled"`
9090
ErrorGroupingKey AttributeConfig `mapstructure:"error_grouping_key"`
91-
92-
// For no exceptions/errors
93-
EventKind AttributeConfig `mapstructure:"event_kind"`
91+
ErrorGroupingName AttributeConfig `mapstructure:"error_grouping_name"`
9492
}
9593

9694
// AttributeConfig is the configuration options for each attribute.
@@ -141,7 +139,7 @@ func Enabled() Config {
141139
ErrorID: AttributeConfig{Enabled: true},
142140
ErrorExceptionHandled: AttributeConfig{Enabled: true},
143141
ErrorGroupingKey: AttributeConfig{Enabled: true},
144-
EventKind: AttributeConfig{Enabled: true},
142+
ErrorGroupingName: AttributeConfig{Enabled: true},
145143
},
146144
}
147145
}

enrichments/trace/internal/elastic/attributes.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,5 @@ const (
5353
AttributeErrorID = "error.id"
5454
AttributeErrorExceptionHandled = "error.exception.handled"
5555
AttributeErrorGroupingKey = "error.grouping_key"
56+
AttributeErrorGroupingName = "error.grouping_name"
5657
)

enrichments/trace/internal/elastic/span.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,11 @@ func (s *spanEventEnrichmentContext) enrich(
491491
}
492492
se.Attributes().PutStr(AttributeErrorGroupingKey, hex.EncodeToString(hash.Sum(nil)))
493493
}
494+
if cfg.ErrorGroupingName.Enabled {
495+
if s.exceptionMessage != "" {
496+
se.Attributes().PutStr(AttributeErrorGroupingName, s.exceptionMessage)
497+
}
498+
}
494499

495500
// Transaction type and sampled are added as span event enrichment only for errors
496501
if parentCtx.isTransaction && s.exception {

enrichments/trace/internal/elastic/span_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,7 @@ func TestSpanEventEnrich(t *testing.T) {
811811
hash.Write([]byte("java.net.ConnectionError"))
812812
return hex.EncodeToString(hash.Sum(nil))
813813
}(),
814+
AttributeErrorGroupingName: "something is wrong",
814815
AttributeTransactionSampled: true,
815816
AttributeTransactionType: "unknown",
816817
},
@@ -843,6 +844,7 @@ func TestSpanEventEnrich(t *testing.T) {
843844
hash.Write([]byte("java.net.ConnectionError"))
844845
return hex.EncodeToString(hash.Sum(nil))
845846
}(),
847+
AttributeErrorGroupingName: "something is wrong",
846848
},
847849
},
848850
} {

0 commit comments

Comments
 (0)