Skip to content

Commit

Permalink
refactor variable names in mockReceiver
Browse files Browse the repository at this point in the history
  • Loading branch information
omrozowicz-splunk committed Aug 1, 2023
1 parent 9f12a3c commit 8ba4c25
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions exporter/exportertest/mock_receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ func (r *mockReceiver) setExportErrorFunction(decisionFunction func() error) {
func (r *mockLogsReceiver) Export(_ context.Context, req plogotlp.ExportRequest) (plogotlp.ExportResponse, error) {
r.reqCounter.total++
generatedError := r.exportErrorFunction()
logs, _ := idFromLogs(req.Logs())
logId, _ := idFromLogs(req.Logs())
if generatedError != nil {
r.processError(generatedError, "log", logs)
r.processError(generatedError, "log", logId)
return r.exportResponse(), generatedError
}
fmt.Println("Successfully sent log number:", logs)
fmt.Println("Successfully sent log number:", logId)
ld := req.Logs()
r.mux.Lock()
defer r.mux.Unlock()
Expand All @@ -105,12 +105,12 @@ func (r *mockLogsReceiver) Export(_ context.Context, req plogotlp.ExportRequest)
func (r *mockTracesReceiver) Export(_ context.Context, req ptraceotlp.ExportRequest) (ptraceotlp.ExportResponse, error) {
r.reqCounter.total++
generatedError := r.exportErrorFunction()
traces, _ := idFromTraces(req.Traces())
traceId, _ := idFromTraces(req.Traces())
if generatedError != nil {
r.processError(generatedError, "trace", traces)
r.processError(generatedError, "trace", traceId)
return r.exportResponse(), generatedError
}
fmt.Println("Successfully sent trace number:", traces)
fmt.Println("Successfully sent trace number:", traceId)
td := req.Traces()
r.mux.Lock()
defer r.mux.Unlock()
Expand All @@ -122,12 +122,12 @@ func (r *mockTracesReceiver) Export(_ context.Context, req ptraceotlp.ExportRequ
func (r *mockMetricsReceiver) Export(_ context.Context, req pmetricotlp.ExportRequest) (pmetricotlp.ExportResponse, error) {
r.reqCounter.total++
generatedError := r.exportErrorFunction()
traces, _ := idFromMetrics(req.Metrics())
metricId, _ := idFromMetrics(req.Metrics())
if generatedError != nil {
r.processError(generatedError, "metric", traces)
r.processError(generatedError, "metric", metricId)
return r.exportResponse(), generatedError
}
fmt.Println("Successfully sent metric number:", traces)
fmt.Println("Successfully sent metric number:", metricId)
md := req.Metrics()
r.mux.Lock()
defer r.mux.Unlock()
Expand All @@ -136,14 +136,14 @@ func (r *mockMetricsReceiver) Export(_ context.Context, req pmetricotlp.ExportRe
return r.exportResponse(), nil
}

func (r *mockReceiver) processError(err error, dataType string, numberOfElements string) {
func (r *mockReceiver) processError(err error, dataType string, idOfElement string) {
if consumererror.IsPermanent(err) {
fmt.Println("permanent error happened")
fmt.Printf("Dropping %s number: %s\n", dataType, numberOfElements)
fmt.Printf("Dropping %s number: %s\n", dataType, idOfElement)
r.reqCounter.error.permanent++
} else {
fmt.Println("non-permanent error happened")
fmt.Printf("Retrying %s number: %s\n", dataType, numberOfElements)
fmt.Printf("Retrying %s number: %s\n", dataType, idOfElement)
r.reqCounter.error.nonpermanent++
}
}
Expand Down

0 comments on commit 8ba4c25

Please sign in to comment.