diff --git a/.github/workflows/muzzle.yml b/.github/workflows/muzzle.yml index 8c010d5d..6d510fc1 100644 --- a/.github/workflows/muzzle.yml +++ b/.github/workflows/muzzle.yml @@ -14,15 +14,18 @@ jobs: build: runs-on: ubuntu-latest steps: + - name: Free Disk Space (Ubuntu) + uses: jlumbroso/free-disk-space@main + with: + # this might remove tools that are actually needed, + # when set to "true" but frees about 6 GB + tool-cache: true - uses: actions/checkout@v4 - - name: Set up Go uses: actions/setup-go@v4 with: go-version: '1.23' - - name: Build run: make build - - name: Test run: go test -timeout 50m -v github.com/alibaba/opentelemetry-go-auto-instrumentation/test -run ".*Muzzle" diff --git a/README.md b/README.md index 9ab9006d..47fd8c13 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ Also there are several [**documents**](./docs) that you may find useful for eith |--------------| ------------------------------------------ | --------------------- |-----------------------| | database/sql | https://pkg.go.dev/database/sql | - | - | | echo | https://github.com/labstack/echo | v4.0.0 | v4.12.0 | +| elasticsearch| https://github.com/elastic/go-elasticsearch| v8.4.0 | v8.15.0 | | fasthttp | https://github.com/valyala/fasthttp | v1.45.0 | v1.57.0 | | gin | https://github.com/gin-gonic/gin | v1.7.0 | v1.10.0 | | go-redis | https://github.com/redis/go-redis | v9.0.5 | v9.5.1 | diff --git a/docs/supported-libraries.md b/docs/supported-libraries.md index 8e61361a..293f4c8d 100644 --- a/docs/supported-libraries.md +++ b/docs/supported-libraries.md @@ -4,6 +4,7 @@ |--------------| ------------------------------------------ | --------------------- |-----------------------| | database/sql | https://pkg.go.dev/database/sql | - | - | | echo | https://github.com/labstack/echo | v4.0.0 | v4.12.0 | +| elasticsearch| https://github.com/elastic/go-elasticsearch| v8.4.0 | v8.15.0 | | fasthttp | https://github.com/valyala/fasthttp | v1.45.0 | v1.57.0 | | gin | https://github.com/gin-gonic/gin | v1.7.0 | v1.10.0 | | go-redis | https://github.com/redis/go-redis | v9.0.5 | v9.5.1 | diff --git a/go.mod b/go.mod index 1eae4c77..b4dc8a0b 100755 --- a/go.mod +++ b/go.mod @@ -11,6 +11,8 @@ require ( github.com/cloudwego/hertz v0.9.3 github.com/dave/dst v0.27.3 github.com/docker/go-connections v0.5.0 + github.com/elastic/elastic-transport-go/v8 v8.1.0 + github.com/elastic/go-elasticsearch/v8 v8.4.0 github.com/gin-gonic/gin v1.10.0 github.com/go-kratos/kratos/v2 v2.8.0 github.com/go-redis/redis/v8 v8.11.0 diff --git a/go.sum b/go.sum index 684f7f68..a6c544f5 100644 --- a/go.sum +++ b/go.sum @@ -70,6 +70,12 @@ github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= +github.com/elastic/elastic-transport-go/v8 v8.0.0-alpha h1:SW9xcMVxx4Nv9oRm5rQxzAMAatwiZV8xROP2a48y45Q= +github.com/elastic/elastic-transport-go/v8 v8.0.0-alpha/go.mod h1:87Tcz8IVNe6rVSLdBux1o/PEItLtyabHU3naC7IoqKI= +github.com/elastic/elastic-transport-go/v8 v8.1.0/go.mod h1:87Tcz8IVNe6rVSLdBux1o/PEItLtyabHU3naC7IoqKI= +github.com/elastic/go-elasticsearch/v8 v8.0.0 h1:Hte+pgoEZI88j/sQx7u9vK9SqisvJYkYMmxDnQXiJyM= +github.com/elastic/go-elasticsearch/v8 v8.0.0/go.mod h1:8NCWP26meGbncX+R9sxo2JD8IqBjRTuS7yXMstHpd40= +github.com/elastic/go-elasticsearch/v8 v8.4.0/go.mod h1:yY52i2Vj0unLz+N3Nwx1gM5LXwoj3h2dgptNGBYkMLA= github.com/envoyproxy/go-control-plane v0.13.0 h1:HzkeUz1Knt+3bK+8LG1bxOO/jzWZmdxpwC51i202les= github.com/envoyproxy/go-control-plane v0.13.0/go.mod h1:GRaKG3dwvFoTg4nj7aXdZnvMg4d7nvT/wl9WgVXn3Q8= github.com/envoyproxy/protoc-gen-validate v1.1.0 h1:tntQDh69XqOCOZsDz0lVJQez/2L6Uu2PdjCQwWCJ3bM= diff --git a/pkg/data/default.json b/pkg/data/default.json index 334e5150..26121606 100644 --- a/pkg/data/default.json +++ b/pkg/data/default.json @@ -1,566 +1,575 @@ [ - { - "ImportPath": "runtime", - "StructType": "g", - "FieldName": "otel_trace_context", - "FieldType": "interface{}" - }, - { - "ImportPath": "runtime", - "StructType": "g", - "FieldName": "otel_baggage_container", - "FieldType": "interface{}" - }, - { - "ImportPath": "runtime", - "Function": "newproc1", - "OnEnter": "defer func(){ retVal0.otel_trace_context = contextPropagate(callergp.otel_trace_context); retVal0.otel_baggage_container = contextPropagate(callergp.otel_baggage_container); }()", - "UseRaw": true - }, - { - "ImportPath": "runtime", - "FileName": "runtime_linker.go", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/runtime" - }, - { - "ImportPath": "database/sql", - "StructType": "DB", - "FieldName": "Endpoint", - "FieldType": "string" - }, - { - "ImportPath": "database/sql", - "StructType": "DB", - "FieldName": "DriverName", - "FieldType": "string" - }, - { - "ImportPath": "database/sql", - "StructType": "DB", - "FieldName": "DSN", - "FieldType": "string" - }, - { - "ImportPath": "database/sql", - "StructType": "Stmt", - "FieldName": "Data", - "FieldType": "map[string]string" - }, - { - "ImportPath": "database/sql", - "StructType": "Stmt", - "FieldName": "DriverName", - "FieldType": "string" - }, - { - "ImportPath": "database/sql", - "StructType": "Stmt", - "FieldName": "DSN", - "FieldType": "string" - }, - { - "ImportPath": "database/sql", - "StructType": "Tx", - "FieldName": "Endpoint", - "FieldType": "string" - }, - { - "ImportPath": "database/sql", - "StructType": "Tx", - "FieldName": "DriverName", - "FieldType": "string" - }, - { - "ImportPath": "database/sql", - "StructType": "Tx", - "FieldName": "DSN", - "FieldType": "string" - }, - { - "ImportPath": "database/sql", - "StructType": "Conn", - "FieldName": "Endpoint", - "FieldType": "string" - }, - { - "ImportPath": "database/sql", - "StructType": "Conn", - "FieldName": "DriverName", - "FieldType": "string" - }, - { - "ImportPath": "database/sql", - "StructType": "Conn", - "FieldName": "DSN", - "FieldType": "string" - }, - { - "ImportPath": "database/sql", - "Function": "Open", - "OnEnter": "beforeOpenInstrumentation", - "OnExit": "afterOpenInstrumentation", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" - }, - { - "ImportPath": "database/sql", - "Function": "PingContext", - "ReceiverType": "*DB", - "OnEnter": "beforePingContextInstrumentation", - "OnExit": "afterPingContextInstrumentation", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" - }, - { - "ImportPath": "database/sql", - "Function": "PrepareContext", - "ReceiverType": "*DB", - "OnEnter": "beforePrepareContextInstrumentation", - "OnExit": "afterPrepareContextInstrumentation", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" - }, - { - "ImportPath": "database/sql", - "Function": "ExecContext", - "ReceiverType": "*DB", - "OnEnter": "beforeExecContextInstrumentation", - "OnExit": "afterExecContextInstrumentation", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" - }, - { - "ImportPath": "database/sql", - "Function": "QueryContext", - "ReceiverType": "*DB", - "OnEnter": "beforeQueryContextInstrumentation", - "OnExit": "afterQueryContextInstrumentation", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" - }, - { - "ImportPath": "database/sql", - "Function": "BeginTx", - "ReceiverType": "*DB", - "OnEnter": "beforeTxInstrumentation", - "OnExit": "afterTxInstrumentation", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" - }, - { - "ImportPath": "database/sql", - "Function": "Conn", - "ReceiverType": "*DB", - "OnEnter": "beforeConnInstrumentation", - "OnExit": "afterConnInstrumentation", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" - }, - { - "ImportPath": "database/sql", - "Function": "PingContext", - "ReceiverType": "*Conn", - "OnEnter": "beforeConnPingContextInstrumentation", - "OnExit": "afterConnPingContextInstrumentation", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" - }, - { - "ImportPath": "database/sql", - "Function": "PrepareContext", - "ReceiverType": "*Conn", - "OnEnter": "beforeConnPrepareContextInstrumentation", - "OnExit": "afterConnPrepareContextInstrumentation", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" - }, - { - "ImportPath": "database/sql", - "Function": "ExecContext", - "ReceiverType": "*Conn", - "OnEnter": "beforeConnExecContextInstrumentation", - "OnExit": "afterConnExecContextInstrumentation", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" - }, - { - "ImportPath": "database/sql", - "Function": "QueryContext", - "ReceiverType": "*Conn", - "OnEnter": "beforeConnQueryContextInstrumentation", - "OnExit": "afterConnQueryContextInstrumentation", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" - }, - { - "ImportPath": "database/sql", - "Function": "BeginTx", - "ReceiverType": "*Conn", - "OnEnter": "beforeConnTxInstrumentation", - "OnExit": "afterConnTxInstrumentation", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" - }, - { - "ImportPath": "database/sql", - "Function": "StmtContext", - "ReceiverType": "*Tx", - "OnEnter": "beforeTxStmtContextInstrumentation", - "OnExit": "afterTxStmtContextInstrumentation", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" - }, - { - "ImportPath": "database/sql", - "Function": "PrepareContext", - "ReceiverType": "*Tx", - "OnEnter": "beforeTxPrepareContextInstrumentation", - "OnExit": "afterTxPrepareContextInstrumentation", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" - }, - { - "ImportPath": "database/sql", - "Function": "ExecContext", - "ReceiverType": "*Tx", - "OnEnter": "beforeTxExecContextInstrumentation", - "OnExit": "afterTxExecContextInstrumentation", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" - }, - { - "ImportPath": "database/sql", - "Function": "QueryContext", - "ReceiverType": "*Tx", - "OnEnter": "beforeTxQueryContextInstrumentation", - "OnExit": "afterTxQueryContextInstrumentation", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" - }, - { - "ImportPath": "database/sql", - "Function": "Commit", - "ReceiverType": "*Tx", - "OnEnter": "beforeTxCommitInstrumentation", - "OnExit": "afterTxCommitInstrumentation", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" - }, - { - "ImportPath": "database/sql", - "Function": "Rollback", - "ReceiverType": "*Tx", - "OnEnter": "beforeTxRollbackInstrumentation", - "OnExit": "afterTxRollbackInstrumentation", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" - }, - { - "ImportPath": "database/sql", - "Function": "ExecContext", - "ReceiverType": "*Stmt", - "OnEnter": "beforeStmtExecContextInstrumentation", - "OnExit": "afterStmtExecContextInstrumentation", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" - }, - { - "ImportPath": "database/sql", - "Function": "QueryContext", - "ReceiverType": "*Stmt", - "OnEnter": "beforeStmtQueryContextInstrumentation", - "OnExit": "afterStmtQueryContextInstrumentation", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" - }, - { - "Version": "[4.0.0,4.12.1)", - "ImportPath": "github.com/labstack/echo/v4", - "Function": "New", - "OnExit": "afterNewEcho", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/echo" - }, - { - "Version": "[1.7.0,1.10.1)", - "ImportPath": "github.com/gin-gonic/gin", - "Function": "Next", - "ReceiverType": "*Context", - "OnEnter": "nextOnEnter", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/gin" - }, - { - "Version": "[1.7.0,1.10.1)", - "ImportPath": "github.com/gin-gonic/gin", - "Function": "HTML", - "ReceiverType": "*Context", - "OnEnter": "htmlOnEnter", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/gin" - }, - { - "ImportPath": "github.com/redis/go-redis/v9", - "Function": "NewClient", - "OnExit": "afterNewRedisClient", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/goredis" - }, - { - "Version": "[9.0.5,9.5.2)", - "ImportPath": "github.com/redis/go-redis/v9", - "Function": "NewFailoverClient", - "OnExit": "afterNewFailOverRedisClient", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/goredis" - }, - { - "Version": "[9.0.5,9.5.2)", - "ImportPath": "github.com/redis/go-redis/v9", - "Function": "NewSentinelClient", - "OnExit": "afterNewSentinelClient", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/goredis" - }, - { - "Version": "[9.0.5,9.5.2)", - "ImportPath": "github.com/redis/go-redis/v9", - "Function": "Conn", - "ReceiverType": "*Client", - "OnExit": "afterClientConn", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/goredis" - }, - { - "Version": "[9.0.5,9.5.2)", - "ImportPath": "github.com/redis/go-redis/v9", - "Function": "NewClusterClient", - "OnExit": "afterNewClusterClient", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/goredis" - }, - { - "Version": "[9.0.5,9.5.2)", - "ImportPath": "github.com/redis/go-redis/v9", - "Function": "NewRing", - "OnExit": "afterNewRingClient", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/goredis" - }, - { - "Version": "[8.11.0,8.11.6)", - "ImportPath": "github.com/go-redis/redis/v8", - "Function": "NewClient", - "OnExit": "afterNewRedisV8Client", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/goredisv8" - }, - { - "Version": "[8.11.0,8.11.6)", - "ImportPath": "github.com/go-redis/redis/v8", - "Function": "NewFailoverClient", - "OnExit": "afterNewFailOverRedisV8Client", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/goredisv8" - }, - { - "Version": "[8.11.0,8.11.6)", - "ImportPath": "github.com/go-redis/redis/v8", - "Function": "newConn", - "OnExit": "afterNewConnRedisV8Client", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/goredisv8" - }, - { - "Version": "[8.11.0,8.11.6)", - "ImportPath": "github.com/go-redis/redis/v8", - "Function": "NewClusterClient", - "OnExit": "afterNewClusterV8Client", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/goredisv8" - }, - { - "Version": "[8.11.0,8.11.6)", - "ImportPath": "github.com/go-redis/redis/v8", - "Function": "NewRing", - "OnExit": "afterNewRingV8Client", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/goredisv8" - }, - { - "Version": "[1.9.0,1.9.3)", - "ImportPath": "github.com/gomodule/redigo/redis", - "Function": "DialContext", - "OnEnter": "onBeforeDialContext", - "OnExit": "onExitDialContext", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/redigo" - }, - { - "ImportPath": "gorm.io/driver/mysql", - "StructType": "Dialector", - "FieldName": "DbInfo", - "FieldType": "interface{}" - }, - { - "Version": "[1.22.0,1.25.10)", - "ImportPath": "gorm.io/gorm", - "Function": "Open", - "OnExit": "afterGormOpen", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/gorm" - }, - { - "ImportPath": "net/http", - "Function": "RoundTrip", - "ReceiverType": "*Transport", - "OnEnter": "clientOnEnter", - "OnExit": "clientOnExit", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/http" - }, - { - "ImportPath": "net/http", - "Function": "ServeHTTP", - "ReceiverType": "serverHandler", - "OnEnter": "serverOnEnter", - "OnExit": "serverOnExit", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/http" - }, - { - "Version": "[1.5.0,1.9.4)", - "ImportPath": "github.com/sirupsen/logrus", - "Function": "SetFormatter", - "OnExit": "logNewOnExit", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/logrus" - }, - { - "Version": "[1.11.1,1.15.2)", - "ImportPath": "go.mongodb.org/mongo-driver/mongo", - "Function": "NewClient", - "OnEnter": "mongoOnEnter", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/mongo" - }, - { - "Version": "[1.3.0,1.7.4)", - "ImportPath": "github.com/gorilla/mux", - "Function": "setCurrentRoute", - "OnEnter": "muxRoute130OnEnter", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/mux" - }, - { - "Version": "[1.7.4,1.8.2)", - "ImportPath": "github.com/gorilla/mux", - "Function": "requestWithRoute", - "OnEnter": "muxRoute174OnEnter", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/mux" - }, - { - "ImportPath": "go.opentelemetry.io/otel/sdk/trace", - "FileName": "otel_trace_context_linker.go", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/otel-sdk" - }, - { - "ImportPath": "go.opentelemetry.io/otel/sdk/trace", - "FileName": "trace-context/otel_trace_context.go", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/otel-sdk" - }, - { - "ImportPath": "go.opentelemetry.io/otel/sdk/trace", - "FileName": "trace-context/span.go", - "Replace": true, - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/otel-sdk" - }, - { - "ImportPath": "go.opentelemetry.io/otel/sdk/trace", - "FileName": "trace-context/tracer.go", - "Replace": true, - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/otel-sdk" - }, - { - "ImportPath": "go.opentelemetry.io/otel/trace", - "Function": "SpanFromContext", - "OnExit": "spanFromContextOnExit", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/otel-context" - }, - { - "ImportPath": "go.opentelemetry.io/otel", - "FileName": "trace-context/trace.go", - "Replace": true, - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/otel-sdk" - }, - { - "ImportPath": "go.opentelemetry.io/otel/baggage", - "FileName": "otel_baggage_linker.go", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/otel-sdk" - }, - { - "ImportPath": "go.opentelemetry.io/otel/baggage", - "FileName": "otel_baggage_util.go", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/otel-sdk" - }, - { - "ImportPath": "go.opentelemetry.io/otel/baggage", - "FileName": "baggage/context.go", - "Replace": true, - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/otel-sdk" - }, - { - "Version": "[1.20.0,1.27.1)", - "ImportPath": "go.uber.org/zap/zapcore", - "Function": "Write", - "ReceiverType": "*CheckedEntry", - "OnEnter": "zapLogWriteOnEnter", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/zap" - }, - { - "ImportPath": "google.golang.org/grpc", - "Function": "DialContext", - "OnEnter": "grpcClientOnEnter", - "OnExit": "grpcClientOnExit", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/grpc" - }, - { - "ImportPath": "google.golang.org/grpc", - "Function": "NewClient", - "OnEnter": "grpcNewClientOnEnter", - "OnExit": "grpcNewClientOnExit", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/grpc" - }, - { - "ImportPath": "google.golang.org/grpc", - "Function": "NewServer", - "OnEnter": "grpcServerOnEnter", - "OnExit": "grpcServerOnExit", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/grpc" - }, - { - "ImportPath": "github.com/cloudwego/hertz/pkg/app/server", - "Function": "New", - "OnEnter": "beforeHertzServerBuild", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/hertz/server" - }, - { - "ImportPath": "github.com/cloudwego/hertz/pkg/app/client", - "Function": "NewClient", - "OnExit": "afterHertzClientBuild", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/hertz/client" - }, - { - "Version": "[1.45.0,1.57.1)", - "ImportPath": "github.com/valyala/fasthttp", - "Function": "Do", - "ReceiverType": "*HostClient", - "OnEnter": "clientFastHttpOnEnter", - "OnExit": "clientFastHttpOnExit", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/fasthttp" - }, - { - "Version": "[1.45.0,1.57.1)", - "ImportPath": "github.com/valyala/fasthttp", - "Function": "ListenAndServe", - "ReceiverType": "*Server", - "OnEnter": "listenAndServeFastHttpOnEnter", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/fasthttp" - }, - { - "ImportPath": "log", - "Function": "output", - "ReceiverType": "*Logger", - "OnEnter": "goLogWriteOnEnter", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/golog" - }, - { - "ImportPath": "log/slog", - "Function": "log", - "ReceiverType": "*Logger", - "OnEnter": "goSlogWriteOnEnter", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/goslog" - }, - { - "Version": "[2.6.3,2.8.3)", - "ImportPath": "github.com/go-kratos/kratos/v2/transport/http", - "Function": "NewServer", - "OnEnter": "KratosNewHTTPServiceOnEnter", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/kratos/http" - }, - { - "Version": "[2.6.3,2.8.3)", - "ImportPath": "github.com/go-kratos/kratos/v2/transport/grpc", - "Function": "NewServer", - "OnEnter": "KratosNewGRPCServiceOnEnter", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/kratos/grpc" - }, - { - "Version": "[2.43.0,2.52.6)", - "ImportPath": "github.com/gofiber/fiber/v2", - "Function": "handler", - "ReceiverType": "*App", - "OnEnter": "fiberHttpOnEnterv2", - "OnExit": "fiberHttpOnExitv2", - "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/fiberv2" - } + { + "ImportPath": "runtime", + "StructType": "g", + "FieldName": "otel_trace_context", + "FieldType": "interface{}" + }, + { + "ImportPath": "runtime", + "StructType": "g", + "FieldName": "otel_baggage_container", + "FieldType": "interface{}" + }, + { + "ImportPath": "runtime", + "Function": "newproc1", + "OnEnter": "defer func(){ retVal0.otel_trace_context = contextPropagate(callergp.otel_trace_context); retVal0.otel_baggage_container = contextPropagate(callergp.otel_baggage_container); }()", + "UseRaw": true + }, + { + "ImportPath": "runtime", + "FileName": "runtime_linker.go", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/runtime" + }, + { + "ImportPath": "database/sql", + "StructType": "DB", + "FieldName": "Endpoint", + "FieldType": "string" + }, + { + "ImportPath": "database/sql", + "StructType": "DB", + "FieldName": "DriverName", + "FieldType": "string" + }, + { + "ImportPath": "database/sql", + "StructType": "DB", + "FieldName": "DSN", + "FieldType": "string" + }, + { + "ImportPath": "database/sql", + "StructType": "Stmt", + "FieldName": "Data", + "FieldType": "map[string]string" + }, + { + "ImportPath": "database/sql", + "StructType": "Stmt", + "FieldName": "DriverName", + "FieldType": "string" + }, + { + "ImportPath": "database/sql", + "StructType": "Stmt", + "FieldName": "DSN", + "FieldType": "string" + }, + { + "ImportPath": "database/sql", + "StructType": "Tx", + "FieldName": "Endpoint", + "FieldType": "string" + }, + { + "ImportPath": "database/sql", + "StructType": "Tx", + "FieldName": "DriverName", + "FieldType": "string" + }, + { + "ImportPath": "database/sql", + "StructType": "Tx", + "FieldName": "DSN", + "FieldType": "string" + }, + { + "ImportPath": "database/sql", + "StructType": "Conn", + "FieldName": "Endpoint", + "FieldType": "string" + }, + { + "ImportPath": "database/sql", + "StructType": "Conn", + "FieldName": "DriverName", + "FieldType": "string" + }, + { + "ImportPath": "database/sql", + "StructType": "Conn", + "FieldName": "DSN", + "FieldType": "string" + }, + { + "ImportPath": "database/sql", + "Function": "Open", + "OnEnter": "beforeOpenInstrumentation", + "OnExit": "afterOpenInstrumentation", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" + }, + { + "ImportPath": "database/sql", + "Function": "PingContext", + "ReceiverType": "*DB", + "OnEnter": "beforePingContextInstrumentation", + "OnExit": "afterPingContextInstrumentation", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" + }, + { + "ImportPath": "database/sql", + "Function": "PrepareContext", + "ReceiverType": "*DB", + "OnEnter": "beforePrepareContextInstrumentation", + "OnExit": "afterPrepareContextInstrumentation", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" + }, + { + "ImportPath": "database/sql", + "Function": "ExecContext", + "ReceiverType": "*DB", + "OnEnter": "beforeExecContextInstrumentation", + "OnExit": "afterExecContextInstrumentation", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" + }, + { + "ImportPath": "database/sql", + "Function": "QueryContext", + "ReceiverType": "*DB", + "OnEnter": "beforeQueryContextInstrumentation", + "OnExit": "afterQueryContextInstrumentation", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" + }, + { + "ImportPath": "database/sql", + "Function": "BeginTx", + "ReceiverType": "*DB", + "OnEnter": "beforeTxInstrumentation", + "OnExit": "afterTxInstrumentation", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" + }, + { + "ImportPath": "database/sql", + "Function": "Conn", + "ReceiverType": "*DB", + "OnEnter": "beforeConnInstrumentation", + "OnExit": "afterConnInstrumentation", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" + }, + { + "ImportPath": "database/sql", + "Function": "PingContext", + "ReceiverType": "*Conn", + "OnEnter": "beforeConnPingContextInstrumentation", + "OnExit": "afterConnPingContextInstrumentation", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" + }, + { + "ImportPath": "database/sql", + "Function": "PrepareContext", + "ReceiverType": "*Conn", + "OnEnter": "beforeConnPrepareContextInstrumentation", + "OnExit": "afterConnPrepareContextInstrumentation", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" + }, + { + "ImportPath": "database/sql", + "Function": "ExecContext", + "ReceiverType": "*Conn", + "OnEnter": "beforeConnExecContextInstrumentation", + "OnExit": "afterConnExecContextInstrumentation", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" + }, + { + "ImportPath": "database/sql", + "Function": "QueryContext", + "ReceiverType": "*Conn", + "OnEnter": "beforeConnQueryContextInstrumentation", + "OnExit": "afterConnQueryContextInstrumentation", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" + }, + { + "ImportPath": "database/sql", + "Function": "BeginTx", + "ReceiverType": "*Conn", + "OnEnter": "beforeConnTxInstrumentation", + "OnExit": "afterConnTxInstrumentation", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" + }, + { + "ImportPath": "database/sql", + "Function": "StmtContext", + "ReceiverType": "*Tx", + "OnEnter": "beforeTxStmtContextInstrumentation", + "OnExit": "afterTxStmtContextInstrumentation", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" + }, + { + "ImportPath": "database/sql", + "Function": "PrepareContext", + "ReceiverType": "*Tx", + "OnEnter": "beforeTxPrepareContextInstrumentation", + "OnExit": "afterTxPrepareContextInstrumentation", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" + }, + { + "ImportPath": "database/sql", + "Function": "ExecContext", + "ReceiverType": "*Tx", + "OnEnter": "beforeTxExecContextInstrumentation", + "OnExit": "afterTxExecContextInstrumentation", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" + }, + { + "ImportPath": "database/sql", + "Function": "QueryContext", + "ReceiverType": "*Tx", + "OnEnter": "beforeTxQueryContextInstrumentation", + "OnExit": "afterTxQueryContextInstrumentation", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" + }, + { + "ImportPath": "database/sql", + "Function": "Commit", + "ReceiverType": "*Tx", + "OnEnter": "beforeTxCommitInstrumentation", + "OnExit": "afterTxCommitInstrumentation", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" + }, + { + "ImportPath": "database/sql", + "Function": "Rollback", + "ReceiverType": "*Tx", + "OnEnter": "beforeTxRollbackInstrumentation", + "OnExit": "afterTxRollbackInstrumentation", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" + }, + { + "ImportPath": "database/sql", + "Function": "ExecContext", + "ReceiverType": "*Stmt", + "OnEnter": "beforeStmtExecContextInstrumentation", + "OnExit": "afterStmtExecContextInstrumentation", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" + }, + { + "ImportPath": "database/sql", + "Function": "QueryContext", + "ReceiverType": "*Stmt", + "OnEnter": "beforeStmtQueryContextInstrumentation", + "OnExit": "afterStmtQueryContextInstrumentation", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/databasesql" + }, + { + "Version": "[4.0.0,4.12.1)", + "ImportPath": "github.com/labstack/echo/v4", + "Function": "New", + "OnExit": "afterNewEcho", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/echo" + }, + { + "Version": "[1.7.0,1.10.1)", + "ImportPath": "github.com/gin-gonic/gin", + "Function": "Next", + "ReceiverType": "*Context", + "OnEnter": "nextOnEnter", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/gin" + }, + { + "Version": "[1.7.0,1.10.1)", + "ImportPath": "github.com/gin-gonic/gin", + "Function": "HTML", + "ReceiverType": "*Context", + "OnEnter": "htmlOnEnter", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/gin" + }, + { + "ImportPath": "github.com/redis/go-redis/v9", + "Function": "NewClient", + "OnExit": "afterNewRedisClient", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/goredis" + }, + { + "Version": "[9.0.5,9.5.2)", + "ImportPath": "github.com/redis/go-redis/v9", + "Function": "NewFailoverClient", + "OnExit": "afterNewFailOverRedisClient", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/goredis" + }, + { + "Version": "[9.0.5,9.5.2)", + "ImportPath": "github.com/redis/go-redis/v9", + "Function": "NewSentinelClient", + "OnExit": "afterNewSentinelClient", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/goredis" + }, + { + "Version": "[9.0.5,9.5.2)", + "ImportPath": "github.com/redis/go-redis/v9", + "Function": "Conn", + "ReceiverType": "*Client", + "OnExit": "afterClientConn", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/goredis" + }, + { + "Version": "[9.0.5,9.5.2)", + "ImportPath": "github.com/redis/go-redis/v9", + "Function": "NewClusterClient", + "OnExit": "afterNewClusterClient", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/goredis" + }, + { + "Version": "[9.0.5,9.5.2)", + "ImportPath": "github.com/redis/go-redis/v9", + "Function": "NewRing", + "OnExit": "afterNewRingClient", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/goredis" + }, + { + "Version": "[8.11.0,8.11.6)", + "ImportPath": "github.com/go-redis/redis/v8", + "Function": "NewClient", + "OnExit": "afterNewRedisV8Client", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/goredisv8" + }, + { + "Version": "[8.11.0,8.11.6)", + "ImportPath": "github.com/go-redis/redis/v8", + "Function": "NewFailoverClient", + "OnExit": "afterNewFailOverRedisV8Client", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/goredisv8" + }, + { + "Version": "[8.11.0,8.11.6)", + "ImportPath": "github.com/go-redis/redis/v8", + "Function": "newConn", + "OnExit": "afterNewConnRedisV8Client", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/goredisv8" + }, + { + "Version": "[8.11.0,8.11.6)", + "ImportPath": "github.com/go-redis/redis/v8", + "Function": "NewClusterClient", + "OnExit": "afterNewClusterV8Client", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/goredisv8" + }, + { + "Version": "[8.11.0,8.11.6)", + "ImportPath": "github.com/go-redis/redis/v8", + "Function": "NewRing", + "OnExit": "afterNewRingV8Client", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/goredisv8" + }, + { + "Version": "[1.9.0,1.9.3)", + "ImportPath": "github.com/gomodule/redigo/redis", + "Function": "DialContext", + "OnEnter": "onBeforeDialContext", + "OnExit": "onExitDialContext", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/redigo" + }, + { + "ImportPath": "gorm.io/driver/mysql", + "StructType": "Dialector", + "FieldName": "DbInfo", + "FieldType": "interface{}" + }, + { + "Version": "[1.22.0,1.25.10)", + "ImportPath": "gorm.io/gorm", + "Function": "Open", + "OnExit": "afterGormOpen", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/gorm" + }, + { + "ImportPath": "net/http", + "Function": "RoundTrip", + "ReceiverType": "*Transport", + "OnEnter": "clientOnEnter", + "OnExit": "clientOnExit", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/http" + }, + { + "ImportPath": "net/http", + "Function": "ServeHTTP", + "ReceiverType": "serverHandler", + "OnEnter": "serverOnEnter", + "OnExit": "serverOnExit", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/http" + }, + { + "Version": "[1.5.0,1.9.4)", + "ImportPath": "github.com/sirupsen/logrus", + "Function": "SetFormatter", + "OnExit": "logNewOnExit", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/logrus" + }, + { + "Version": "[1.11.1,1.15.2)", + "ImportPath": "go.mongodb.org/mongo-driver/mongo", + "Function": "NewClient", + "OnEnter": "mongoOnEnter", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/mongo" + }, + { + "Version": "[1.3.0,1.7.4)", + "ImportPath": "github.com/gorilla/mux", + "Function": "setCurrentRoute", + "OnEnter": "muxRoute130OnEnter", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/mux" + }, + { + "Version": "[1.7.4,1.8.2)", + "ImportPath": "github.com/gorilla/mux", + "Function": "requestWithRoute", + "OnEnter": "muxRoute174OnEnter", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/mux" + }, + { + "ImportPath": "go.opentelemetry.io/otel/sdk/trace", + "FileName": "otel_trace_context_linker.go", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/otel-sdk" + }, + { + "ImportPath": "go.opentelemetry.io/otel/sdk/trace", + "FileName": "trace-context/otel_trace_context.go", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/otel-sdk" + }, + { + "ImportPath": "go.opentelemetry.io/otel/sdk/trace", + "FileName": "trace-context/span.go", + "Replace": true, + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/otel-sdk" + }, + { + "ImportPath": "go.opentelemetry.io/otel/sdk/trace", + "FileName": "trace-context/tracer.go", + "Replace": true, + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/otel-sdk" + }, + { + "ImportPath": "go.opentelemetry.io/otel/trace", + "Function": "SpanFromContext", + "OnExit": "spanFromContextOnExit", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/otel-context" + }, + { + "ImportPath": "go.opentelemetry.io/otel", + "FileName": "trace-context/trace.go", + "Replace": true, + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/otel-sdk" + }, + { + "ImportPath": "go.opentelemetry.io/otel/baggage", + "FileName": "otel_baggage_linker.go", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/otel-sdk" + }, + { + "ImportPath": "go.opentelemetry.io/otel/baggage", + "FileName": "otel_baggage_util.go", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/otel-sdk" + }, + { + "ImportPath": "go.opentelemetry.io/otel/baggage", + "FileName": "baggage/context.go", + "Replace": true, + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/otel-sdk" + }, + { + "Version": "[1.20.0,1.27.1)", + "ImportPath": "go.uber.org/zap/zapcore", + "Function": "Write", + "ReceiverType": "*CheckedEntry", + "OnEnter": "zapLogWriteOnEnter", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/zap" + }, + { + "ImportPath": "google.golang.org/grpc", + "Function": "DialContext", + "OnEnter": "grpcClientOnEnter", + "OnExit": "grpcClientOnExit", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/grpc" + }, + { + "ImportPath": "google.golang.org/grpc", + "Function": "NewClient", + "OnEnter": "grpcNewClientOnEnter", + "OnExit": "grpcNewClientOnExit", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/grpc" + }, + { + "ImportPath": "google.golang.org/grpc", + "Function": "NewServer", + "OnEnter": "grpcServerOnEnter", + "OnExit": "grpcServerOnExit", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/grpc" + }, + { + "ImportPath": "github.com/cloudwego/hertz/pkg/app/server", + "Function": "New", + "OnEnter": "beforeHertzServerBuild", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/hertz/server" + }, + { + "ImportPath": "github.com/cloudwego/hertz/pkg/app/client", + "Function": "NewClient", + "OnExit": "afterHertzClientBuild", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/hertz/client" + }, + { + "Version": "[1.45.0,1.57.1)", + "ImportPath": "github.com/valyala/fasthttp", + "Function": "Do", + "ReceiverType": "*HostClient", + "OnEnter": "clientFastHttpOnEnter", + "OnExit": "clientFastHttpOnExit", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/fasthttp" + }, + { + "Version": "[1.45.0,1.57.1)", + "ImportPath": "github.com/valyala/fasthttp", + "Function": "ListenAndServe", + "ReceiverType": "*Server", + "OnEnter": "listenAndServeFastHttpOnEnter", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/fasthttp" + }, + { + "ImportPath": "log", + "Function": "output", + "ReceiverType": "*Logger", + "OnEnter": "goLogWriteOnEnter", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/golog" + }, + { + "ImportPath": "log/slog", + "Function": "log", + "ReceiverType": "*Logger", + "OnEnter": "goSlogWriteOnEnter", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/goslog" + }, + { + "Version": "[2.6.3,2.8.3)", + "ImportPath": "github.com/go-kratos/kratos/v2/transport/http", + "Function": "NewServer", + "OnEnter": "kratosNewHTTPServiceOnEnter", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/kratos/http" + }, + { + "Version": "[2.6.3,2.8.3)", + "ImportPath": "github.com/go-kratos/kratos/v2/transport/grpc", + "Function": "NewServer", + "OnEnter": "kratosNewGRPCServiceOnEnter", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/kratos/grpc" + }, + { + "Version": "[8.4.0,8.15.1)", + "ImportPath": "github.com/elastic/go-elasticsearch/v8", + "Function": "Perform", + "ReceiverType": "*BaseClient", + "OnEnter": "beforeElasticSearchPerform", + "OnExit": "afterElasticSearchPerform", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/elasticsearch" + }, + { + "Version": "[2.43.0,2.52.6)", + "ImportPath": "github.com/gofiber/fiber/v2", + "Function": "handler", + "ReceiverType": "*App", + "OnEnter": "fiberHttpOnEnterv2", + "OnExit": "fiberHttpOnExitv2", + "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/fiberv2" + } ] \ No newline at end of file diff --git a/pkg/inst-api/utils/scope.go b/pkg/inst-api/utils/scope.go index 9a0db239..1a3ae77e 100644 --- a/pkg/inst-api/utils/scope.go +++ b/pkg/inst-api/utils/scope.go @@ -31,3 +31,4 @@ const KRATOS_GRPC_INTERNAL_SCOPE_NAME = "pkg/rules/kratos/grpc/kratos_internal_s const KRATOS_HTTP_INTERNAL_SCOPE_NAME = "pkg/rules/kratos/http/kratos_internal_setup.go" const MONGO_SCOPE_NAME = "pkg/rules/mongo/client_setup.go" const REDIGO_SCOPE_NAME = "pkg/rules/redigo/redigo_client_setup.go" +const ELASTICSEARCH_SCOPE_NAME = "pkg/rules/elasticsearch/es_client_setup.go" diff --git a/pkg/inst-api/version/version.go b/pkg/inst-api/version/version.go index da811f0a..fad2d72e 100644 --- a/pkg/inst-api/version/version.go +++ b/pkg/inst-api/version/version.go @@ -15,4 +15,4 @@ package version // Tag specifies the current release tag. It needs to be manually updated. -const Tag = "v0.3.0" +const Tag = "v0.4.0" diff --git a/pkg/rules/elasticsearch/es_client_setup.go b/pkg/rules/elasticsearch/es_client_setup.go new file mode 100644 index 00000000..8a803773 --- /dev/null +++ b/pkg/rules/elasticsearch/es_client_setup.go @@ -0,0 +1,78 @@ +// Copyright (c) 2024 Alibaba Group Holding Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package elasticsearch + +import ( + "context" + "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/api" + "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/inst-api/instrumenter" + "github.com/elastic/elastic-transport-go/v8/elastictransport" + elasticsearch "github.com/elastic/go-elasticsearch/v8" + "net/http" + "strings" +) + +var esInstrumenter = BuildElasticSearchInstrumenter() + +var esEnabler = instrumenter.NewDefaultInstrumentEnabler() + +func beforeElasticSearchPerform(call api.CallContext, client *elasticsearch.BaseClient, request *http.Request) { + if !esEnabler.Enable() { + return + } + var addresses []string + for _, u := range client.Transport.(*elastictransport.Client).URLs() { + addresses = append(addresses, u.String()) + } + op, params := getEsOpAndParams(request) + er := &esRequest{ + request: request, + address: strings.Join(addresses, ","), + op: op, + params: params, + } + newCtx := esInstrumenter.Start(request.Context(), er) + call.SetKeyData("ctx", newCtx) + call.SetKeyData("request", er) +} + +func afterElasticSearchPerform(call api.CallContext, response *http.Response, err error) { + if !esEnabler.Enable() { + return + } + newCtx := call.GetKeyData("ctx").(context.Context) + er := call.GetKeyData("request").(*esRequest) + esInstrumenter.End(newCtx, er, response, err) +} + +func getEsOpAndParams(req *http.Request) (string, []any) { + if req == nil || req.URL == nil { + return "UNKNOWN", nil + } + path := req.URL.Path + paths := strings.Split(path, "/") + if len(paths) <= 1 { + return "UNKNOWN", nil + } + if len(paths) == 2 { + return strings.ToLower(req.Method), nil + } + params := make([]any, len(paths)-2) + // path[0] should be the index name + for i := 2; i < len(paths); i++ { + params[i-2] = paths[i] + } + return paths[2], params +} diff --git a/tool/version/version.go b/pkg/rules/elasticsearch/es_data_type.go similarity index 81% rename from tool/version/version.go rename to pkg/rules/elasticsearch/es_data_type.go index da811f0a..2698ed47 100644 --- a/tool/version/version.go +++ b/pkg/rules/elasticsearch/es_data_type.go @@ -12,7 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -package version +package elasticsearch -// Tag specifies the current release tag. It needs to be manually updated. -const Tag = "v0.3.0" +import "net/http" + +type esRequest struct { + request *http.Request + address string + op string + params []any +} diff --git a/pkg/rules/elasticsearch/es_otel_instrumenter.go b/pkg/rules/elasticsearch/es_otel_instrumenter.go new file mode 100644 index 00000000..2f82fc05 --- /dev/null +++ b/pkg/rules/elasticsearch/es_otel_instrumenter.go @@ -0,0 +1,58 @@ +// Copyright (c) 2024 Alibaba Group Holding Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package elasticsearch + +import ( + "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/inst-api-semconv/instrumenter/db" + "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/inst-api/instrumenter" + "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/inst-api/utils" + "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/inst-api/version" + "go.opentelemetry.io/otel/sdk/instrumentation" +) + +type elasticSearchGetter struct { +} + +func (e elasticSearchGetter) GetSystem(request *esRequest) string { + return "elasticsearch" +} + +func (e elasticSearchGetter) GetServerAddress(request *esRequest) string { + return request.address +} + +func (e elasticSearchGetter) GetStatement(request *esRequest) string { + return request.request.URL.Path +} + +func (e elasticSearchGetter) GetOperation(request *esRequest) string { + return request.op +} + +func (e elasticSearchGetter) GetParameters(request *esRequest) []any { + return request.params +} + +func BuildElasticSearchInstrumenter() instrumenter.Instrumenter[*esRequest, interface{}] { + builder := instrumenter.Builder[*esRequest, any]{} + getter := elasticSearchGetter{} + return builder.Init().SetSpanNameExtractor(&db.DBSpanNameExtractor[*esRequest]{Getter: elasticSearchGetter{}}).SetSpanKindExtractor(&instrumenter.AlwaysClientExtractor[*esRequest]{}). + SetInstrumentationScope(instrumentation.Scope{ + Name: utils.ELASTICSEARCH_SCOPE_NAME, + Version: version.Tag, + }). + AddAttributesExtractor(&db.DbClientAttrsExtractor[*esRequest, any, db.DbClientAttrsGetter[*esRequest]]{Base: db.DbClientCommonAttrsExtractor[*esRequest, any, db.DbClientAttrsGetter[*esRequest]]{Getter: getter}}). + BuildInstrumenter() +} diff --git a/pkg/rules/kratos/grpc/kratos_internal_setup.go b/pkg/rules/kratos/grpc/kratos_internal_setup.go index 716ce60b..2ad68a4d 100644 --- a/pkg/rules/kratos/grpc/kratos_internal_setup.go +++ b/pkg/rules/kratos/grpc/kratos_internal_setup.go @@ -33,7 +33,7 @@ var kratosEnabler = instrumenter.NewDefaultInstrumentEnabler() var kratosInternalInstrument = BuildKratosInternalInstrumenter() -func KratosNewGRPCServiceOnEnter(call api.CallContext, opts ...grpc.ServerOption) { +func kratosNewGRPCServiceOnEnter(call api.CallContext, opts ...grpc.ServerOption) { if os.Getenv(OTEL_INSTRUMENTATION_KRATOS_EXPERIMENTAL_SPAN_ATTRIBUTES) != "true" { return } diff --git a/pkg/rules/kratos/http/kratos_internal_setup.go b/pkg/rules/kratos/http/kratos_internal_setup.go index 4dde7041..78b5d5d0 100644 --- a/pkg/rules/kratos/http/kratos_internal_setup.go +++ b/pkg/rules/kratos/http/kratos_internal_setup.go @@ -30,7 +30,7 @@ const OTEL_INSTRUMENTATION_KRATOS_EXPERIMENTAL_SPAN_ATTRIBUTES = "OTEL_INSTRUMEN var kratosInternalInstrument = BuildKratosInternalInstrumenter() -func KratosNewHTTPServiceOnEnter(call api.CallContext, opts ...http.ServerOption) { +func kratosNewHTTPServiceOnEnter(call api.CallContext, opts ...http.ServerOption) { if os.Getenv(OTEL_INSTRUMENTATION_KRATOS_EXPERIMENTAL_SPAN_ATTRIBUTES) != "true" { return } diff --git a/pkg/rules/mongo/mongo_otel_instrumenter.go b/pkg/rules/mongo/mongo_otel_instrumenter.go index fbb9154f..8a5026de 100644 --- a/pkg/rules/mongo/mongo_otel_instrumenter.go +++ b/pkg/rules/mongo/mongo_otel_instrumenter.go @@ -42,7 +42,7 @@ func (m mongoAttrsGetter) GetOperation(request mongoRequest) string { return request.CommandName } -func (d mongoAttrsGetter) GetParameters(request mongoRequest) []any { +func (m mongoAttrsGetter) GetParameters(request mongoRequest) []any { return nil } diff --git a/test/elasticsearch/v8.4.0/go.mod b/test/elasticsearch/v8.4.0/go.mod new file mode 100644 index 00000000..c4cc2bb0 --- /dev/null +++ b/test/elasticsearch/v8.4.0/go.mod @@ -0,0 +1,26 @@ +module elasticsearch/v8.0.0 + +go 1.22 + +replace github.com/alibaba/opentelemetry-go-auto-instrumentation/test/verifier => ../../../../opentelemetry-go-auto-instrumentation/test/verifier + +replace github.com/alibaba/opentelemetry-go-auto-instrumentation => ../../../../opentelemetry-go-auto-instrumentation + +require ( + github.com/alibaba/opentelemetry-go-auto-instrumentation/test/verifier v0.0.0-00010101000000-000000000000 + github.com/elastic/go-elasticsearch/v8 v8.4.0 + go.opentelemetry.io/otel/sdk v1.31.0 +) + +require ( + github.com/elastic/elastic-transport-go/v8 v8.4.0 // indirect + github.com/go-logr/logr v1.4.2 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect + go.opentelemetry.io/otel v1.31.0 // indirect + go.opentelemetry.io/otel/metric v1.31.0 // indirect + go.opentelemetry.io/otel/sdk/metric v1.31.0 // indirect + go.opentelemetry.io/otel/trace v1.31.0 // indirect + golang.org/x/sys v0.26.0 // indirect +) diff --git a/test/elasticsearch/v8.4.0/test_es_crud.go b/test/elasticsearch/v8.4.0/test_es_crud.go new file mode 100644 index 00000000..9d64a880 --- /dev/null +++ b/test/elasticsearch/v8.4.0/test_es_crud.go @@ -0,0 +1,97 @@ +// Copyright (c) 2024 Alibaba Group Holding Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "bytes" + "encoding/json" + "github.com/alibaba/opentelemetry-go-auto-instrumentation/test/verifier" + "github.com/elastic/go-elasticsearch/v8" + "go.opentelemetry.io/otel/sdk/trace/tracetest" + "log" + "os" + "strings" +) + +var ( + client *elasticsearch.Client + url = "http://127.0.0.1:" + os.Getenv("OTEL_ES_PORT") +) + +func main() { + var err error + client, err = elasticsearch.NewClient(elasticsearch.Config{ + Addresses: []string{url}, + Password: "123456", + Username: "elastic", + }) + if err != nil { + panic(err) + } + // creating an index + _, err = client.Indices.Create("my_index") + if err != nil { + log.Printf("failed to create index %v\n", err) + } + // indexing documents + document := struct { + Name string `json:"name"` + }{ + "go-elasticsearch", + } + data, _ := json.Marshal(document) + _, err = client.Index("my_index", bytes.NewReader(data)) + if err != nil { + log.Printf("failed to index document %v\n", err) + } + // getting documents + _, err = client.Get("my_index", "id") + if err != nil { + log.Printf("failed to get documents %v\n", err) + } + // searching documents + query := `{ "query": { "match_all": {} } }` + _, err = client.Search( + client.Search.WithIndex("my_index"), + client.Search.WithBody(strings.NewReader(query)), + ) + if err != nil { + log.Printf("failed to search documents %v\n", err) + } + // updating documents + _, err = client.Update("my_index", "id", strings.NewReader(`{doc: { language: "Go" }}`)) + if err != nil { + log.Printf("failed to update document %v\n", err) + } + // deleting documents + _, err = client.Delete("my_index", "id") + if err != nil { + log.Printf("failed to delete document %v\n", err) + } + // deleting an index + _, err = client.Indices.Delete([]string{"my_index"}) + if err != nil { + log.Printf("failed to delete index %v\n", err) + } + verifier.WaitAndAssertTraces(func(stubs []tracetest.SpanStubs) { + verifier.VerifyDbAttributes(stubs[0][0], "put", "elasticsearch", "127.0.0.1", "/my_index", "put") + verifier.VerifyDbAttributes(stubs[1][0], "_doc", "elasticsearch", "127.0.0.1", "/my_index/_doc", "_doc") + verifier.VerifyDbAttributes(stubs[2][0], "_doc", "elasticsearch", "127.0.0.1", "/my_index/_doc/id", "_doc") + verifier.VerifyDbAttributes(stubs[3][0], "_search", "elasticsearch", "127.0.0.1", "/my_index/_search", "_search") + verifier.VerifyDbAttributes(stubs[4][0], "_update", "elasticsearch", "127.0.0.1", "/my_index/_update/id", "_update") + verifier.VerifyDbAttributes(stubs[5][0], "_doc", "elasticsearch", "127.0.0.1", "/my_index/_doc/id", "_doc") + verifier.VerifyDbAttributes(stubs[6][0], "delete", "elasticsearch", "127.0.0.1", "/my_index", "delete") + }, 1) +} diff --git a/test/elasticsearch/v8.5.0/go.mod b/test/elasticsearch/v8.5.0/go.mod new file mode 100644 index 00000000..04c6fc46 --- /dev/null +++ b/test/elasticsearch/v8.5.0/go.mod @@ -0,0 +1,26 @@ +module elasticsearch/v8.0.0 + +go 1.22 + +replace github.com/alibaba/opentelemetry-go-auto-instrumentation/test/verifier => ../../../../opentelemetry-go-auto-instrumentation/test/verifier + +replace github.com/alibaba/opentelemetry-go-auto-instrumentation => ../../../../opentelemetry-go-auto-instrumentation + +require ( + github.com/alibaba/opentelemetry-go-auto-instrumentation/test/verifier v0.0.0-00010101000000-000000000000 + github.com/elastic/go-elasticsearch/v8 v8.5.0 + go.opentelemetry.io/otel/sdk v1.31.0 +) + +require ( + github.com/elastic/elastic-transport-go/v8 v8.4.0 // indirect + github.com/go-logr/logr v1.4.2 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect + go.opentelemetry.io/otel v1.31.0 // indirect + go.opentelemetry.io/otel/metric v1.31.0 // indirect + go.opentelemetry.io/otel/sdk/metric v1.31.0 // indirect + go.opentelemetry.io/otel/trace v1.31.0 // indirect + golang.org/x/sys v0.26.0 // indirect +) diff --git a/test/elasticsearch/v8.5.0/test_es_typedclient.go b/test/elasticsearch/v8.5.0/test_es_typedclient.go new file mode 100644 index 00000000..e651b851 --- /dev/null +++ b/test/elasticsearch/v8.5.0/test_es_typedclient.go @@ -0,0 +1,100 @@ +// Copyright (c) 2024 Alibaba Group Holding Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "context" + "encoding/json" + "github.com/alibaba/opentelemetry-go-auto-instrumentation/test/verifier" + "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v8/typedapi/core/search" + "github.com/elastic/go-elasticsearch/v8/typedapi/core/update" + "github.com/elastic/go-elasticsearch/v8/typedapi/types" + "go.opentelemetry.io/otel/sdk/trace/tracetest" + "log" + "os" +) + +var ( + client *elasticsearch.TypedClient + url = "http://127.0.0.1:" + os.Getenv("OTEL_ES_PORT") +) + +func main() { + var err error + client, err = elasticsearch.NewTypedClient(elasticsearch.Config{ + Addresses: []string{url}, + Password: "123456", + Username: "elastic", + }) + if err != nil { + panic(err) + } + ctx := context.Background() + // creating an index + _, err = client.Indices.Create("my_index").Do(ctx) + if err != nil { + log.Printf("failed to create index %v\n", err) + } + // indexing documents + document := struct { + Name string `json:"name"` + }{ + "go-elasticsearch", + } + _, err = client.Index("my_index"). + Id("1"). + Request(document). + Do(ctx) + if err != nil { + log.Printf("failed to index document %v\n", err) + } + // getting documents + _, err = client.Get("my_index", "id").Do(ctx) + if err != nil { + log.Printf("failed to get documents %v\n", err) + } + // searching documents + _, err = client.Search().Index("my_index").Request(&search.Request{Query: &types.Query{MatchAll: &types.MatchAllQuery{}}}).Do(ctx) + if err != nil { + log.Printf("failed to search documents %v\n", err) + } + // updating documents + _, err = client.Update("my_index", "id"). + Request(&update.Request{ + Doc: json.RawMessage(`{ language: "Go" }`), + }).Do(ctx) + if err != nil { + log.Printf("failed to update document %v\n", err) + } + // deleting documents + _, err = client.Delete("my_index", "id").Do(ctx) + if err != nil { + log.Printf("failed to delete document %v\n", err) + } + // deleting an index + _, err = client.Indices.Delete("my_index").Do(ctx) + if err != nil { + log.Printf("failed to delete index %v\n", err) + } + verifier.WaitAndAssertTraces(func(stubs []tracetest.SpanStubs) { + verifier.VerifyDbAttributes(stubs[0][0], "put", "elasticsearch", "127.0.0.1", "/my_index", "put") + verifier.VerifyDbAttributes(stubs[1][0], "_doc", "elasticsearch", "127.0.0.1", "/my_index/_doc", "_doc") + verifier.VerifyDbAttributes(stubs[2][0], "_doc", "elasticsearch", "127.0.0.1", "/my_index/_doc/id", "_doc") + verifier.VerifyDbAttributes(stubs[3][0], "_search", "elasticsearch", "127.0.0.1", "/my_index/_search", "_search") + verifier.VerifyDbAttributes(stubs[4][0], "_doc", "elasticsearch", "127.0.0.1", "/my_index/_doc/id", "_doc") + verifier.VerifyDbAttributes(stubs[5][0], "delete", "elasticsearch", "127.0.0.1", "/my_index", "delete") + }, 1) +} diff --git a/test/elasticsearch_tests.go b/test/elasticsearch_tests.go new file mode 100644 index 00000000..ebf365fd --- /dev/null +++ b/test/elasticsearch_tests.go @@ -0,0 +1,95 @@ +// Copyright (c) 2024 Alibaba Group Holding Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package test + +import ( + "context" + "fmt" + "github.com/docker/go-connections/nat" + "github.com/testcontainers/testcontainers-go" + "testing" + "time" +) + +const es_v8_dependency_name = "github.com/elastic/go-elasticsearch/v8" +const es_v8_module_name = "elasticsearch" + +const defaultHTTPPort = "9200" +const defaultTCPPort = "9300" + +func init() { + TestCases = append(TestCases, + NewGeneralTestCase("es-crud-test", es_v8_module_name, "v8.4.0", "", "1.18", "", TestESCrud), + NewGeneralTestCase("es-typed-client-test", es_v8_module_name, "v8.4.0", "", "1.18", "", TestESTypedClient), + NewLatestDepthTestCase("es-crud-latestdepth-test", es_v8_dependency_name, es_v8_module_name, "v8.4.0", "v8.15.0", "1.18", "", TestESCrud), + NewMuzzleTestCase("es-muzzle", es_v8_dependency_name, es_v8_module_name, "v8.4.0", "v8.4.0", "1.18", "", []string{"go", "build", "test_es_crud.go"}), + NewMuzzleTestCase("es-muzzle", es_v8_dependency_name, es_v8_module_name, "v8.5.0", "", "1.18", "", []string{"go", "build", "test_es_typedclient.go"}), + ) +} + +func TestESCrud(t *testing.T, env ...string) { + esC, esPort := initElasticSearchContainer() + defer testcontainers.CleanupContainer(t, esC) + UseApp("elasticsearch/v8.4.0") + RunInstrument(t, "-debuglog", "go", "build", "test_es_crud.go") + env = append(env, "OTEL_ES_PORT="+esPort.Port()) + RunApp(t, "test_es_crud", env...) +} + +func TestESTypedClient(t *testing.T, env ...string) { + esC, esPort := initElasticSearchContainer() + defer testcontainers.CleanupContainer(t, esC) + UseApp("elasticsearch/v8.5.0") + RunInstrument(t, "-debuglog", "go", "build", "test_es_typedclient.go") + env = append(env, "OTEL_ES_PORT="+esPort.Port()) + RunApp(t, "test_es_typedclient", env...) +} + +func initElasticSearchContainer() (testcontainers.Container, nat.Port) { + ctx := context.Background() + elasticsearchContainer, err := runElasticSearchContainer(ctx) + if err != nil { + panic(err) + } + time.Sleep(5 * time.Second) + port, err := elasticsearchContainer.MappedPort(context.Background(), "9200") + if err != nil { + panic(err) + } + return elasticsearchContainer, port +} + +func runElasticSearchContainer(ctx context.Context) (testcontainers.Container, error) { + req := testcontainers.GenericContainerRequest{ + ContainerRequest: testcontainers.ContainerRequest{ + Image: "docker.elastic.co/elasticsearch/elasticsearch:7.17.25", + Env: map[string]string{ + "discovery.type": "single-node", + "cluster.routing.allocation.disk.threshold_enabled": "false", + }, + ExposedPorts: []string{ + defaultHTTPPort + "/tcp", + defaultTCPPort + "/tcp", + }, + }, + Started: true, + } + container, err := testcontainers.GenericContainer(ctx, req) + if err != nil { + return container, fmt.Errorf("generic container: %w", err) + } + + return container, nil +} diff --git a/test/infra.go b/test/infra.go index 92f10966..bd1ce805 100644 --- a/test/infra.go +++ b/test/infra.go @@ -154,6 +154,7 @@ func RunApp(t *testing.T, appName string, env ...string) (string, string) { } func FetchVersion(t *testing.T, dependency, version string) string { + t.Logf("dependency %s, version %s", dependency, version) output, err := exec.Command("go", "get", "-u", dependency+"@"+version).Output() if err != nil { t.Fatal(output, err)