diff --git a/go.mod b/go.mod index 6c198021066ac..7650cc94b1e61 100644 --- a/go.mod +++ b/go.mod @@ -73,6 +73,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/sts v1.33.2 github.com/aws/aws-sigv4-auth-cassandra-gocql-driver-plugin v1.1.0 github.com/aws/smithy-go v1.22.1 + github.com/aws/smithy-go/tracing/smithyoteltracing v1.0.2 github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20241128053516-b9e7404a33c3 github.com/beevik/etree v1.4.1 github.com/buildkite/bintest/v3 v3.3.0 @@ -187,7 +188,6 @@ require ( go.etcd.io/etcd/api/v3 v3.5.17 go.etcd.io/etcd/client/v3 v3.5.17 go.mongodb.org/mongo-driver v1.14.0 - go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws v0.57.0 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.57.0 go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.57.0 go.opentelemetry.io/otel v1.32.0 diff --git a/go.sum b/go.sum index b98562123abbd..07313c8afecaa 100644 --- a/go.sum +++ b/go.sum @@ -950,6 +950,8 @@ github.com/aws/aws-sigv4-auth-cassandra-gocql-driver-plugin v1.1.0/go.mod h1:AxK github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/aws/smithy-go v1.22.1 h1:/HPHZQ0g7f4eUeK6HKglFz8uwVfZKgoI25rb/J+dnro= github.com/aws/smithy-go v1.22.1/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= +github.com/aws/smithy-go/tracing/smithyoteltracing v1.0.2 h1:QRzksLadP0+ddubqgdVrmNlGWEwv2c4gyZXG7wrx+V8= +github.com/aws/smithy-go/tracing/smithyoteltracing v1.0.2/go.mod h1:ZQD5d3TZpTct86y+1Q8pvnhp/BB1UTRUZXEyLyV7eC8= github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20241128053516-b9e7404a33c3 h1:Z0GhCczQLlS/GRRS/suhoVxqU4Oz4CftHRd+Kdj22Uo= github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20241128053516-b9e7404a33c3/go.mod h1:7GP/HkcmpkFy6JyDSTKfdN6PNWCpMgsVMpwTkQwvVc4= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= @@ -2289,8 +2291,6 @@ go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= go.opentelemetry.io/contrib/detectors/gcp v1.29.0 h1:TiaiXB4DpGD3sdzNlYQxruQngn5Apwzi1X0DRhuGvDQ= go.opentelemetry.io/contrib/detectors/gcp v1.29.0/go.mod h1:GW2aWZNwR2ZxDLdv8OyC2G8zkRoQBuURgV7RPQgcPoU= -go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws v0.57.0 h1:G47XgH32CEM1I9kZ8xrVExSxivATGHNE0tdxuqlx9MQ= -go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws v0.57.0/go.mod h1:aqXlYGrumc8b/n4z9eDHHoiLN4fq2DAO//wMnqdxPhg= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.57.0 h1:qtFISDHKolvIxzSs0gIaiPUPR0Cucb0F2coHC7ZLdps= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.57.0/go.mod h1:Y+Pop1Q6hCOnETWTW4NROK/q1hv50hM7yDaUTjG8lp8= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.57.0 h1:DheMAlT6POBP+gh8RUH19EOTnQIor5QE0uSRPtzCpSw= diff --git a/integrations/event-handler/go.mod b/integrations/event-handler/go.mod index fe793f8d2028e..db319df633827 100644 --- a/integrations/event-handler/go.mod +++ b/integrations/event-handler/go.mod @@ -94,6 +94,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.6 // indirect github.com/aws/aws-sdk-go-v2/service/sts v1.33.2 // indirect github.com/aws/smithy-go v1.22.1 // indirect + github.com/aws/smithy-go/tracing/smithyoteltracing v1.0.2 // indirect github.com/beevik/etree v1.4.1 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/blang/semver/v4 v4.0.0 // indirect diff --git a/integrations/event-handler/go.sum b/integrations/event-handler/go.sum index a1c4a0e0ba948..87936090e79db 100644 --- a/integrations/event-handler/go.sum +++ b/integrations/event-handler/go.sum @@ -791,6 +791,8 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.33.2 h1:s4074ZO1Hk8qv65GqNXqDjmkf4HS github.com/aws/aws-sdk-go-v2/service/sts v1.33.2/go.mod h1:mVggCnIWoM09jP71Wh+ea7+5gAp53q+49wDFs1SW5z8= github.com/aws/smithy-go v1.22.1 h1:/HPHZQ0g7f4eUeK6HKglFz8uwVfZKgoI25rb/J+dnro= github.com/aws/smithy-go v1.22.1/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= +github.com/aws/smithy-go/tracing/smithyoteltracing v1.0.2 h1:QRzksLadP0+ddubqgdVrmNlGWEwv2c4gyZXG7wrx+V8= +github.com/aws/smithy-go/tracing/smithyoteltracing v1.0.2/go.mod h1:ZQD5d3TZpTct86y+1Q8pvnhp/BB1UTRUZXEyLyV7eC8= github.com/beevik/etree v1.1.0/go.mod h1:r8Aw8JqVegEf0w2fDnATrX9VpkMcyFeM0FhwO62wh+A= github.com/beevik/etree v1.4.1 h1:PmQJDDYahBGNKDcpdX8uPy1xRCwoCGVUiW669MEirVI= github.com/beevik/etree v1.4.1/go.mod h1:gPNJNaBGVZ9AwsidazFZyygnd+0pAU38N4D+WemwKNs= diff --git a/integrations/terraform/go.mod b/integrations/terraform/go.mod index 7c255cad63724..5dfbfe9091e37 100644 --- a/integrations/terraform/go.mod +++ b/integrations/terraform/go.mod @@ -107,6 +107,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.6 // indirect github.com/aws/aws-sdk-go-v2/service/sts v1.33.2 // indirect github.com/aws/smithy-go v1.22.1 // indirect + github.com/aws/smithy-go/tracing/smithyoteltracing v1.0.2 // indirect github.com/beevik/etree v1.4.1 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/speakeasy v0.1.0 // indirect diff --git a/integrations/terraform/go.sum b/integrations/terraform/go.sum index 1fcb3d41059a9..4a6ebfdad146b 100644 --- a/integrations/terraform/go.sum +++ b/integrations/terraform/go.sum @@ -866,6 +866,8 @@ github.com/aws/aws-sigv4-auth-cassandra-gocql-driver-plugin v1.1.0 h1:EJsHUYgFBV github.com/aws/aws-sigv4-auth-cassandra-gocql-driver-plugin v1.1.0/go.mod h1:AxKuXHc0zv2yYaeueUG7R3ONbcnQIuDj0bkdFmPVRzU= github.com/aws/smithy-go v1.22.1 h1:/HPHZQ0g7f4eUeK6HKglFz8uwVfZKgoI25rb/J+dnro= github.com/aws/smithy-go v1.22.1/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= +github.com/aws/smithy-go/tracing/smithyoteltracing v1.0.2 h1:QRzksLadP0+ddubqgdVrmNlGWEwv2c4gyZXG7wrx+V8= +github.com/aws/smithy-go/tracing/smithyoteltracing v1.0.2/go.mod h1:ZQD5d3TZpTct86y+1Q8pvnhp/BB1UTRUZXEyLyV7eC8= github.com/beevik/etree v1.1.0/go.mod h1:r8Aw8JqVegEf0w2fDnATrX9VpkMcyFeM0FhwO62wh+A= github.com/beevik/etree v1.4.1 h1:PmQJDDYahBGNKDcpdX8uPy1xRCwoCGVUiW669MEirVI= github.com/beevik/etree v1.4.1/go.mod h1:gPNJNaBGVZ9AwsidazFZyygnd+0pAU38N4D+WemwKNs= @@ -1947,8 +1949,6 @@ go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= go.opentelemetry.io/contrib/detectors/gcp v1.29.0 h1:TiaiXB4DpGD3sdzNlYQxruQngn5Apwzi1X0DRhuGvDQ= go.opentelemetry.io/contrib/detectors/gcp v1.29.0/go.mod h1:GW2aWZNwR2ZxDLdv8OyC2G8zkRoQBuURgV7RPQgcPoU= -go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws v0.57.0 h1:G47XgH32CEM1I9kZ8xrVExSxivATGHNE0tdxuqlx9MQ= -go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws v0.57.0/go.mod h1:aqXlYGrumc8b/n4z9eDHHoiLN4fq2DAO//wMnqdxPhg= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.57.0 h1:qtFISDHKolvIxzSs0gIaiPUPR0Cucb0F2coHC7ZLdps= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.57.0/go.mod h1:Y+Pop1Q6hCOnETWTW4NROK/q1hv50hM7yDaUTjG8lp8= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.57.0 h1:DheMAlT6POBP+gh8RUH19EOTnQIor5QE0uSRPtzCpSw= diff --git a/lib/auth/join/iam/iam.go b/lib/auth/join/iam/iam.go index f381912a56ad2..aa69ebd26d521 100644 --- a/lib/auth/join/iam/iam.go +++ b/lib/auth/join/iam/iam.go @@ -29,7 +29,9 @@ import ( "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/service/sts" smithyendpoints "github.com/aws/smithy-go/endpoints" + "github.com/aws/smithy-go/tracing/smithyoteltracing" "github.com/gravitational/trace" + "go.opentelemetry.io/otel" cloudaws "github.com/gravitational/teleport/lib/cloud/imds/aws" ) @@ -112,6 +114,8 @@ func CreateSignedSTSIdentityRequest(ctx context.Context, challenge string, opts // httpRequestRecorder intentionally records the request and returns // an error, don't retry. stsOpts.RetryMaxAttempts = 1 + + stsOpts.TracerProvider = smithyoteltracing.Adapt(otel.GetTracerProvider()) }) if _, err = stsClient.GetCallerIdentity(ctx, &sts.GetCallerIdentityInput{}); !errors.Is(err, errRequestRecorded) { diff --git a/lib/auth/join_ec2.go b/lib/auth/join_ec2.go index 72622caedd35f..0b5cf51252cef 100644 --- a/lib/auth/join_ec2.go +++ b/lib/auth/join_ec2.go @@ -34,9 +34,11 @@ import ( "github.com/aws/aws-sdk-go-v2/service/ec2" ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types" "github.com/aws/aws-sdk-go-v2/service/sts" + "github.com/aws/smithy-go/tracing/smithyoteltracing" "github.com/digitorus/pkcs7" "github.com/gravitational/trace" "github.com/jonboulle/clockwork" + "go.opentelemetry.io/otel" "github.com/gravitational/teleport/api/types" "github.com/gravitational/teleport/lib/services" @@ -61,7 +63,9 @@ func ec2ClientFromConfig(ctx context.Context, cfg aws.Config) ec2Client { if ok { return ec2Client } - return ec2.NewFromConfig(cfg) + return ec2.NewFromConfig(cfg, func(o *ec2.Options) { + o.TracerProvider = smithyoteltracing.Adapt(otel.GetTracerProvider()) + }) } // checkEC2AllowRules checks that the iid matches at least one of the allow @@ -96,7 +100,9 @@ func checkInstanceRunning(ctx context.Context, instanceID, region, IAMRole strin // assume the configured IAM role if necessary if IAMRole != "" { - stsClient := sts.NewFromConfig(awsClientConfig) + stsClient := sts.NewFromConfig(awsClientConfig, func(o *sts.Options) { + o.TracerProvider = smithyoteltracing.Adapt(otel.GetTracerProvider()) + }) creds := stscreds.NewAssumeRoleProvider(stsClient, IAMRole) awsClientConfig.Credentials = aws.NewCredentialsCache(creds) } diff --git a/lib/auth/keystore/aws_kms.go b/lib/auth/keystore/aws_kms.go index 536a940654a62..0a5c6824fe55d 100644 --- a/lib/auth/keystore/aws_kms.go +++ b/lib/auth/keystore/aws_kms.go @@ -37,8 +37,10 @@ import ( "github.com/aws/aws-sdk-go-v2/service/kms" kmstypes "github.com/aws/aws-sdk-go-v2/service/kms/types" "github.com/aws/aws-sdk-go-v2/service/sts" + "github.com/aws/smithy-go/tracing/smithyoteltracing" "github.com/gravitational/trace" "github.com/jonboulle/clockwork" + "go.opentelemetry.io/otel" "golang.org/x/sync/errgroup" "github.com/gravitational/teleport/api/types" @@ -81,10 +83,14 @@ func newAWSKMSKeystore(ctx context.Context, cfg *servicecfg.AWSKMSConfig, opts * return nil, trace.Wrap(err, "loading default AWS config") } if stsClient == nil { - stsClient = sts.NewFromConfig(awsCfg) + stsClient = sts.NewFromConfig(awsCfg, func(o *sts.Options) { + o.TracerProvider = smithyoteltracing.Adapt(otel.GetTracerProvider()) + }) } if kmsClient == nil { - kmsClient = kms.NewFromConfig(awsCfg) + kmsClient = kms.NewFromConfig(awsCfg, func(o *kms.Options) { + o.TracerProvider = smithyoteltracing.Adapt(otel.GetTracerProvider()) + }) } } id, err := stsClient.GetCallerIdentity(ctx, &sts.GetCallerIdentityInput{}) diff --git a/lib/backend/dynamo/dynamodbbk.go b/lib/backend/dynamo/dynamodbbk.go index 44f9774584b7e..556366959e905 100644 --- a/lib/backend/dynamo/dynamodbbk.go +++ b/lib/backend/dynamo/dynamodbbk.go @@ -38,9 +38,10 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" "github.com/aws/aws-sdk-go-v2/service/dynamodbstreams" streamtypes "github.com/aws/aws-sdk-go-v2/service/dynamodbstreams/types" + "github.com/aws/smithy-go/tracing/smithyoteltracing" "github.com/gravitational/trace" "github.com/jonboulle/clockwork" - "go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws" + "go.opentelemetry.io/otel" "github.com/gravitational/teleport" "github.com/gravitational/teleport/api/utils" @@ -282,7 +283,12 @@ func New(ctx context.Context, params backend.Params) (*Backend, error) { return nil, trace.Wrap(err) } - dynamoOpts := []func(*dynamodb.Options){dynamodb.WithEndpointResolverV2(dynamoResolver)} + dynamoOpts := []func(*dynamodb.Options){ + dynamodb.WithEndpointResolverV2(dynamoResolver), + func(o *dynamodb.Options) { + o.TracerProvider = smithyoteltracing.Adapt(otel.GetTracerProvider()) + }, + } // FIPS settings are applied on the individual service instead of the aws config, // as DynamoDB Streams and Application Auto Scaling do not yet have FIPS endpoints in non-GovCloud. @@ -293,8 +299,6 @@ func New(ctx context.Context, params backend.Params) (*Backend, error) { }) } - otelaws.AppendMiddlewares(&awsConfig.APIOptions, otelaws.WithAttributeSetter(otelaws.DynamoDBAttributeSetter)) - dynamoClient := dynamodb.NewFromConfig(awsConfig, dynamoOpts...) streamsResolver, err := endpoint.NewLoggingResolver( diff --git a/lib/cloud/aws/config/config.go b/lib/cloud/aws/config/config.go index 815ebea3d0230..13e032bf3fe65 100644 --- a/lib/cloud/aws/config/config.go +++ b/lib/cloud/aws/config/config.go @@ -24,7 +24,9 @@ import ( "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/credentials/stscreds" "github.com/aws/aws-sdk-go-v2/service/sts" + "github.com/aws/smithy-go/tracing/smithyoteltracing" "github.com/gravitational/trace" + "go.opentelemetry.io/otel" "github.com/gravitational/teleport/lib/modules" ) @@ -221,7 +223,9 @@ func getAWSConfigForRole(ctx context.Context, region string, options awsOptions) return aws.Config{}, trace.Wrap(err) } - stsClient := sts.NewFromConfig(*options.baseConfig) + stsClient := sts.NewFromConfig(*options.baseConfig, func(o *sts.Options) { + o.TracerProvider = smithyoteltracing.Adapt(otel.GetTracerProvider()) + }) cred := stscreds.NewAssumeRoleProvider(stsClient, options.assumeRoleARN, func(aro *stscreds.AssumeRoleOptions) { if options.assumeRoleExternalID != "" { aro.ExternalID = aws.String(options.assumeRoleExternalID) diff --git a/lib/configurators/aws/aws.go b/lib/configurators/aws/aws.go index 839bf08de2df1..6673b1fbe8519 100644 --- a/lib/configurators/aws/aws.go +++ b/lib/configurators/aws/aws.go @@ -34,7 +34,9 @@ import ( "github.com/aws/aws-sdk-go-v2/service/ssm" ssmtypes "github.com/aws/aws-sdk-go-v2/service/ssm/types" "github.com/aws/aws-sdk-go-v2/service/sts" + "github.com/aws/smithy-go/tracing/smithyoteltracing" "github.com/gravitational/trace" + "go.opentelemetry.io/otel" "github.com/gravitational/teleport/api/types" apiutils "github.com/gravitational/teleport/api/utils" @@ -388,10 +390,14 @@ func (c *ConfiguratorConfig) CheckAndSetDefaults() error { } if c.stsClient == nil { - c.stsClient = sts.NewFromConfig(*c.awsCfg) + c.stsClient = sts.NewFromConfig(*c.awsCfg, func(o *sts.Options) { + o.TracerProvider = smithyoteltracing.Adapt(otel.GetTracerProvider()) + }) } if c.iamClient == nil { - c.iamClient = iam.NewFromConfig(*c.awsCfg) + c.iamClient = iam.NewFromConfig(*c.awsCfg, func(o *iam.Options) { + o.TracerProvider = smithyoteltracing.Adapt(otel.GetTracerProvider()) + }) } if c.Identity == nil { c.Identity, err = awslib.GetIdentityWithClientV2(context.Background(), c.stsClient) @@ -413,7 +419,9 @@ func (c *ConfiguratorConfig) CheckAndSetDefaults() error { withRegion := func(o *ssm.Options) { o.Region = region } - c.ssmClients[region] = ssm.NewFromConfig(*c.awsCfg, withRegion) + c.ssmClients[region] = ssm.NewFromConfig(*c.awsCfg, withRegion, func(o *ssm.Options) { + o.TracerProvider = smithyoteltracing.Adapt(otel.GetTracerProvider()) + }) } } @@ -422,7 +430,9 @@ func (c *ConfiguratorConfig) CheckAndSetDefaults() error { if c.Policies == nil { partition := c.Identity.GetPartition() accountID := c.Identity.GetAccountID() - iamClient := iam.NewFromConfig(*c.awsCfg) + iamClient := iam.NewFromConfig(*c.awsCfg, func(o *iam.Options) { + o.TracerProvider = smithyoteltracing.Adapt(otel.GetTracerProvider()) + }) c.Policies = awslib.NewPolicies(partition, accountID, iamClient) } } diff --git a/lib/events/athena/athena.go b/lib/events/athena/athena.go index 0fa5416a5e1cb..7541523ea01bd 100644 --- a/lib/events/athena/athena.go +++ b/lib/events/athena/athena.go @@ -33,7 +33,6 @@ import ( "github.com/gravitational/trace" "github.com/jonboulle/clockwork" "github.com/prometheus/client_golang/prometheus" - "go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws" oteltrace "go.opentelemetry.io/otel/trace" "github.com/gravitational/teleport" @@ -296,7 +295,6 @@ func (cfg *Config) CheckAndSetDefaults(ctx context.Context) error { if cfg.Region != "" { awsCfg.Region = cfg.Region } - otelaws.AppendMiddlewares(&awsCfg.APIOptions) cfg.PublisherConsumerAWSConfig = &awsCfg } @@ -452,7 +450,6 @@ func (cfg *Config) UpdateForExternalAuditStorage(ctx context.Context, externalAu if err != nil { return trace.Wrap(err) } - otelaws.AppendMiddlewares(&awsCfg.APIOptions) cfg.StorerQuerierAWSConfig = &awsCfg cfg.ObserveWriteEventsError = externalAuditStorage.ErrorCounter.ObserveEmitError diff --git a/lib/events/athena/consumer.go b/lib/events/athena/consumer.go index 0b9655c90beb2..4c51ec53f0fa8 100644 --- a/lib/events/athena/consumer.go +++ b/lib/events/athena/consumer.go @@ -38,9 +38,11 @@ import ( s3Types "github.com/aws/aws-sdk-go-v2/service/s3/types" "github.com/aws/aws-sdk-go-v2/service/sqs" sqsTypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" + "github.com/aws/smithy-go/tracing/smithyoteltracing" "github.com/google/uuid" "github.com/gravitational/trace" "github.com/parquet-go/parquet-go" + "go.opentelemetry.io/otel" "github.com/gravitational/teleport" apievents "github.com/gravitational/teleport/api/types/events" @@ -121,14 +123,26 @@ func newConsumer(cfg Config, cancelFn context.CancelFunc) (*consumer, error) { t.MaxIdleConns = defaults.HTTPMaxIdleConns t.MaxIdleConnsPerHost = defaults.HTTPMaxIdleConnsPerHost }) - sqsClient := sqs.NewFromConfig(*cfg.PublisherConsumerAWSConfig, func(o *sqs.Options) { o.HTTPClient = sqsHTTPClient }) + sqsClient := sqs.NewFromConfig(*cfg.PublisherConsumerAWSConfig, + func(o *sqs.Options) { + o.HTTPClient = sqsHTTPClient + o.TracerProvider = smithyoteltracing.Adapt(otel.GetTracerProvider()) + }) s3HTTPClient := awshttp.NewBuildableClient().WithTransportOptions(func(t *http.Transport) { t.MaxIdleConns = defaults.HTTPMaxIdleConns t.MaxIdleConnsPerHost = defaults.HTTPMaxIdleConnsPerHost }) - publisherS3Client := s3.NewFromConfig(*cfg.PublisherConsumerAWSConfig, func(o *s3.Options) { o.HTTPClient = s3HTTPClient }) - storerS3Client := s3.NewFromConfig(*cfg.StorerQuerierAWSConfig, func(o *s3.Options) { o.HTTPClient = s3HTTPClient }) + publisherS3Client := s3.NewFromConfig(*cfg.PublisherConsumerAWSConfig, + func(o *s3.Options) { + o.HTTPClient = s3HTTPClient + o.TracerProvider = smithyoteltracing.Adapt(otel.GetTracerProvider()) + }) + storerS3Client := s3.NewFromConfig(*cfg.StorerQuerierAWSConfig, + func(o *s3.Options) { + o.HTTPClient = s3HTTPClient + o.TracerProvider = smithyoteltracing.Adapt(otel.GetTracerProvider()) + }) collectCfg := sqsCollectConfig{ sqsReceiver: sqsClient, diff --git a/lib/events/athena/publisher.go b/lib/events/athena/publisher.go index 1c9fed79107f4..4f5d541c1fd8a 100644 --- a/lib/events/athena/publisher.go +++ b/lib/events/athena/publisher.go @@ -36,8 +36,10 @@ import ( snstypes "github.com/aws/aws-sdk-go-v2/service/sns/types" "github.com/aws/aws-sdk-go-v2/service/sqs" sqstypes "github.com/aws/aws-sdk-go-v2/service/sqs/types" + "github.com/aws/smithy-go/tracing/smithyoteltracing" "github.com/google/uuid" "github.com/gravitational/trace" + "go.opentelemetry.io/otel" apievents "github.com/gravitational/teleport/api/types/events" "github.com/gravitational/teleport/lib/defaults" @@ -183,18 +185,21 @@ func newPublisherFromAthenaConfig(cfg Config) *publisher { messagePublisher = SQSPublisherFunc(cfg.QueueURL, sqs.NewFromConfig(*cfg.PublisherConsumerAWSConfig, func(o *sqs.Options) { o.Retryer = r o.HTTPClient = hc + o.TracerProvider = smithyoteltracing.Adapt(otel.GetTracerProvider()) })) } else { messagePublisher = SNSPublisherFunc(cfg.TopicARN, sns.NewFromConfig(*cfg.PublisherConsumerAWSConfig, func(o *sns.Options) { o.Retryer = r o.HTTPClient = hc + o.TracerProvider = smithyoteltracing.Adapt(otel.GetTracerProvider()) })) } return NewPublisher(PublisherConfig{ MessagePublisher: messagePublisher, - // TODO(tobiaszheller): consider reworking lib/observability to work also on s3 sdk-v2. - Uploader: s3manager.NewUploader(s3.NewFromConfig(*cfg.PublisherConsumerAWSConfig)), + Uploader: s3manager.NewUploader(s3.NewFromConfig(*cfg.PublisherConsumerAWSConfig, func(o *s3.Options) { + o.TracerProvider = smithyoteltracing.Adapt(otel.GetTracerProvider()) + })), PayloadBucket: cfg.largeEventsBucket, PayloadPrefix: cfg.largeEventsPrefix, }) diff --git a/lib/events/athena/querier.go b/lib/events/athena/querier.go index 9b22920e5cc99..b2d36040d0014 100644 --- a/lib/events/athena/querier.go +++ b/lib/events/athena/querier.go @@ -36,11 +36,13 @@ import ( athenaTypes "github.com/aws/aws-sdk-go-v2/service/athena/types" "github.com/aws/aws-sdk-go-v2/service/s3" s3types "github.com/aws/aws-sdk-go-v2/service/s3/types" + "github.com/aws/smithy-go/tracing/smithyoteltracing" "github.com/dustin/go-humanize" "github.com/google/uuid" "github.com/gravitational/trace" "github.com/jonboulle/clockwork" "github.com/parquet-go/parquet-go" + "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" oteltrace "go.opentelemetry.io/otel/trace" @@ -148,8 +150,12 @@ func newQuerier(cfg querierConfig) (*querier, error) { return nil, trace.Wrap(err) } return &querier{ - athenaClient: athena.NewFromConfig(*cfg.awsCfg), - s3Getter: s3.NewFromConfig(*cfg.awsCfg), + athenaClient: athena.NewFromConfig(*cfg.awsCfg, func(o *athena.Options) { + o.TracerProvider = smithyoteltracing.Adapt(otel.GetTracerProvider()) + }), + s3Getter: s3.NewFromConfig(*cfg.awsCfg, func(o *s3.Options) { + o.TracerProvider = smithyoteltracing.Adapt(otel.GetTracerProvider()) + }), querierConfig: cfg, }, nil } diff --git a/lib/events/dynamoevents/dynamoevents.go b/lib/events/dynamoevents/dynamoevents.go index 1504d987b7fcc..3f3c46ac874b6 100644 --- a/lib/events/dynamoevents/dynamoevents.go +++ b/lib/events/dynamoevents/dynamoevents.go @@ -43,10 +43,11 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb" dynamodbtypes "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" "github.com/aws/smithy-go" + "github.com/aws/smithy-go/tracing/smithyoteltracing" "github.com/google/uuid" "github.com/gravitational/trace" "github.com/jonboulle/clockwork" - "go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws" + "go.opentelemetry.io/otel" "github.com/gravitational/teleport" apidefaults "github.com/gravitational/teleport/api/defaults" @@ -307,7 +308,12 @@ func New(ctx context.Context, cfg Config) (*Log, error) { return nil, trace.Wrap(err) } - dynamoOpts := []func(*dynamodb.Options){dynamodb.WithEndpointResolverV2(resolver)} + dynamoOpts := []func(*dynamodb.Options){ + dynamodb.WithEndpointResolverV2(resolver), + func(o *dynamodb.Options) { + o.TracerProvider = smithyoteltracing.Adapt(otel.GetTracerProvider()) + }, + } // Override the service endpoint using the "endpoint" query parameter from // "audit_events_uri". This is for non-AWS DynamoDB-compatible backends. @@ -333,8 +339,6 @@ func New(ctx context.Context, cfg Config) (*Log, error) { return nil, trace.Wrap(err) } - otelaws.AppendMiddlewares(&awsConfig.APIOptions, otelaws.WithAttributeSetter(otelaws.DynamoDBAttributeSetter)) - client := dynamodb.NewFromConfig(awsConfig, dynamoOpts...) b := &Log{ logger: l, diff --git a/lib/events/s3sessions/s3handler.go b/lib/events/s3sessions/s3handler.go index 8b8487bd26a3f..f4492d27337a9 100644 --- a/lib/events/s3sessions/s3handler.go +++ b/lib/events/s3sessions/s3handler.go @@ -37,8 +37,9 @@ import ( "github.com/aws/aws-sdk-go-v2/feature/s3/manager" "github.com/aws/aws-sdk-go-v2/service/s3" awstypes "github.com/aws/aws-sdk-go-v2/service/s3/types" + "github.com/aws/smithy-go/tracing/smithyoteltracing" "github.com/gravitational/trace" - "go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws" + "go.opentelemetry.io/otel" "github.com/gravitational/teleport" "github.com/gravitational/teleport/api/types" @@ -208,7 +209,12 @@ func NewHandler(ctx context.Context, cfg Config) (*Handler, error) { return nil, trace.Wrap(err) } - s3Opts := []func(*s3.Options){s3.WithEndpointResolverV2(resolver)} + s3Opts := []func(*s3.Options){ + s3.WithEndpointResolverV2(resolver), + func(o *s3.Options) { + o.TracerProvider = smithyoteltracing.Adapt(otel.GetTracerProvider()) + }, + } if cfg.Endpoint != "" { if _, err := url.Parse(cfg.Endpoint); err != nil { @@ -233,8 +239,6 @@ func NewHandler(ctx context.Context, cfg Config) (*Handler, error) { return nil, trace.Wrap(err) } - otelaws.AppendMiddlewares(&awsConfig.APIOptions) - // Create S3 client with custom options client := s3.NewFromConfig(awsConfig, s3Opts...)