Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into romain.marcadier/rm-d…
Browse files Browse the repository at this point in the history
…ead-code
  • Loading branch information
RomainMuller committed Sep 16, 2024
2 parents b7361ee + b4de369 commit f70b096
Show file tree
Hide file tree
Showing 24 changed files with 590 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deps-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
git diff --staged --patch > "${{ runner.temp }}/go.diff.patch"
- name: Upload Artifact
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4
with:
name: Patches
path: ${{ runner.temp }}/go.diff.patch
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docsite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
# identical to hugo's.
run: go -C ./docs run github.com/gohugoio/hugo --minify --enableGitInfo --environment=gh-pages
- name: Upload Artifact
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4
with:
name: site
path: docs/public/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ossf-scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:

# Upload the results as artifacts.
- name: "Upload artifact"
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4
with:
name: SARIF file
path: results.sarif
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
git diff --staged --patch --exit-code > .repo.patch || echo "result=true" >> ${GITHUB_OUTPUT}
- name: Upload patch
if: github.event_name != 'push' && steps.is-tree-dirty.outputs.result == 'true'
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4
with:
name: repo.patch
path: .repo.patch
Expand Down Expand Up @@ -163,7 +163,7 @@ jobs:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Ensure SHA pinned actions
uses: zgosalvez/github-actions-ensure-sha-pinned-actions@3c16e895bb662b4d7e284f032cbe8835a57773cc # v3
uses: zgosalvez/github-actions-ensure-sha-pinned-actions@0901cf7b71c7ea6261ec69a3dc2bd3f9264f893e # v3

##############################################################################
# Run all unit tests with coverage enabled
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,18 @@ Library | Since | Notes
`github.com/Shopify/sarama` | `v0.7.4` | [Aspect][shopify-sarama]
`k8s.io/client-go` | `v0.7.4` | [Aspect][k8s-client]
`log/slog` | `v0.7.4` | [Aspect][log-slog]
`os` | `v0.8.0` | [Aspect][os]
`github.com/aws/aws-sdk-go-v2` | `v0.8.0` | [Aspect][aws-sdk-go-v2]
`github.com/redis/go-redis/v9` | `v0.8.0` | [Aspect][go-redis-v9]
`github.com/gocql/gocql` | `v0.8.0` | [Aspect][gocql]

[db-sql]: https://datadoghq.dev/orchestrion/docs/built-in/stdlib/database-sql/
[gin]: https://datadoghq.dev/orchestrion/docs/built-in/http/gin/
[chi-v5]: https://datadoghq.dev/orchestrion/docs/built-in/http/chi/#use-v5-tracer-middleware
[chi-v1]: https://datadoghq.dev/orchestrion/docs/built-in/http/chi/#use-v1-tracer-middleware
[go-redis-v7]: https://datadoghq.dev/orchestrion/docs/built-in/databases/go-redis/#wrap-v7-client
[go-redis-v8]: https://datadoghq.dev/orchestrion/docs/built-in/databases/go-redis/#wrap-v8-client
[go-redis-v9]: https://datadoghq.dev/orchestrion/docs/built-in/databases/go-redis/#wrap-v9-client
[fiber-v2]: https://datadoghq.dev/orchestrion/docs/built-in/http/fiber/
[redigo]: https://datadoghq.dev/orchestrion/docs/built-in/databases/redigo/
[gorilla]: https://datadoghq.dev/orchestrion/docs/built-in/http/gorilla/
Expand All @@ -161,8 +166,11 @@ Library | Since | Notes
[hashicorp-vault]: https://datadoghq.dev/orchestrion/docs/built-in/api/vault/
[log-slog]: https://datadoghq.dev/orchestrion/docs/built-in/stdlib/slog/
[aws-sdk-go]: https://datadoghq.dev/orchestrion/docs/built-in/cloud/aws-sdk/
[aws-sdk-go-v2]: https://datadoghq.dev/orchestrion/docs/built-in/cloud/aws-sdk-v2/
[ibm-sarama]: https://datadoghq.dev/orchestrion/docs/built-in/datastreams/ibm_sarama/
[shopify-sarama]: https://datadoghq.dev/orchestrion/docs/built-in/datastreams/shopify_sarama/
[os]: https://datadoghq.dev/orchestrion/docs/built-in/stdlib/ossec/
[gocql]: https://datadoghq.dev/orchestrion/docs/built-in/databases/gocql/

