Copyright 2020 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

package dcensus

import (
	
	
	
	
	

	
	
)

type debugTraceExporter struct {
	exp trace.Exporter
	mu  sync.Mutex
	err error
}

func ( *debugTraceExporter) ( error) {
	log.Debugf(context.Background(), "trace exporter: onError called with %v", )
	.err = 
}
ExportSpan implements the trace.Exporter interface.
func ( *debugTraceExporter) ( *trace.SpanData) {
	 := context.Background()
	.mu.Lock()
	.exp.ExportSpan()
	 := .err
	.err = nil
	.mu.Unlock()
	if  != nil {
		log.Warningf(, "trace exporter: %v", )
		log.Debugf(, "trace exporter SpanData:\n%s", dumpSpanData())
	}
}

func ( *trace.SpanData) string {
	var  bytes.Buffer
	fmt.Fprintf(&, "Name: %q\n", .Name)
	dumpAttributes(&, .Attributes)
	for ,  := range .Annotations {
		fmt.Fprintf(&, "  annotation: %q\n", .Message)
		dumpAttributes(&, .Attributes)
	}
	fmt.Fprintf(&, "Status.Message: %q\n", .Status.Message)
	fmt.Fprintln(&, "link attrs:")
	for ,  := range .Links {
		dumpAttributes(&, .Attributes)
	}
	return .String()
}

func ( io.Writer,  map[string]interface{}) {
	for ,  := range  {
		fmt.Fprintf(, "  %q: %#v\n", , )
	}