Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exporter/datadogexporter: allow more trace-agents #18248

Merged
merged 2 commits into from
Feb 3, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
exporter/datadogexporter: allow more trace-agents
This change ensures that each receiver instantiated by the factory uses
its own pkg/trace/agent instance to facilitate multiple API endpoints.
  • Loading branch information
gbbr committed Feb 2, 2023
commit 485bc3ba636996b73c88e34e9abb649621ac311f
29 changes: 11 additions & 18 deletions exporter/datadogexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ type factory struct {
sourceProvider source.Provider
providerErr error

onceAgent sync.Once // ensures agent only gets instantiated once
wg sync.WaitGroup // waits for agent to exit
agent *agent.Agent // agent processes incoming traces and stats
gbbr marked this conversation as resolved.
Show resolved Hide resolved
agentErr error // specifies any error occurred while instantiating agent
wg sync.WaitGroup // waits for agent to exit

registry *featuregate.Registry
}
Expand All @@ -89,20 +86,16 @@ func (f *factory) SourceProvider(set component.TelemetrySettings, configHostname
}

func (f *factory) TraceAgent(ctx context.Context, params exporter.CreateSettings, cfg *Config, sourceProvider source.Provider) (*agent.Agent, error) {
f.onceAgent.Do(func() {
agnt, err := newTraceAgent(ctx, params, cfg, sourceProvider)
if err != nil {
f.agentErr = err
return
}
f.wg.Add(1)
go func() {
defer f.wg.Done()
agnt.Run()
}()
f.agent = agnt
})
return f.agent, f.agentErr
agnt, err := newTraceAgent(ctx, params, cfg, sourceProvider)
if err != nil {
return nil, err
}
f.wg.Add(1)
go func() {
defer f.wg.Done()
agnt.Run()
}()
return agnt, nil
}

func newFactoryWithRegistry(registry *featuregate.Registry) exporter.Factory {
Expand Down