Calls to these libraries are instrumented with library-specific code adding tracing to them, including support for
distributed traces.
Expand Down
5 changes: 4 additions & 1 deletion _integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ require (
github.com/go-chi/chi/v5 v5.1.0
github.com/go-redis/redis/v7 v7.4.1
github.com/go-redis/redis/v8 v8.11.5
github.com/gocql/gocql v1.6.0
github.com/gofiber/fiber/v2 v2.52.5
github.com/gomodule/redigo v1.9.2
github.com/google/uuid v1.6.0
Expand All @@ -30,6 +31,7 @@ require (
github.com/redis/go-redis/v9 v9.6.1
github.com/stretchr/testify v1.9.0
github.com/testcontainers/testcontainers-go v0.33.0
github.com/testcontainers/testcontainers-go/modules/cassandra v0.33.0
github.com/testcontainers/testcontainers-go/modules/mongodb v0.32.0
github.com/testcontainers/testcontainers-go/modules/redis v0.33.0
github.com/testcontainers/testcontainers-go/modules/redpanda v0.33.0
Expand All @@ -38,7 +40,7 @@ require (
go.mongodb.org/mongo-driver v1.16.1
google.golang.org/grpc v1.65.0
google.golang.org/grpc/examples v0.0.0-20240816220358-f8d98a477c22
gopkg.in/DataDog/dd-trace-go.v1 v1.67.1-rc.2
gopkg.in/DataDog/dd-trace-go.v1 v1.67.1
gorm.io/driver/sqlite v1.5.6
gorm.io/gorm v1.25.11
gotest.tools/v3 v3.5.1
Expand Down Expand Up @@ -195,6 +197,7 @@ require (
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.13.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
github.com/hairyhenderson/go-codeowners v0.5.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
Expand Down
15 changes: 13 additions & 2 deletions _integration-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ github.com/bep/tmc v0.5.1 h1:CsQnSC6MsomH64gw0cT5f+EwQDcvZz4AazKunFwTpuI=
github.com/bep/tmc v0.5.1/go.mod h1:tGYHN8fS85aJPhDLgXETVKp+PR382OvFi2+q2GkGsq0=
github.com/bep/workers v1.0.0 h1:U+H8YmEaBCEaFZBst7GcRVEoqeRC9dzH2dWOwGmOchg=
github.com/bep/workers v1.0.0/go.mod h1:7kIESOB86HfR2379pwoMWNy8B50D7r99fRLUyPSNyCs=
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932 h1:mXoPYz/Ul5HYEDvkta6I8/rnYM5gSdSV2tJ6XbZuEtY=
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCSz6Q9T7+igc/hlvDOUdtWKryOrtFyIVABv/p7k=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
Expand Down Expand Up @@ -391,6 +395,8 @@ github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA=
github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/gocql/gocql v1.6.0 h1:IdFdOTbnpbd0pDhl4REKQDM+Q0SzKXQ1Yh+YZZ8T/qU=
github.com/gocql/gocql v1.6.0/go.mod h1:3gM2c4D3AnkISwBxGnMMsS8Oy4y2lhbPRsH4xnJrHG8=
github.com/gofiber/fiber/v2 v2.52.5 h1:tWoP1MJQjGEe4GB5TUGOi7P2E0ZMMRx5ZTG4rT+yGMo=
github.com/gofiber/fiber/v2 v2.52.5/go.mod h1:KEOE+cXMhXG0zHc9d8+E38hoX+ZN7bhOtgeF2oT6jrQ=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
Expand Down Expand Up @@ -451,6 +457,7 @@ github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/gomodule/redigo v1.9.2 h1:HrutZBLhSIU8abiSfW8pj8mPhOyMYjZT/wcA4/L9L9s=
Expand Down Expand Up @@ -528,6 +535,8 @@ github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aN
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rHAxPBD8KFhJpmcqms=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0/go.mod h1:YN5jB8ie0yfIUg6VvR9Kz84aCaG7AsGZnLjhHbUqwPg=
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8=
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4=
github.com/hairyhenderson/go-codeowners v0.5.0 h1:dpQB+hVHiRc2VVvc2BHxkuM+tmu9Qej/as3apqUbsWc=
github.com/hairyhenderson/go-codeowners v0.5.0/go.mod h1:R3uW1OQXEj2Gu6/OvZ7bt6hr0qdkLvUWPiqNaWnexpo=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
Expand Down Expand Up @@ -852,6 +861,8 @@ github.com/tdewolff/test v1.0.11-0.20240106005702-7de5f7df4739 h1:IkjBCtQOOjIn03
github.com/tdewolff/test v1.0.11-0.20240106005702-7de5f7df4739/go.mod h1:XPuWBzvdUzhCuxWO1ojpXsyzsA5bFoS3tO/Q3kFuTG8=
github.com/testcontainers/testcontainers-go v0.33.0 h1:zJS9PfXYT5O0ZFXM2xxXfk4J5UMw/kRiISng037Gxdw=
github.com/testcontainers/testcontainers-go v0.33.0/go.mod h1:W80YpTa8D5C3Yy16icheD01UTDu+LmXIA2Keo+jWtT8=
github.com/testcontainers/testcontainers-go/modules/cassandra v0.33.0 h1:Bpgl1+KQernz/8j6jwFZt3sDK7o9jCDaa3pVmQNJEU4=
github.com/testcontainers/testcontainers-go/modules/cassandra v0.33.0/go.mod h1:N6PuXZPZSUPioP8u5X67M8rPScL852hpZSMm8TDD3Tg=
github.com/testcontainers/testcontainers-go/modules/mongodb v0.32.0 h1:DvmvHV1irfNIVBhixeTAcoaWCvmdkoNQxRmZisqic4E=
github.com/testcontainers/testcontainers-go/modules/mongodb v0.32.0/go.mod h1:z0ZvM2V2iThZGrzEN6sddJpvnGhJd6O1O0FTFoZXmpk=
github.com/testcontainers/testcontainers-go/modules/redis v0.33.0 h1:S/QvMOwpr00MM2aWH+krzP73Erlp/Ug0dr2rkgZYI5s=
Expand Down Expand Up @@ -1343,8 +1354,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
gopkg.in/DataDog/dd-trace-go.v1 v1.67.1-rc.2 h1:n5+Mdtr4A8fPNntz1rUo8c4BUdTHOCIKyFpI5dOpX/8=
gopkg.in/DataDog/dd-trace-go.v1 v1.67.1-rc.2/go.mod h1:6DdiJPKOeJfZyd/IUGCAd5elY8qPGkztK6wbYYsMjag=
gopkg.in/DataDog/dd-trace-go.v1 v1.67.1 h1:frgcpZ18wmpj+/TwyDJM8057M65aOdgaxLiZ8pb1PFU=
gopkg.in/DataDog/dd-trace-go.v1 v1.67.1/go.mod h1:6DdiJPKOeJfZyd/IUGCAd5elY8qPGkztK6wbYYsMjag=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
141 changes: 141 additions & 0 deletions _integration-tests/tests/gocql/base.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2023-present Datadog, Inc.

//go:build integration

package gocql

import (
"context"
"net"
"testing"
"time"

"github.com/gocql/gocql"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/testcontainers/testcontainers-go"
testcassandra "github.com/testcontainers/testcontainers-go/modules/cassandra"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"

"orchestrion/integration/utils"
"orchestrion/integration/validator/trace"
)

type base struct {
container *testcassandra.CassandraContainer
session *gocql.Session
hostPort string
port string
}

func (b *base) setup(t *testing.T) {
ctx := context.Background()

var err error
b.container, err = testcassandra.Run(ctx,
"cassandra:4.1",
testcontainers.WithLogger(testcontainers.TestLogger(t)),
utils.WithTestLogConsumer(t),
)
utils.AssertTestContainersError(t, err)

b.hostPort, err = b.container.ConnectionHost(ctx)
require.NoError(t, err)

_, b.port, err = net.SplitHostPort(b.hostPort)
require.NoError(t, err)
}

func (b *base) teardown(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()

b.session.Close()
assert.NoError(t, b.container.Terminate(ctx))
}

func (b *base) run(t *testing.T) {
span, ctx := tracer.StartSpanFromContext(context.Background(), "test.root")
defer span.Finish()

err := b.session.
Query("CREATE KEYSPACE if not exists trace WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor': 1}").
WithContext(ctx).
Exec()
require.NoError(t, err)

err = b.session.
Query("CREATE TABLE if not exists trace.person (name text PRIMARY KEY, age int, description text)").
WithContext(ctx).
Exec()
require.NoError(t, err)

err = b.session.
Query("INSERT INTO trace.person (name, age, description) VALUES ('Cassandra', 100, 'A cruel mistress')").
WithContext(ctx).
Exec()
require.NoError(t, err)
}

func (b *base) expectedSpans() trace.Spans {
return trace.Spans{
{
Tags: map[string]any{
"name": "test.root",
},
Children: trace.Spans{
{
Tags: map[string]any{
"name": "cassandra.query",
"service": "gocql.query",
"resource": "CREATE KEYSPACE if not exists trace WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor': 1}",
"type": "cassandra",
},
Meta: map[string]any{
"component": "gocql/gocql",
"span.kind": "client",
"db.system": "cassandra",
"out.port": b.port,
"cassandra.cluster": "Test Cluster",
"cassandra.datacenter": "datacenter1",
},
},
{
Tags: map[string]any{
"name": "cassandra.query",
"service": "gocql.query",
"resource": "CREATE TABLE if not exists trace.person (name text PRIMARY KEY, age int, description text)",
"type": "cassandra",
},
Meta: map[string]any{
"component": "gocql/gocql",
"span.kind": "client",
"db.system": "cassandra",
"out.port": b.port,
"cassandra.cluster": "Test Cluster",
"cassandra.datacenter": "datacenter1",
},
},
{
Tags: map[string]any{
"name": "cassandra.query",
"service": "gocql.query",
"resource": "INSERT INTO trace.person (name, age, description) VALUES ('Cassandra', 100, 'A cruel mistress')",
"type": "cassandra",
},
Meta: map[string]any{
"component": "gocql/gocql",
"span.kind": "client",
"db.system": "cassandra",
"out.port": b.port,
"cassandra.cluster": "Test Cluster",
"cassandra.datacenter": "datacenter1",
},
},
},
},
}
}
42 changes: 42 additions & 0 deletions _integration-tests/tests/gocql/new_cluster.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2023-present Datadog, Inc.

//go:build integration

package gocql

import (
"testing"

"github.com/gocql/gocql"
"github.com/stretchr/testify/require"

"orchestrion/integration/validator/trace"
)

type TestCaseNewCluster struct {
base
}

func (tc *TestCaseNewCluster) Setup(t *testing.T) {
tc.setup(t)

var err error
cluster := gocql.NewCluster(tc.hostPort)
tc.session, err = cluster.CreateSession()
require.NoError(t, err)
}

func (tc *TestCaseNewCluster) Run(t *testing.T) {
tc.base.run(t)
}

func (tc *TestCaseNewCluster) Teardown(t *testing.T) {
tc.base.teardown(t)
}

func (tc *TestCaseNewCluster) ExpectedTraces() trace.Spans {
return tc.base.expectedSpans()
}
Loading

0 comments on commit f70b096

Please sign in to comment.