This commit is contained in:
Filip Góra 2024-04-26 15:50:00 +02:00
parent 7a6882c09a
commit fe07b26e67
2 changed files with 8 additions and 6 deletions

View File

@ -21,7 +21,7 @@ func main() {
main.Use(tracer.NewTracer(tracer.Config{ main.Use(tracer.NewTracer(tracer.Config{
AppName: "test", AppName: "test",
JaegerUrl: "http://localhost:4318/v1/traces", JaegerUrl: "http://localhost:4318/v1/traces",
GelfUrl: "192.168.220.30:12001", GelfUrl: "192.168.220.30:12201",
Version: "1", Version: "1",
})) }))
defer tracer.ShutdownTracer() defer tracer.ShutdownTracer()

View File

@ -2,7 +2,7 @@ package gelfexporter
import ( import (
"context" "context"
"fmt" "maal/tracer/pkg/level"
"sync" "sync"
"time" "time"
@ -33,7 +33,6 @@ func New(options ...Option) (*Exporter, error) {
} }
// Exporter is an implementation of trace.SpanSyncer that writes spans to stdout.
type Exporter struct { type Exporter struct {
timestamps bool timestamps bool
gelfWriter *gelf.UDPWriter gelfWriter *gelf.UDPWriter
@ -42,7 +41,6 @@ type Exporter struct {
stopped bool stopped bool
} }
// ExportSpans writes spans in json format to stdout.
func (e *Exporter) ExportSpans(ctx context.Context, spans []trace.ReadOnlySpan) error { func (e *Exporter) ExportSpans(ctx context.Context, spans []trace.ReadOnlySpan) error {
if err := ctx.Err(); err != nil { if err := ctx.Err(); err != nil {
return err return err
@ -72,11 +70,15 @@ func (e *Exporter) ExportSpans(ctx context.Context, spans []trace.ReadOnlySpan)
} }
} }
fmt.Printf("stub: %v\n", stub) // fmt.Printf("stub: %v\n", stub)
Log(e.gelfWriter, GELFMessage{ Log(e.gelfWriter, GELFMessage{
Host: "test", Host: "test",
ShortMessage: "test", ShortMessage: stub.Name,
LongMessage: "test",
Timestamp: stub.StartTime,
Level: level.DEBUG,
ExtraFields: make(map[string]interface{}),
}) })
} }