This commit is contained in:
@@ -38,9 +38,11 @@ func initMetrics(ctx context.Context, name string) (context.Context, func() erro
|
||||
goversion := ""
|
||||
pkg := ""
|
||||
host := ""
|
||||
version := "0.0.1"
|
||||
if info, ok := debug.ReadBuildInfo(); ok {
|
||||
goversion = info.GoVersion
|
||||
pkg = info.Path
|
||||
version = info.Main.Version
|
||||
}
|
||||
if h, err := os.Hostname(); err == nil {
|
||||
host = h
|
||||
@@ -69,7 +71,7 @@ func initMetrics(ctx context.Context, name string) (context.Context, func() erro
|
||||
)
|
||||
|
||||
meter := provider.Meter(name,
|
||||
api.WithInstrumentationVersion("0.0.1"),
|
||||
api.WithInstrumentationVersion(version),
|
||||
api.WithInstrumentationAttributes(
|
||||
attribute.String("app", name),
|
||||
attribute.String("host", host),
|
||||
|
||||
@@ -64,12 +64,11 @@ func (w wrapSpan) AddEvent(name string, options ...trace.EventOption) {
|
||||
cfg := trace.NewEventConfig(options...)
|
||||
|
||||
attrs := cfg.Attributes()
|
||||
args := make([]any, len(attrs)*2)
|
||||
args := make([]any, len(attrs))
|
||||
|
||||
for i, a := range attrs {
|
||||
args[2*i] = a.Key
|
||||
args[2*i+1] = a.Value
|
||||
}
|
||||
args[i] = slog.Attr{Key: string(a.Key), Value: slog.StringValue(a.Value.AsString())}
|
||||
}
|
||||
|
||||
slog.Debug(name, args...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user