Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

trace: reduce the number of the printing APIs #129

Closed
rakyll opened this issue Nov 17, 2017 · 0 comments
Closed

trace: reduce the number of the printing APIs #129

rakyll opened this issue Nov 17, 2017 · 0 comments

Comments

@rakyll
Copy link
Contributor

rakyll commented Nov 17, 2017

The trace package currently allows users to print in a few different ways:

func LazyPrint(ctx context.Context, str fmt.Stringer)
func LazyPrintWithAttributes(ctx context.Context, attributes []Attribute, str fmt.Stringer)
func LazyPrintf(ctx context.Context, format string, a ...interface{})
func LazyPrintfWithAttributes(ctx context.Context, attributes []Attribute, format string, a ...interface{})
func Print(ctx context.Context, str string)
func PrintWithAttributes(ctx context.Context, attributes []Attribute, str string)

Instead of giving users different combinations of these options, we should provide a printing entry type and allow user to provide their options via the new type.

type Entry struct {
	Text       fmt.Stringer
	Attributes []Attribute
}

func LazyPrint(ctx context.Context, e Entry)

Then, we can provide maybe one other option for convience:

func LazyPrintf(ctx context.Context, format string, a ...interface{})

Users who doesn't want lazy formatting can always implement their own fmt.Stringer to format it at the point LazyPrint is called.

/cc @jcd2 @bogdandrutu

@rakyll rakyll changed the title Reduce the number of the printing APIs trace: reduce the number of the printing APIs Nov 28, 2017
rakyll added a commit to rakyll/opencensus-go that referenced this issue Jan 17, 2018
Provide Annoate and Annoatef.

We don't want to the lazy behavior of the annotation
APIs exposed to the user. Don't document the lazy
behavior.

Passing nil as attributes meets the case for annotating
only with a message. We are removing all other functions
and methods and expect user to pass nil if they
don't want to annotate with attributes.

Fixes census-instrumentation#129.
rakyll added a commit to rakyll/opencensus-go that referenced this issue Jan 17, 2018
Provide Annotate and Annotatef.

We don't want to the lazy behavior of the annotation
APIs exposed to the user. Don't document the lazy
behavior.

Passing nil as attributes meets the case for annotating
only with a message. We are removing all other functions
and methods and expect user to pass nil if they
don't want to annotate with attributes.

Fixes census-instrumentation#129.
rakyll added a commit to rakyll/opencensus-go that referenced this issue Jan 17, 2018
Provide Annotate and Annotatef.

We don't want to the lazy behavior of the annotation
APIs exposed to the user. Don't document the lazy
behavior.

Passing nil as attributes meets the case for annotating
only with a message. We are removing all other functions
and methods and expect user to pass nil if they
don't want to annotate with attributes.

Fixes census-instrumentation#129.
rakyll pushed a commit that referenced this issue Jan 18, 2018
Provide Annoate and Annoatef.

We don't want to the lazy behavior of the annotation
APIs exposed to the user. Don't document the lazy
behavior.

Passing nil as attributes meets the case for annotating
only with a message. We are removing all other functions
and methods and expect user to pass nil if they
don't want to annotate with attributes.

Fixes #129.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant