MCPcopy
hub / github.com/grafana/tempo / createCore

Function createCore

tempodb/backend/s3/s3.go:729–784  ·  view source on GitHub ↗
(cfg *Config, hedge bool)

Source from the content-addressed store, hash-verified

727}
728
729func createCore(cfg *Config, hedge bool) (*minio.Core, error) {
730 creds, err := fetchCreds(cfg)
731 if err != nil {
732 return nil, fmt.Errorf("failed to fetch credentials: %w", err)
733 }
734
735 customTransport, err := minio.DefaultTransport(!cfg.Insecure)
736 if err != nil {
737 return nil, fmt.Errorf("create minio.DefaultTransport: %w", err)
738 }
739
740 /* minio sets MaxIdleConns to 100 but we should also increase per host to 100 */
741 customTransport.MaxIdleConnsPerHost = 100
742 customTransport.MaxIdleConns = 100
743
744 tlsConfig, err := cfg.GetTLSConfig()
745 if err != nil {
746 return nil, fmt.Errorf("failed to create TLS config: %w", err)
747 }
748
749 if tlsConfig != nil {
750 customTransport.TLSClientConfig = tlsConfig
751 }
752
753 // add instrumentation
754 transport := instrumentation.NewTransport(customTransport)
755 var stats *hedgedhttp.Stats
756 if hedge && cfg.HedgeRequestsAt != 0 {
757 transport, stats, err = hedgedhttp.NewRoundTripperAndStats(cfg.HedgeRequestsAt, cfg.HedgeRequestsUpTo, transport)
758 if err != nil {
759 return nil, err
760 }
761 instrumentation.PublishHedgedMetrics(stats)
762 }
763
764 opts := &minio.Options{
765 Region: cfg.Region,
766 Secure: !cfg.Insecure,
767 Creds: creds,
768 Transport: transport,
769 }
770
771 if cfg.ForcePathStyle {
772 opts.BucketLookup = minio.BucketLookupPath
773 } else {
774 opts.BucketLookup = minio.BucketLookupType(cfg.BucketLookupType)
775 }
776
777 core, err := minio.NewCore(cfg.Endpoint, opts)
778 if err != nil {
779 return nil, fmt.Errorf("failed to create minio client: %w", err)
780 }
781
782 core.SetS3EnableDualstack(cfg.UseDualStack)
783 return core, err
784}
785
786func readError(err error) error {

Callers 1

internalNewFunction · 0.85

Calls 3

NewTransportFunction · 0.92
PublishHedgedMetricsFunction · 0.92
fetchCredsFunction · 0.85

Tested by

no test coverage detected