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

v2: merge main into v2 again #2937

Merged
merged 61 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
f65cab8
Fix: Support custom propagators in startup log (#2925)
mtoffl01 Oct 18, 2024
1366f6b
contrib/jackc/pgx.v5: wrap previous tracer (#2932)
rarguelloF Oct 21, 2024
020a9da
contrib/net/http: refactor tracing (#2921)
rarguelloF Oct 21, 2024
2cae09f
contrib/confluentinc/confluent-kafka-go: split tracing code (#2907)
rarguelloF Oct 21, 2024
576ecef
merge pt2: fix kafka
hannahkm Oct 21, 2024
46b8e10
fix various type issues
hannahkm Oct 21, 2024
f46380e
fix more type and import issues
hannahkm Oct 21, 2024
9fa6680
easy type fixes
hannahkm Oct 21, 2024
d06af26
remove call to deleted option
hannahkm Oct 21, 2024
8c9279e
another call to options
hannahkm Oct 21, 2024
2c54fc9
remove internal calls 1/n
hannahkm Oct 21, 2024
ed1c61c
import and options fixes
hannahkm Oct 21, 2024
d48348e
internal/appsec: better docs (#2935)
eliottness Oct 22, 2024
e104e1e
[godfathering] contrib/dimfeld/httptreemux.v5: failing tests for path…
darccio Oct 22, 2024
a118199
[serverless] Inject trace context into SQS/SNS/EventBridge (#2917)
nhulston Oct 22, 2024
e73b3d1
contrib/log/slog: fix WithAttrs and WithGroup implementation (#2857)
rarguelloF Oct 22, 2024
48e3a66
internal/civisibility: removes importing contrib packages from tests …
tonyredondo Oct 22, 2024
f787fb7
remove internal kafka directory
hannahkm Oct 22, 2024
61ac0b0
fix more internal kafka links
hannahkm Oct 22, 2024
e770614
clean up kafka package
hannahkm Oct 22, 2024
05625d5
fix broken kafka test
hannahkm Oct 22, 2024
6a5284c
merge + conflict resolve
hannahkm Oct 22, 2024
91012f0
workflows test on beta 3
hannahkm Oct 22, 2024
69c8f2b
clean up imports
hannahkm Oct 22, 2024
38b22a0
edit toolchain
hannahkm Oct 22, 2024
a853d8a
remove contrib from test files
hannahkm Oct 22, 2024
71223be
update mod to latest commit
hannahkm Oct 23, 2024
9e564cf
test against new system test branch
hannahkm Oct 23, 2024
a588c11
Revert "remove contrib from test files"
hannahkm Oct 23, 2024
11b5baf
update refs to hannah branch
hannahkm Oct 23, 2024
00c300f
fix: allow go.work to be usable in Go 1.22 (#2945)
darccio Oct 24, 2024
287927c
revert to og testing branch, mod tidy
hannahkm Oct 24, 2024
5cb7b5b
remove replace from smoke test mod
hannahkm Oct 24, 2024
12ca1dc
update smoke test mod name
hannahkm Oct 24, 2024
31f0edd
go mod tidy
hannahkm Oct 24, 2024
f576f28
align go mod w v2dev
hannahkm Oct 24, 2024
aca9aca
mark branch as merged
hannahkm Oct 24, 2024
e94fb8a
revert for wrong commit hash
hannahkm Oct 24, 2024
424d1d8
create replace for smoke tests
hannahkm Oct 24, 2024
55e20e9
add smoke tests to work file
hannahkm Oct 24, 2024
21b44e6
fix integration enabled test
hannahkm Oct 24, 2024
07f6de4
mocktracer and error code fixes
hannahkm Oct 25, 2024
91218a6
fix goroutine leak in mocktracer
hannahkm Oct 25, 2024
e39240a
fix roundtripper test
hannahkm Oct 25, 2024
46a0800
fix and clean slog
hannahkm Oct 25, 2024
09bf8cf
fix restful test
hannahkm Oct 25, 2024
7f20d0c
fix kafka
hannahkm Oct 25, 2024
6d6775e
fix kafkav2
hannahkm Oct 25, 2024
6dfa49e
fix gqlgen tests
hannahkm Oct 25, 2024
b770e1c
fix appsec contrib tests
hannahkm Oct 25, 2024
1426e57
update traceproftest mod
hannahkm Oct 25, 2024
1eb3756
easy test fixes
hannahkm Oct 25, 2024
e6b61b2
contrib test fixes
hannahkm Oct 25, 2024
9e23b52
move common func to options
hannahkm Oct 28, 2024
af792a7
fix debug stack tests
hannahkm Oct 28, 2024
b147c72
Revert "fix debug stack tests"
hannahkm Oct 28, 2024
8445590
remove error stack if debug stack off
hannahkm Oct 29, 2024
729a1be
merge 1.69.1-rc.4 with v2 (#2953)
hannahkm Oct 29, 2024
39065cb
fix civisibility tests
hannahkm Oct 30, 2024
564e172
remove todo
hannahkm Oct 30, 2024
af4994b
fix kafka tests with mockspans
hannahkm Oct 31, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
# Related to issue https://github.com/DataDog/dd-trace-go/issues/1607
name: 'go get -u smoke test'
runs-on: ubuntu-latest
if: github.repository_owner == 'DataDog' # only run on DataDog's repository, not in forks
if: github.repository_owner == 'DataDog' && github.ref_type == 'tag' && contains(github.ref_name, 'v2.0.0-beta.3') # only run on DataDog's repository, not in forks
env:
PACKAGES: ./internal/... ./ddtrace/... ./profiler/... ./appsec/...
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/system-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
- main
- release-v*
tags:
- "**"
- "v2.0.0-beta.3"
pull_request:
branches:
- "**"
Expand Down
28 changes: 16 additions & 12 deletions .github/workflows/unit-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,20 +180,24 @@ jobs:
image: memcached:1.5.9
ports:
- 11211:11211
zookeeper:
image: bitnami/zookeeper:latest
env:
ALLOW_ANONYMOUS_LOGIN: "yes"
ports:
- 2181:2181
kafka:
image: darccio/kafka:2.13-2.8.1
image: confluentinc/confluent-local:7.5.0
env:
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
KAFKA_CREATE_TOPICS: gotest:1:1,gosegtest:1:1
KAFKA_BROKER_ID: 1
KAFKA_LISTENERS: "PLAINTEXT://0.0.0.0:9093,BROKER://0.0.0.0:9092,CONTROLLER://0.0.0.0:9094"
KAFKA_ADVERTISED_LISTENERS: "PLAINTEXT://localhost:9093,BROKER://localhost:9092"
KAFKA_REST_BOOTSTRAP_SERVERS: "PLAINTEXT://0.0.0.0:9093,BROKER://0.0.0.0:9092"
KAFKA_CONTROLLER_QUORUM_VOTERS: "1@localhost:9094"
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: "BROKER:PLAINTEXT,PLAINTEXT:PLAINTEXT,CONTROLLER:PLAINTEXT"
KAFKA_INTER_BROKER_LISTENER_NAME: "BROKER"
KAFKA_BROKER_ID: "1"
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: "1"
KAFKA_OFFSETS_TOPIC_NUM_PARTITIONS: "1"
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: "1"
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: "1"
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: "0"
KAFKA_NODE_ID: "1"
KAFKA_PROCESS_ROLES: "broker,controller"
KAFKA_CONTROLLER_LISTENER_NAMES: "CONTROLLER"
ports:
- 9092:9092
localstack:
Expand Down
2 changes: 1 addition & 1 deletion contrib/99designs/gqlgen/appsec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func TestAppSec(t *testing.T) {

// The last finished span (which is GraphQL entry) should have the "_dd.appsec.enabled" tag.
span := spans[len(spans)-1]
require.Equal(t, 1, span.Tag("_dd.appsec.enabled"))
require.Equal(t, float64(1), span.Tag("_dd.appsec.enabled"))

type ddAppsecJSON struct {
Triggers []struct {
Expand Down
4 changes: 1 addition & 3 deletions contrib/99designs/gqlgen/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ module github.com/DataDog/dd-trace-go/contrib/99designs/gqlgen/v2

go 1.22.0

toolchain go1.23.1

require (
github.com/99designs/gqlgen v0.17.36
github.com/DataDog/dd-trace-go/v2 v2.0.0-beta.3
github.com/DataDog/dd-trace-go/v2 v2.0.0-beta.3.0.20241024132757-00c300faaace
github.com/stretchr/testify v1.9.0
github.com/vektah/gqlparser/v2 v2.5.16
)
Expand Down
2 changes: 1 addition & 1 deletion contrib/99designs/gqlgen/tracer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func TestInterceptOperation(t *testing.T) {
assertions.ElementsMatch(resNames, []string{readOp, parsingOp, validationOp, `mutation Name { name }`})
assertions.ElementsMatch(opNames, []string{readOp, parsingOp, validationOp, "graphql.mutation"})
assertions.NotNil(root)
assertions.NotNil(root.Tag(ext.Error))
assertions.NotNil(root.Tag(ext.ErrorMsg))
})

t.Run("intercept operation with graphQL Subscription", func(t *testing.T) {
Expand Down
4 changes: 1 addition & 3 deletions contrib/IBM/sarama/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ module github.com/DataDog/dd-trace-go/contrib/IBM/sarama/v2

go 1.22.0

toolchain go1.23.1

require (
github.com/DataDog/dd-trace-go/v2 v2.0.0-beta.3
github.com/DataDog/dd-trace-go/v2 v2.0.0-beta.3.0.20241024132757-00c300faaace
github.com/IBM/sarama v1.40.0
github.com/stretchr/testify v1.9.0
)
Expand Down
4 changes: 1 addition & 3 deletions contrib/Shopify/sarama/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ module github.com/DataDog/dd-trace-go/contrib/Shopify/sarama/v2

go 1.22.0

toolchain go1.23.1

require (
github.com/DataDog/dd-trace-go/v2 v2.0.0-beta.3
github.com/DataDog/dd-trace-go/v2 v2.0.0-beta.3.0.20241024132757-00c300faaace
github.com/Shopify/sarama v1.38.1
github.com/stretchr/testify v1.9.0
)
Expand Down
13 changes: 13 additions & 0 deletions contrib/aws/aws-sdk-go-v2/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import (
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"

eventBridgeTracer "github.com/DataDog/dd-trace-go/v2/contrib/aws/eventbridge"
snsTracer "github.com/DataDog/dd-trace-go/v2/contrib/aws/sns"
sqsTracer "github.com/DataDog/dd-trace-go/v2/contrib/aws/sqs"
"github.com/DataDog/dd-trace-go/v2/ddtrace/ext"
"github.com/DataDog/dd-trace-go/v2/ddtrace/tracer"
"github.com/DataDog/dd-trace-go/v2/instrumentation"
Expand Down Expand Up @@ -102,6 +105,16 @@ func (mw *traceMiddleware) startTraceMiddleware(stack *middleware.Stack) error {
}
span, spanctx := tracer.StartSpanFromContext(ctx, spanName(serviceID, operation), opts...)

// Inject trace context
switch serviceID {
case "SQS":
sqsTracer.EnrichOperation(span, in, operation)
case "SNS":
snsTracer.EnrichOperation(span, in, operation)
case "EventBridge":
eventBridgeTracer.EnrichOperation(span, in, operation)
}

// Handle initialize and continue through the middleware chain.
out, metadata, err = next.HandleInitialize(spanctx, in)
if err != nil && (mw.cfg.errCheck == nil || mw.cfg.errCheck(err)) {
Expand Down
134 changes: 134 additions & 0 deletions contrib/aws/aws-sdk-go-v2/aws/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package aws
import (
"context"
"encoding/base64"
"encoding/json"
"net/http"
"net/http/httptest"
"net/url"
Expand All @@ -19,6 +20,7 @@ import (
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/dynamodb"
"github.com/aws/aws-sdk-go-v2/service/eventbridge"
eventBridgeTypes "github.com/aws/aws-sdk-go-v2/service/eventbridge/types"
"github.com/aws/aws-sdk-go-v2/service/kinesis"
"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/aws/aws-sdk-go-v2/service/sfn"
Expand Down Expand Up @@ -254,6 +256,66 @@ func TestAppendMiddlewareSqsReceiveMessage(t *testing.T) {
}
}

func TestAppendMiddlewareSqsSendMessage(t *testing.T) {
mt := mocktracer.Start()
defer mt.Stop()

expectedStatusCode := 200
server := mockAWS(expectedStatusCode)
defer server.Close()

resolver := aws.EndpointResolverFunc(func(service, region string) (aws.Endpoint, error) {
return aws.Endpoint{
PartitionID: "aws",
URL: server.URL,
SigningRegion: "eu-west-1",
}, nil
})

awsCfg := aws.Config{
Region: "eu-west-1",
Credentials: aws.AnonymousCredentials{},
EndpointResolver: resolver,
}

AppendMiddleware(&awsCfg)

sqsClient := sqs.NewFromConfig(awsCfg)
sendMessageInput := &sqs.SendMessageInput{
MessageBody: aws.String("test message"),
QueueUrl: aws.String("https://sqs.us-west-2.amazonaws.com/123456789012/MyQueueName"),
}
_, err := sqsClient.SendMessage(context.Background(), sendMessageInput)
require.NoError(t, err)

spans := mt.FinishedSpans()
require.Len(t, spans, 1)

s := spans[0]
assert.Equal(t, "SQS.request", s.OperationName())
assert.Equal(t, "SendMessage", s.Tag("aws.operation"))
assert.Equal(t, "SQS", s.Tag("aws.service"))
assert.Equal(t, "MyQueueName", s.Tag("queuename"))
assert.Equal(t, "SQS.SendMessage", s.Tag(ext.ResourceName))
assert.Equal(t, "aws.SQS", s.Tag(ext.ServiceName))

// Check for trace context injection
assert.NotNil(t, sendMessageInput.MessageAttributes)
assert.Contains(t, sendMessageInput.MessageAttributes, "_datadog")
ddAttr := sendMessageInput.MessageAttributes["_datadog"]
assert.Equal(t, "String", *ddAttr.DataType)
assert.NotEmpty(t, *ddAttr.StringValue)

// Decode and verify the injected trace context
var traceContext map[string]string
err = json.Unmarshal([]byte(*ddAttr.StringValue), &traceContext)
assert.NoError(t, err)
assert.Contains(t, traceContext, "x-datadog-trace-id")
assert.Contains(t, traceContext, "x-datadog-parent-id")
assert.NotEmpty(t, traceContext["x-datadog-trace-id"])
assert.NotEmpty(t, traceContext["x-datadog-parent-id"])
}

func TestAppendMiddlewareS3ListObjects(t *testing.T) {
tests := []struct {
name string
Expand Down Expand Up @@ -416,6 +478,22 @@ func TestAppendMiddlewareSnsPublish(t *testing.T) {
assert.Equal(t, server.URL+"/", s.Tag(ext.HTTPURL))
assert.Equal(t, "aws/aws-sdk-go-v2/aws", s.Tag(ext.Component))
assert.Equal(t, ext.SpanKindClient, s.Tag(ext.SpanKind))

// Check for trace context injection
assert.NotNil(t, tt.publishInput.MessageAttributes)
assert.Contains(t, tt.publishInput.MessageAttributes, "_datadog")
ddAttr := tt.publishInput.MessageAttributes["_datadog"]
assert.Equal(t, "Binary", *ddAttr.DataType)
assert.NotEmpty(t, ddAttr.BinaryValue)

// Decode and verify the injected trace context
var traceContext map[string]string
err := json.Unmarshal(ddAttr.BinaryValue, &traceContext)
assert.NoError(t, err)
assert.Contains(t, traceContext, "x-datadog-trace-id")
assert.Contains(t, traceContext, "x-datadog-parent-id")
assert.NotEmpty(t, traceContext["x-datadog-trace-id"])
assert.NotEmpty(t, traceContext["x-datadog-parent-id"])
})
}
}
Expand Down Expand Up @@ -640,6 +718,62 @@ func TestAppendMiddlewareEventBridgePutRule(t *testing.T) {
}
}

func TestAppendMiddlewareEventBridgePutEvents(t *testing.T) {
mt := mocktracer.Start()
defer mt.Stop()

expectedStatusCode := 200
server := mockAWS(expectedStatusCode)
defer server.Close()

resolver := aws.EndpointResolverFunc(func(service, region string) (aws.Endpoint, error) {
return aws.Endpoint{
PartitionID: "aws",
URL: server.URL,
SigningRegion: "eu-west-1",
}, nil
})

awsCfg := aws.Config{
Region: "eu-west-1",
Credentials: aws.AnonymousCredentials{},
EndpointResolver: resolver,
}

AppendMiddleware(&awsCfg)

eventbridgeClient := eventbridge.NewFromConfig(awsCfg)
putEventsInput := &eventbridge.PutEventsInput{
Entries: []eventBridgeTypes.PutEventsRequestEntry{
{
EventBusName: aws.String("my-event-bus"),
Detail: aws.String(`{"key": "value"}`),
},
},
}
eventbridgeClient.PutEvents(context.Background(), putEventsInput)

spans := mt.FinishedSpans()
require.Len(t, spans, 1)

s := spans[0]
assert.Equal(t, "PutEvents", s.Tag("aws.operation"))
assert.Equal(t, "EventBridge.PutEvents", s.Tag(ext.ResourceName))

// Check for trace context injection
assert.Len(t, putEventsInput.Entries, 1)
entry := putEventsInput.Entries[0]
var detail map[string]interface{}
err := json.Unmarshal([]byte(*entry.Detail), &detail)
assert.NoError(t, err)
assert.Contains(t, detail, "_datadog")
ddData, ok := detail["_datadog"].(map[string]interface{})
assert.True(t, ok)
assert.Contains(t, ddData, "x-datadog-start-time")
assert.Contains(t, ddData, "x-datadog-resource-name")
assert.Equal(t, "my-event-bus", ddData["x-datadog-resource-name"])
}

func TestAppendMiddlewareSfnDescribeStateMachine(t *testing.T) {
tests := []struct {
name string
Expand Down
20 changes: 9 additions & 11 deletions contrib/aws/aws-sdk-go-v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,19 @@ module github.com/DataDog/dd-trace-go/contrib/aws/aws-sdk-go-v2/v2

go 1.22.0

toolchain go1.23.1

require (
github.com/DataDog/dd-trace-go/v2 v2.0.0-beta.3
github.com/aws/aws-sdk-go-v2 v1.30.3
github.com/DataDog/dd-trace-go/v2 v2.0.0-beta.3.0.20241024132757-00c300faaace
github.com/aws/aws-sdk-go-v2 v1.32.2
github.com/aws/aws-sdk-go-v2/config v1.27.27
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.8
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.34.3
github.com/aws/aws-sdk-go-v2/service/eventbridge v1.33.3
github.com/aws/aws-sdk-go-v2/service/eventbridge v1.35.2
github.com/aws/aws-sdk-go-v2/service/kinesis v1.29.3
github.com/aws/aws-sdk-go-v2/service/s3 v1.58.2
github.com/aws/aws-sdk-go-v2/service/sfn v1.29.3
github.com/aws/aws-sdk-go-v2/service/sns v1.31.3
github.com/aws/aws-sdk-go-v2/service/sqs v1.34.3
github.com/aws/smithy-go v1.20.3
github.com/aws/aws-sdk-go-v2/service/sns v1.33.2
github.com/aws/aws-sdk-go-v2/service/sqs v1.36.2
github.com/aws/smithy-go v1.22.0
github.com/stretchr/testify v1.9.0
)

Expand All @@ -32,10 +30,10 @@ require (
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.3 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.17.27 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.11 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.15 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.15 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.21 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.21 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.15 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.21 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.3 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.3.17 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.9.16 // indirect
Expand Down
Loading
Loading