feat 编译时插桩

This commit is contained in:
2026-01-24 11:38:33 +08:00
parent 6c124f9f3f
commit 44f89f9981
3 changed files with 26 additions and 2 deletions

3
deploy/Jenkinsfile vendored
View File

@@ -58,12 +58,13 @@ pipeline {
}
steps {
sh """
go install github.com/DataDog/orchestrion@latest
export GOPROXY=https://goproxy.cn,direct
export CGO_ENABLED=0
export GOOS=linux
export GOARCH=amd64
go build -o ${env.APP_NAME} .
orchestrion go build -o ${env.APP_NAME} .
"""
}
}

View File

@@ -23,7 +23,7 @@ type TopicQuestionAnswer struct {
func startConsumer() {
kafka.NewConsumer().Consume("qgdzs.question.answer", func(ctx context.Context, msg *sarama.ConsumerMessage) error {
log.Infof("qgdzs.question.answer: %s", string(msg.Value))
log.Infof("Kafka topic: qgdzs.question.answer: %s", string(msg.Value))
data := &TopicQuestionAnswer{}
if err := json.Unmarshal(msg.Value, &data); err != nil {
return utils.ErrorsWrap(err)

23
orchestrion.tool.go Normal file
View File

@@ -0,0 +1,23 @@
// This file was created by `orchestrion pin`, and is used to ensure the
// `go.mod` file contains the necessary entries to ensure repeatable builds when
// using `orchestrion`. It is also used to set up which integrations are enabled.
//go:build tools
//go:generate go run github.com/DataDog/orchestrion pin -generate
package tools
// Imports in this file determine which tracer integrations are enabled in
// orchestrion. New integrations can be automatically discovered by running
// `orchestrion pin` again. You can also manually add new imports here to
// enable additional integrations. When doing so, you can run `orchestrion pin`
// to make sure manually added integrations are valid (i.e, the imported package
// includes a valid `orchestrion.yml` file).
import (
// Ensures `orchestrion` is present in `go.mod` so that builds are repeatable.
// Do not remove.
_ "github.com/DataDog/orchestrion" // integration
_ "github.com/DataDog/dd-trace-go/orchestrion/all/v2" // integration
)