feat: add projection layer to eventstore
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package logz
|
||||
package lg
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -1,4 +1,4 @@
|
||||
package logz
|
||||
package lg
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -72,7 +72,7 @@ func initLogger(name string) func() error {
|
||||
l, err := logzio.New(
|
||||
token.Secret(),
|
||||
// logzio.SetDebug(os.Stderr),
|
||||
logzio.SetUrl(env("LOGZIO_LOG_URL", "https://listener.logz.io:8071")),
|
||||
logzio.SetUrl(env("LOGZIO_LOG_URL", "https://listener.lg.io:8071")),
|
||||
logzio.SetDrainDuration(time.Second*5),
|
||||
logzio.SetTempDirectory(env("LOGZIO_DIR", os.TempDir())),
|
||||
logzio.SetCheckDiskSpace(true),
|
||||
@@ -1,4 +1,4 @@
|
||||
package logz
|
||||
package lg
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -1,4 +1,4 @@
|
||||
package logz
|
||||
package lg
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -33,10 +33,10 @@ func Tracer(ctx context.Context) trace.Tracer {
|
||||
return otel.Tracer("")
|
||||
}
|
||||
|
||||
func Span(ctx context.Context, opts ...trace.SpanStartOption) (context.Context, trace.Span) {
|
||||
func attrs(ctx context.Context) (string, []attribute.KeyValue) {
|
||||
var attrs []attribute.KeyValue
|
||||
var name string
|
||||
if pc, file, line, ok := runtime.Caller(1); ok {
|
||||
if pc, file, line, ok := runtime.Caller(2); ok {
|
||||
if fn := runtime.FuncForPC(pc); fn != nil {
|
||||
name = fn.Name()
|
||||
}
|
||||
@@ -47,12 +47,29 @@ func Span(ctx context.Context, opts ...trace.SpanStartOption) (context.Context,
|
||||
attribute.String("name", name),
|
||||
)
|
||||
}
|
||||
return name, attrs
|
||||
}
|
||||
|
||||
func Span(ctx context.Context, opts ...trace.SpanStartOption) (context.Context, trace.Span) {
|
||||
name, attrs := attrs(ctx)
|
||||
ctx, span := Tracer(ctx).Start(ctx, name, opts...)
|
||||
span.SetAttributes(attrs...)
|
||||
|
||||
return ctx, span
|
||||
}
|
||||
|
||||
func Fork(ctx context.Context, opts ...trace.SpanStartOption) (context.Context, trace.Span) {
|
||||
name, attrs := attrs(ctx)
|
||||
childCTX, childSpan := Tracer(ctx).Start(context.Background(), name, append(opts, trace.WithLinks(trace.LinkFromContext(ctx)))...)
|
||||
childSpan.SetAttributes(attrs...)
|
||||
|
||||
_, span := Tracer(ctx).Start(ctx, name, append(opts, trace.WithLinks(trace.LinkFromContext(childCTX)))...)
|
||||
span.SetAttributes(attrs...)
|
||||
defer span.End()
|
||||
|
||||
return childCTX, childSpan
|
||||
}
|
||||
|
||||
type SampleRate string
|
||||
|
||||
const (
|
||||
Reference in New Issue
Block a user