@@ -83,7 +83,47 @@ func (obs *observerHandler) OnAdd(added []observer.Endpoint) {
83
83
continue
84
84
}
85
85
86
- obs .params .TelemetrySettings .Logger .Debug ("handling added endpoint" , zap .Any ("env" , env ))
86
+ obs .params .TelemetrySettings .Logger .Info ("handling added endpoint" , zap .Any ("env" , env ))
87
+
88
+ ann := env ["annotations" ]
89
+ if ann != nil {
90
+ annotations , ok := ann .(map [string ]string )
91
+ if ! ok {
92
+ // Can't assert, handle error.
93
+ }
94
+ if len (annotations ) > 0 {
95
+ // detect if there are hints
96
+ subreceiverKey := annotations ["otel.hints/receiver" ]
97
+ if subreceiverKey == "" {
98
+ break
99
+ }
100
+ obs .params .TelemetrySettings .Logger .Warn ("handling added hinted receiver" , zap .Any ("subreceiverKey" , subreceiverKey ))
101
+
102
+ userConfigMap := userConfigMap {"collection_interval" : "10s" }
103
+ subreceiverEndpoint := annotations ["otel.hints/endpoint" ]
104
+ if subreceiverEndpoint == "" {
105
+ break
106
+ }
107
+ userConfigMap ["endpoint" ] = subreceiverEndpoint
108
+ subreceiver , err := newReceiverTemplate (subreceiverKey , userConfigMap )
109
+ if err != nil {
110
+ // TODO: handle error here
111
+ obs .params .TelemetrySettings .Logger .Debug ("error adding subreceiver1" , zap .Any ("err" , err ))
112
+ break
113
+ }
114
+
115
+ subreceiver .Rule = "type == \" pod\" "
116
+ subreceiver .rule , err = newRule (subreceiver .Rule )
117
+ if err != nil {
118
+ // TODO: handle error here
119
+ obs .params .TelemetrySettings .Logger .Debug ("error adding subreceiver rule" , zap .Any ("err" , err ))
120
+ break
121
+ }
122
+
123
+ obs .config .receiverTemplates [subreceiverKey ] = subreceiver
124
+ }
125
+ }
126
+ obs .params .TelemetrySettings .Logger .Debug ("handling added templates" , zap .Any ("templates" , obs .config .receiverTemplates ))
87
127
88
128
for _ , template := range obs .config .receiverTemplates {
89
129
if matches , e := template .rule .eval (env ); e != nil {
@@ -96,7 +136,8 @@ func (obs *observerHandler) OnAdd(added []observer.Endpoint) {
96
136
obs .params .TelemetrySettings .Logger .Info ("starting receiver" ,
97
137
zap .String ("name" , template .id .String ()),
98
138
zap .String ("endpoint" , e .Target ),
99
- zap .String ("endpoint_id" , string (e .ID )))
139
+ zap .String ("endpoint_id" , string (e .ID )),
140
+ zap .Any ("config" , template .config ))
100
141
101
142
resolvedConfig , err := expandConfig (template .config , env )
102
143
if err != nil {
0 commit comments