@@ -21,6 +21,7 @@ package internal
2121
2222import (
2323 "context"
24+ "strings"
2425
2526 "go.opentelemetry.io/collector/component"
2627 "go.opentelemetry.io/collector/component/componenttest"
@@ -68,20 +69,46 @@ func (p *processorExecutor[C]) parseConfig(yamlConfig string) (*C, error) {
6869 return nil , err
6970 }
7071
71- yamlConfigMap , err := deserializedYaml .AsConf ()
72+ deserializedConf , err := deserializedYaml .AsConf ()
7273 if err != nil {
7374 return nil , err
7475 }
7576
77+ configMap := make (map [string ]any )
78+ for k , v := range deserializedConf .ToStringMap () {
79+ configMap [k ] = escapeDollarSigns (v )
80+ }
81+
7682 defaultConfig := p .factory .CreateDefaultConfig ().(* C )
77- err = yamlConfigMap .Unmarshal (& defaultConfig )
83+ err = confmap . NewFromStringMap ( configMap ) .Unmarshal (& defaultConfig )
7884 if err != nil {
7985 return nil , err
8086 }
8187
8288 return defaultConfig , nil
8389}
8490
91+ func escapeDollarSigns (val any ) any {
92+ switch v := val .(type ) {
93+ case string :
94+ return strings .ReplaceAll (v , "$$" , "$" )
95+ case []any :
96+ escapedVals := make ([]any , len (v ))
97+ for i , x := range v {
98+ escapedVals [i ] = escapeDollarSigns (x )
99+ }
100+ return escapedVals
101+ case map [string ]any :
102+ escapedMap := make (map [string ]any , len (v ))
103+ for k , x := range v {
104+ escapedMap [k ] = escapeDollarSigns (x )
105+ }
106+ return escapedMap
107+ default :
108+ return val
109+ }
110+ }
111+
85112func (p * processorExecutor [C ]) ExecuteLogStatements (yamlConfig , input string ) ([]byte , error ) {
86113 config , err := p .parseConfig (yamlConfig )
87114 if err != nil {
0 commit comments