-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
379 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,5 +13,5 @@ | |
#### 安装 | ||
|
||
```shell | ||
go get -v -u go.dtapp.net/golog@v1.0.142 | ||
go get -v -u go.dtapp.net/golog@v1.0.143 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package golog | ||
|
||
import ( | ||
"context" | ||
"go.opentelemetry.io/otel" | ||
"go.opentelemetry.io/otel/attribute" | ||
"go.opentelemetry.io/otel/codes" | ||
"go.opentelemetry.io/otel/trace" | ||
) | ||
|
||
// SetTrace 设置OpenTelemetry链路追踪 | ||
func (ag *ApiGorm) SetTrace(trace bool) { | ||
ag.trace = trace | ||
} | ||
|
||
// TraceStartSpan 开始OpenTelemetry链路追踪状态 | ||
func (ag *ApiGorm) TraceStartSpan(ctx context.Context) context.Context { | ||
if ag.trace { | ||
tr := otel.Tracer("go.dtapp.net/golog", trace.WithInstrumentationVersion(Version)) | ||
ctx, ag.span = tr.Start(ctx, "golog.api") | ||
} | ||
return ctx | ||
} | ||
|
||
// TraceEndSpan 结束OpenTelemetry链路追踪状态 | ||
func (ag *ApiGorm) TraceEndSpan() { | ||
if ag.trace { | ||
ag.span.End() | ||
} | ||
} | ||
|
||
// TraceSetAttributes 设置OpenTelemetry链路追踪属性 | ||
func (ag *ApiGorm) TraceSetAttributes(kv ...attribute.KeyValue) { | ||
if ag.trace { | ||
ag.span.SetAttributes(kv...) | ||
} | ||
} | ||
|
||
// TraceSetStatus 设置OpenTelemetry链路追踪状态 | ||
func (ag *ApiGorm) TraceSetStatus(code codes.Code, description string) { | ||
if ag.trace { | ||
ag.span.SetStatus(code, description) | ||
} | ||
} | ||
|
||
// TraceGetTraceID 获取OpenTelemetry链路追踪TraceID | ||
func (ag *ApiGorm) TraceGetTraceID() string { | ||
if ag.trace { | ||
return ag.span.SpanContext().TraceID().String() | ||
} | ||
return "" | ||
} | ||
|
||
// TraceGetSpanID 获取OpenTelemetry链路追踪SpanID | ||
func (ag *ApiGorm) TraceGetSpanID() string { | ||
if ag.trace { | ||
return ag.span.SpanContext().SpanID().String() | ||
} | ||
return "" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package golog | ||
|
||
import ( | ||
"context" | ||
"go.opentelemetry.io/otel" | ||
"go.opentelemetry.io/otel/attribute" | ||
"go.opentelemetry.io/otel/codes" | ||
"go.opentelemetry.io/otel/trace" | ||
) | ||
|
||
// SetTrace 设置OpenTelemetry链路追踪 | ||
func (gg *GinGorm) SetTrace(trace bool) { | ||
gg.trace = trace | ||
} | ||
|
||
// TraceStartSpan 开始OpenTelemetry链路追踪状态 | ||
func (gg *GinGorm) TraceStartSpan(ctx context.Context) context.Context { | ||
if gg.trace { | ||
tr := otel.Tracer("go.dtapp.net/golog", trace.WithInstrumentationVersion(Version)) | ||
ctx, gg.span = tr.Start(ctx, "golog.gin") | ||
} | ||
return ctx | ||
} | ||
|
||
// TraceEndSpan 结束OpenTelemetry链路追踪状态 | ||
func (gg *GinGorm) TraceEndSpan() { | ||
if gg.trace { | ||
gg.span.End() | ||
} | ||
} | ||
|
||
// TraceSetAttributes 设置OpenTelemetry链路追踪属性 | ||
func (gg *GinGorm) TraceSetAttributes(kv ...attribute.KeyValue) { | ||
if gg.trace { | ||
gg.span.SetAttributes(kv...) | ||
} | ||
} | ||
|
||
// TraceSetStatus 设置OpenTelemetry链路追踪状态 | ||
func (gg *GinGorm) TraceSetStatus(code codes.Code, description string) { | ||
if gg.trace { | ||
gg.span.SetStatus(code, description) | ||
} | ||
} | ||
|
||
// TraceGetTraceID 获取OpenTelemetry链路追踪TraceID | ||
func (gg *GinGorm) TraceGetTraceID() string { | ||
if gg.trace { | ||
return gg.span.SpanContext().TraceID().String() | ||
} | ||
return "" | ||
} | ||
|
||
// TraceGetSpanID 获取OpenTelemetry链路追踪SpanID | ||
func (gg *GinGorm) TraceGetSpanID() string { | ||
if gg.trace { | ||
return gg.span.SpanContext().SpanID().String() | ||
} | ||
return "" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package golog | ||
|
||
import ( | ||
"context" | ||
"go.opentelemetry.io/otel" | ||
"go.opentelemetry.io/otel/attribute" | ||
"go.opentelemetry.io/otel/codes" | ||
"go.opentelemetry.io/otel/trace" | ||
) | ||
|
||
// SetTrace 设置OpenTelemetry链路追踪 | ||
func (hg *HertzGorm) SetTrace(trace bool) { | ||
hg.trace = trace | ||
} | ||
|
||
// TraceStartSpan 开始OpenTelemetry链路追踪状态 | ||
func (hg *HertzGorm) TraceStartSpan(ctx context.Context) context.Context { | ||
if hg.trace { | ||
tr := otel.Tracer("go.dtapp.net/golog", trace.WithInstrumentationVersion(Version)) | ||
ctx, hg.span = tr.Start(ctx, "golog.hertz") | ||
} | ||
return ctx | ||
} | ||
|
||
// TraceEndSpan 结束OpenTelemetry链路追踪状态 | ||
func (hg *HertzGorm) TraceEndSpan() { | ||
if hg.trace { | ||
hg.span.End() | ||
} | ||
} | ||
|
||
// TraceSetAttributes 设置OpenTelemetry链路追踪属性 | ||
func (hg *HertzGorm) TraceSetAttributes(kv ...attribute.KeyValue) { | ||
if hg.trace { | ||
hg.span.SetAttributes(kv...) | ||
} | ||
} | ||
|
||
// TraceSetStatus 设置OpenTelemetry链路追踪状态 | ||
func (hg *HertzGorm) TraceSetStatus(code codes.Code, description string) { | ||
if hg.trace { | ||
hg.span.SetStatus(code, description) | ||
} | ||
} | ||
|
||
// TraceGetTraceID 获取OpenTelemetry链路追踪TraceID | ||
func (hg *HertzGorm) TraceGetTraceID() string { | ||
if hg.trace { | ||
return hg.span.SpanContext().TraceID().String() | ||
} | ||
return "" | ||
} | ||
|
||
// TraceGetSpanID 获取OpenTelemetry链路追踪SpanID | ||
func (hg *HertzGorm) TraceGetSpanID() string { | ||
if hg.trace { | ||
return hg.span.SpanContext().SpanID().String() | ||
} | ||
return "" | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.