in cmd/apmtool/tracegen.go [32:62]
func (cmd *Commands) sendTrace(ctx context.Context, c *cli.Command) error {
creds, err := cmd.getCredentials(ctx, c)
if err != nil {
return err
}
cfg := tracegen.NewConfig(
tracegen.WithAPMServerURL(cmd.cfg.APMServerURL),
tracegen.WithAPIKey(creds.APIKey),
tracegen.WithSampleRate(c.Float("sample-rate")),
tracegen.WithInsecureConn(cmd.cfg.TLSSkipVerify),
tracegen.WithOTLPProtocol(c.String("otlp-protocol")),
tracegen.WithOTLPServiceName(newUniqueServiceName("service", "otlp")),
tracegen.WithElasticAPMServiceName(newUniqueServiceName("service", "intake")),
)
ctx, cancel := signal.NotifyContext(context.Background(), os.Kill, os.Interrupt)
defer cancel()
stats, err := tracegen.SendDistributedTrace(ctx, cfg)
if err != nil {
return fmt.Errorf("error sending distributed trace: %w", err)
}
fmt.Printf(
"Sent %d span%s, %d exception%s, and %d log%s\n",
stats.SpansSent, pluralize(stats.SpansSent),
stats.ExceptionsSent, pluralize(stats.ExceptionsSent),
stats.LogsSent, pluralize(stats.LogsSent),
)
return nil
}