Clarify behaviour of enum processor without default or defined mapping (#6301)
This commit is contained in:
parent
c67674eff3
commit
da17d6569d
|
@ -25,8 +25,8 @@ source tag or field is overwritten.
|
||||||
dest = "status_code"
|
dest = "status_code"
|
||||||
|
|
||||||
## Default value to be used for all values not contained in the mapping
|
## Default value to be used for all values not contained in the mapping
|
||||||
## table. When unset, the unmodified value for the field will be used if no
|
## table. When unset and no match is found, the original field will remain
|
||||||
## match is found.
|
## unmodified and the destination tag or field will not be created.
|
||||||
# default = 0
|
# default = 0
|
||||||
|
|
||||||
## Table of mappings
|
## Table of mappings
|
||||||
|
@ -42,3 +42,9 @@ source tag or field is overwritten.
|
||||||
- xyzzy status="green" 1502489900000000000
|
- xyzzy status="green" 1502489900000000000
|
||||||
+ xyzzy status="green",status_code=1i 1502489900000000000
|
+ xyzzy status="green",status_code=1i 1502489900000000000
|
||||||
```
|
```
|
||||||
|
|
||||||
|
With unknown value and no default set:
|
||||||
|
```diff
|
||||||
|
- xyzzy status="black" 1502489900000000000
|
||||||
|
+ xyzzy status="black" 1502489900000000000
|
||||||
|
```
|
||||||
|
|
|
@ -123,3 +123,14 @@ func TestWritesToDestination(t *testing.T) {
|
||||||
assertFieldValue(t, "test", "string_value", fields)
|
assertFieldValue(t, "test", "string_value", fields)
|
||||||
assertFieldValue(t, 1, "string_code", fields)
|
assertFieldValue(t, 1, "string_code", fields)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDoNotWriteToDestinationWithoutDefaultOrDefinedMapping(t *testing.T) {
|
||||||
|
field := "string_code"
|
||||||
|
mapper := EnumMapper{Mappings: []Mapping{{Field: "string_value", Dest: field, ValueMappings: map[string]interface{}{"other": int64(1)}}}}
|
||||||
|
|
||||||
|
fields := calculateProcessedValues(mapper, createTestMetric())
|
||||||
|
|
||||||
|
assertFieldValue(t, "test", "string_value", fields)
|
||||||
|
_, present := fields[field]
|
||||||
|
assert.False(t, present, "value of field '"+field+"' was present")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue