Skip to content

Commit

Permalink
updated factory to use GetCode function
Browse files Browse the repository at this point in the history
  • Loading branch information
daidokoro committed Oct 7, 2023
1 parent 260b4c1 commit 91d1f73
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions processor/starlarktransform/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,16 @@ func createLogsProcessor(
return nil, errors.New("invalid config type")
}

return logs.NewProcessor(ctx, set.Logger, config.Code, nextConsumer), nil
if err := config.validate(); err != nil {
return nil, err
}

code, err := config.GetCode()
if err != nil {
return nil, err
}

return logs.NewProcessor(ctx, set.Logger, code, nextConsumer), nil
}

func createMetricsProcessor(
Expand All @@ -56,7 +65,16 @@ func createMetricsProcessor(
return nil, errors.New("invalid config type")
}

return metrics.NewProcessor(ctx, set.Logger, config.Code, nextConsumer), nil
if err := config.validate(); err != nil {
return nil, err
}

code, err := config.GetCode()
if err != nil {
return nil, err
}

return metrics.NewProcessor(ctx, set.Logger, code, nextConsumer), nil
}

func createTracesProcessor(
Expand All @@ -70,5 +88,14 @@ func createTracesProcessor(
return nil, errors.New("invalid config type")
}

return traces.NewProcessor(ctx, set.Logger, config.Code, nextConsumer), nil
if err := config.validate(); err != nil {
return nil, err
}

code, err := config.GetCode()
if err != nil {
return nil, err
}

return traces.NewProcessor(ctx, set.Logger, code, nextConsumer), nil
}

0 comments on commit 91d1f73

Please sign in to comment.