Skip to content

Commit

Permalink
eventbus supports configurable
Browse files Browse the repository at this point in the history
Signed-off-by: jyjiangkai <[email protected]>
  • Loading branch information
hwjiangkai committed Jul 14, 2023
1 parent 7ddd6ed commit 9d87e96
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions observability/tracing/exporter/event_trace_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ type Option func(*Options)

type Options struct {
Endpoints string
Eventbus string
}

func defaultOptions() *Options {
return &Options{
Endpoints: "127.0.0.1:8080",
Eventbus: "event-tracing",
}
}

Expand All @@ -44,6 +46,12 @@ func WithEndpoint(endpoint string) Option {
}
}

func WithEventbus(eventbus string) Option {
return func(options *Options) {
options.Eventbus = eventbus
}
}

// Exporter exports trace data in the OTLP wire format.
type Exporter struct {
endpoints string
Expand Down
5 changes: 4 additions & 1 deletion observability/tracing/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type Config struct {
OtelCollector string `yaml:"otel_collector"`
EventTracingEnable bool `yaml:"event_tracing_enable"`
EventCollector string `yaml:"event_collector"`
Eventbus string `yaml:"eventbus"`
}

var tp *tracerProvider
Expand Down Expand Up @@ -188,7 +189,9 @@ func newTracerProvider(serviceName string, cfg Config) (*trace.TracerProvider, e

if cfg.EventTracingEnable && cfg.EventCollector != "" {
// Set up a event exporter
eventExporter, err := exporter.New(ctx, exporter.WithEndpoint(cfg.EventCollector))
endpoint := exporter.WithEndpoint(cfg.EventCollector)
eventbus := exporter.WithEventbus(cfg.Eventbus)
eventExporter, err := exporter.New(ctx, endpoint, eventbus)
if err != nil {
return nil, fmt.Errorf("failed to create event exporter: %w", err)
}
Expand Down

0 comments on commit 9d87e96

Please sign in to comment.