@@ -92,14 +92,11 @@ func (e *baseExporter) shutdown(context.Context) error {
92
92
return nil
93
93
}
94
94
95
- func (e * baseExporter ) pushTraces (ctx context.Context , td ptrace.Traces ) (err error ) {
96
- defer func () {
97
- e .reportStatusFromError (err )
98
- }()
95
+ func (e * baseExporter ) pushTraces (ctx context.Context , td ptrace.Traces ) error {
99
96
req := ptraceotlp .NewExportRequestFromTraces (td )
100
97
resp , respErr := e .traceExporter .Export (e .enhanceContext (ctx ), req , e .callOptions ... )
101
- if err = processError (respErr ); err != nil {
102
- return
98
+ if err : = processError (respErr ); err != nil {
99
+ return err
103
100
}
104
101
partialSuccess := resp .PartialSuccess ()
105
102
if ! (partialSuccess .ErrorMessage () == "" && partialSuccess .RejectedSpans () == 0 ) {
@@ -108,17 +105,23 @@ func (e *baseExporter) pushTraces(ctx context.Context, td ptrace.Traces) (err er
108
105
zap .Int64 ("dropped_spans" , resp .PartialSuccess ().RejectedSpans ()),
109
106
)
110
107
}
111
- return
108
+ return nil
109
+ }
110
+
111
+ func (e * baseExporter ) pushTracesWithStatus (ctx context.Context , td ptrace.Traces ) error {
112
+ if err := e .pushTraces (ctx , td ); err != nil {
113
+ componentstatus .ReportStatus (e .host , componentstatus .NewRecoverableErrorEvent (err ))
114
+ return err
115
+ }
116
+ componentstatus .ReportStatus (e .host , componentstatus .NewEvent (componentstatus .StatusOK ))
117
+ return nil
112
118
}
113
119
114
- func (e * baseExporter ) pushMetrics (ctx context.Context , md pmetric.Metrics ) (err error ) {
115
- defer func () {
116
- e .reportStatusFromError (err )
117
- }()
120
+ func (e * baseExporter ) pushMetrics (ctx context.Context , md pmetric.Metrics ) error {
118
121
req := pmetricotlp .NewExportRequestFromMetrics (md )
119
122
resp , respErr := e .metricExporter .Export (e .enhanceContext (ctx ), req , e .callOptions ... )
120
- if err = processError (respErr ); err != nil {
121
- return
123
+ if err : = processError (respErr ); err != nil {
124
+ return err
122
125
}
123
126
partialSuccess := resp .PartialSuccess ()
124
127
if ! (partialSuccess .ErrorMessage () == "" && partialSuccess .RejectedDataPoints () == 0 ) {
@@ -127,17 +130,23 @@ func (e *baseExporter) pushMetrics(ctx context.Context, md pmetric.Metrics) (err
127
130
zap .Int64 ("dropped_data_points" , resp .PartialSuccess ().RejectedDataPoints ()),
128
131
)
129
132
}
130
- return
133
+ return nil
131
134
}
132
135
133
- func (e * baseExporter ) pushLogs (ctx context.Context , ld plog.Logs ) (err error ) {
134
- defer func () {
135
- e .reportStatusFromError (err )
136
- }()
136
+ func (e * baseExporter ) pushMetricsWithStatus (ctx context.Context , md pmetric.Metrics ) error {
137
+ if err := e .pushMetrics (ctx , md ); err != nil {
138
+ componentstatus .ReportStatus (e .host , componentstatus .NewRecoverableErrorEvent (err ))
139
+ return err
140
+ }
141
+ componentstatus .ReportStatus (e .host , componentstatus .NewEvent (componentstatus .StatusOK ))
142
+ return nil
143
+ }
144
+
145
+ func (e * baseExporter ) pushLogs (ctx context.Context , ld plog.Logs ) error {
137
146
req := plogotlp .NewExportRequestFromLogs (ld )
138
147
resp , respErr := e .logExporter .Export (e .enhanceContext (ctx ), req , e .callOptions ... )
139
- if err = processError (respErr ); err != nil {
140
- return
148
+ if err : = processError (respErr ); err != nil {
149
+ return err
141
150
}
142
151
partialSuccess := resp .PartialSuccess ()
143
152
if ! (partialSuccess .ErrorMessage () == "" && partialSuccess .RejectedLogRecords () == 0 ) {
@@ -146,7 +155,16 @@ func (e *baseExporter) pushLogs(ctx context.Context, ld plog.Logs) (err error) {
146
155
zap .Int64 ("dropped_log_records" , resp .PartialSuccess ().RejectedLogRecords ()),
147
156
)
148
157
}
149
- return
158
+ return nil
159
+ }
160
+
161
+ func (e * baseExporter ) pushLogsWithStatus (ctx context.Context , ld plog.Logs ) error {
162
+ if err := e .pushLogs (ctx , ld ); err != nil {
163
+ componentstatus .ReportStatus (e .host , componentstatus .NewRecoverableErrorEvent (err ))
164
+ return err
165
+ }
166
+ componentstatus .ReportStatus (e .host , componentstatus .NewEvent (componentstatus .StatusOK ))
167
+ return nil
150
168
}
151
169
152
170
func (e * baseExporter ) pushProfiles (ctx context.Context , td pprofile.Profiles ) error {
@@ -165,6 +183,15 @@ func (e *baseExporter) pushProfiles(ctx context.Context, td pprofile.Profiles) e
165
183
return nil
166
184
}
167
185
186
+ func (e * baseExporter ) pushProfilesWithStatus (ctx context.Context , td pprofile.Profiles ) error {
187
+ if err := e .pushProfiles (ctx , td ); err != nil {
188
+ componentstatus .ReportStatus (e .host , componentstatus .NewRecoverableErrorEvent (err ))
189
+ return err
190
+ }
191
+ componentstatus .ReportStatus (e .host , componentstatus .NewEvent (componentstatus .StatusOK ))
192
+ return nil
193
+ }
194
+
168
195
func (e * baseExporter ) enhanceContext (ctx context.Context ) context.Context {
169
196
if e .metadata .Len () > 0 {
170
197
return metadata .NewOutgoingContext (ctx , e .metadata )
@@ -203,14 +230,6 @@ func processError(err error) error {
203
230
return err
204
231
}
205
232
206
- func (e * baseExporter ) reportStatusFromError (err error ) {
207
- if err != nil {
208
- componentstatus .ReportStatus (e .host , componentstatus .NewRecoverableErrorEvent (err ))
209
- return
210
- }
211
- componentstatus .ReportStatus (e .host , componentstatus .NewEvent (componentstatus .StatusOK ))
212
- }
213
-
214
233
func shouldRetry (code codes.Code , retryInfo * errdetails.RetryInfo ) bool {
215
234
switch code {
216
235
case codes .Canceled ,
0 commit comments