Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
Example ¶
nolint: lll
package main import ( "context" "encoding/json" "fmt" "time" "gitoa.ru/go-4devs/log/otel" "go.opentelemetry.io/otel/api/trace/tracetest" ) func main() { start, _ := time.Parse(time.RFC3339, "2020-09-20T12:49:52+03:00") tp := tracetest.NewProvider() tracer := tp.Tracer("4devs/log") ctx, span := tracer.Start(context.Background(), "test") prov := otel.New() prov.ErrKV(ctx, "some message", "error", "some error message") prov.InfoKV(ctx, "some info message", "data info", "additional data") defer span.End() s := span.(*tracetest.Span) for _, e := range s.Events() { e.Timestamp = start j, _ := json.Marshal(e) fmt.Println(string(j)) } }
Output: {"Timestamp":"2020-09-20T12:49:52+03:00","Name":"some message","Attributes":{"SeverityNumber":{"Type":"INT64","Value":17},"SeverityText":{"Type":"STRING","Value":"ERROR"},"error":{"Type":"STRING","Value":"some error message"}}} {"Timestamp":"2020-09-20T12:49:52+03:00","Name":"some info message","Attributes":{"SeverityNumber":{"Type":"INT64","Value":9},"SeverityText":{"Type":"STRING","Value":"INFO"},"data info":{"Type":"STRING","Value":"additional data"}}}
Types ¶
Click to show internal directories.
Click to hide internal directories.