| "golang.org/x/tools/internal/telemetry" |
| "golang.org/x/tools/internal/telemetry/export" |
| "golang.org/x/tools/internal/xcontext" |
| export.AddExporters(logExporter{}) |
| clientKey = contextKey(iota) |
| func WithClient(ctx context.Context, client Client) context.Context { |
| return context.WithValue(ctx, clientKey, client) |
| // logExporter sends the log event back to the client if there is one stored on the |
| type logExporter struct{} |
| func (logExporter) StartSpan(context.Context, *telemetry.Span) {} |
| func (logExporter) FinishSpan(context.Context, *telemetry.Span) {} |
| func (logExporter) Metric(context.Context, telemetry.MetricData) {} |
| func (logExporter) Flush() {} |
| func (logExporter) Log(ctx context.Context, event telemetry.Event) { |
| client, ok := ctx.Value(clientKey).(Client) |
| msg := &LogMessageParams{Type: Info, Message: fmt.Sprint(event)} |
| go client.LogMessage(xcontext.Detach(ctx), msg) |