diff --git a/example/extension/nethttp/README.md b/example/extension/nethttp/README.md index cc4a2c6f..4a223e40 100644 --- a/example/extension/nethttp/README.md +++ b/example/extension/nethttp/README.md @@ -11,14 +11,15 @@ Replace the `Path` in `config.json` with the actual absolute path of `rules` dir "OnEnter":"httpClientEnterHook", "ReceiverType": "*Transport", "OnExit": "httpClientExitHook", -"Path": "/Users/zhanghaibin/Desktop/opentelemetry-go-auto-instrumentation/example/extension/nethttp/rules" +"Path": "/path/opentelemetry-go-auto-instrumentation/example/extension/nethttp/rules" }] ``` ## Step2: Compile the target binary with otel Use `otel` to build the binary with `config.json`: ``` -cd example/extension/netHttp +cd example/extension/nethttp +../../../otel set -rule=config.json ../../../otel -rule=config.json go build demo/net_http.go ``` Users can get the `otel` according to [documentation](../../../README.md) diff --git a/example/extension/nethttp/config.json b/example/extension/nethttp/config.json index 3dfcb54e..fb878d44 100644 --- a/example/extension/nethttp/config.json +++ b/example/extension/nethttp/config.json @@ -5,6 +5,6 @@ "OnEnter":"httpClientEnterHook", "ReceiverType": "*Transport", "OnExit": "httpClientExitHook", - "Path": "/path/to/nethttp/rules" + "Path": "/path/opentelemetry-go-auto-instrumentation/example/extension/nethttp/rules" } ] \ No newline at end of file diff --git a/example/extension/sqlinject/README.md b/example/extension/sqlinject/README.md index d7c2a0c8..cc49c510 100644 --- a/example/extension/sqlinject/README.md +++ b/example/extension/sqlinject/README.md @@ -18,7 +18,8 @@ Replace the `Path` in `config.json` with the actual absolute path of `rules` dir Use `otel` to build the binary with `config.json`: ``` cd example/extension/sqlinject -../../../otel -rule=config.json go build demo/sql_inject.go +../../../otel set -rule=config.json +../../../otel go build demo/sql_inject.go ``` Users can get the `otel` according to [documentation](../../../README.md) diff --git a/pkg/data/default.json b/pkg/data/default.json index 8ef6ef59..e0c565be 100644 --- a/pkg/data/default.json +++ b/pkg/data/default.json @@ -521,7 +521,7 @@ "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/hertz/client" }, { - "Version": "[1.45.0,1.57.1)", + "Version": "[1.45.0,1.58.1)", "ImportPath": "github.com/valyala/fasthttp", "Function": "Do", "ReceiverType": "*HostClient", @@ -530,7 +530,7 @@ "Path": "github.com/alibaba/opentelemetry-go-auto-instrumentation/pkg/rules/fasthttp" }, { - "Version": "[1.45.0,1.57.1)", + "Version": "[1.45.0,1.58.1)", "ImportPath": "github.com/valyala/fasthttp", "Function": "ListenAndServe", "ReceiverType": "*Server", diff --git a/pkg/rules/otel-sdk/otel_baggage_util.go b/pkg/rules/otel-sdk/otel_baggage_util.go index be4ce6b2..b3c2b7d7 100644 --- a/pkg/rules/otel-sdk/otel_baggage_util.go +++ b/pkg/rules/otel-sdk/otel_baggage_util.go @@ -18,6 +18,7 @@ type BaggageContainer struct { baggage interface{} } +//go:norace func (bc *BaggageContainer) TakeSnapShot() interface{} { return &BaggageContainer{bc.baggage} } diff --git a/pkg/rules/otel-sdk/trace-context/otel_trace_context.go b/pkg/rules/otel-sdk/trace-context/otel_trace_context.go index 88a5ea0c..9426df14 100644 --- a/pkg/rules/otel-sdk/trace-context/otel_trace_context.go +++ b/pkg/rules/otel-sdk/trace-context/otel_trace_context.go @@ -23,10 +23,9 @@ import ( const maxSpans = 300 type traceContext struct { - sw *spanWrapper - n int - Data map[string]interface{} - lcs trace.Span + sw *spanWrapper + n int + lcs trace.Span } type spanWrapper struct { @@ -54,6 +53,7 @@ func (tc *traceContext) add(span trace.Span) bool { return true } +//go:norace func (tc *traceContext) tail() trace.Span { if tc.n == 0 { return nil @@ -92,43 +92,37 @@ func (tc *traceContext) del(span trace.Span) { func (tc *traceContext) clear() { tc.sw = nil tc.n = 0 - tc.Data = nil SetBaggageContainerToGLS(nil) } +//go:norace func (tc *traceContext) TakeSnapShot() interface{} { // take a deep copy to avoid reading & writing the same map at the same time - var dataCopy = make(map[string]interface{}) - for key, value := range tc.Data { - dataCopy[key] = value - } if tc.n == 0 { - return &traceContext{nil, 0, dataCopy, nil} + return &traceContext{nil, 0, nil} } last := tc.tail() sw := &spanWrapper{last, nil} - return &traceContext{sw, 1, dataCopy, nil} + return &traceContext{sw, 1, nil} } func GetGLocalData(key string) interface{} { - t := getOrInitTraceContext() - r := t.Data[key] - return r + //todo set key into traceContext struct + //t := getOrInitTraceContext() + + return nil } func SetGLocalData(key string, value interface{}) { t := getOrInitTraceContext() - if t.Data == nil { - t.Data = make(map[string]interface{}) - } - t.Data[key] = value + setTraceContext(t) } func getOrInitTraceContext() *traceContext { tc := GetTraceContextFromGLS() if tc == nil { - newTc := &traceContext{nil, 0, nil, nil} + newTc := &traceContext{nil, 0, nil} setTraceContext(newTc) return newTc } else {