44 "context"
55
66 "go.opentelemetry.io/otel"
7- "go.opentelemetry.io/otel/attribute"
87 "go.opentelemetry.io/otel/codes"
98 "go.opentelemetry.io/otel/trace"
109)
@@ -32,9 +31,11 @@ type Span interface {
3231 // RecordError records an error as an event.
3332 RecordError (err error )
3433 // SetAttributes sets attributes on the span.
35- SetAttributes (attrs ... attribute.KeyValue )
34+ // Use attribute.String(), attribute.Int64(), etc. to create Attr values.
35+ SetAttributes (attrs ... Attr )
3636 // AddEvent adds an event to the span.
37- AddEvent (name string , attrs ... attribute.KeyValue )
37+ // Use attribute.String(), attribute.Int64(), etc. to create Attr values.
38+ AddEvent (name string , attrs ... Attr )
3839}
3940
4041// SpanOption configures span creation.
@@ -44,7 +45,7 @@ type SpanOption interface {
4445
4546type spanOptions struct {
4647 kind trace.SpanKind
47- attributes []attribute. KeyValue
48+ attributes []Attr
4849 links []trace.Link
4950 otelOpts []trace.SpanStartOption
5051}
@@ -56,12 +57,13 @@ func (k kindOption) apply(o *spanOptions) { o.kind = trace.SpanKind(k) }
5657// WithSpanKind sets the span kind (client, server, etc).
5758func WithSpanKind (kind trace.SpanKind ) SpanOption { return kindOption (kind ) }
5859
59- type attrOption []attribute. KeyValue
60+ type attrOption []Attr
6061
6162func (a attrOption ) apply (o * spanOptions ) { o .attributes = append (o .attributes , a ... ) }
6263
6364// WithAttributes adds attributes to the span.
64- func WithAttributes (attrs ... attribute.KeyValue ) SpanOption { return attrOption (attrs ) }
65+ // Use attribute.String(), attribute.Int64(), etc. to create Attr values.
66+ func WithAttributes (attrs ... Attr ) SpanOption { return attrOption (attrs ) }
6567
6668type linkOption []trace.Link
6769
@@ -113,11 +115,11 @@ type otelSpan struct {
113115 span trace.Span
114116}
115117
116- func (s * otelSpan ) End () { s .span .End () }
117- func (s * otelSpan ) SetStatus (code codes.Code , desc string ) { s .span .SetStatus (code , desc ) }
118- func (s * otelSpan ) RecordError (err error ) { s .span .RecordError (err ) }
119- func (s * otelSpan ) SetAttributes (attrs ... attribute. KeyValue ) { s .span .SetAttributes (attrs ... ) }
120- func (s * otelSpan ) AddEvent (name string , attrs ... attribute. KeyValue ) {
118+ func (s * otelSpan ) End () { s .span .End () }
119+ func (s * otelSpan ) SetStatus (code codes.Code , desc string ) { s .span .SetStatus (code , desc ) }
120+ func (s * otelSpan ) RecordError (err error ) { s .span .RecordError (err ) }
121+ func (s * otelSpan ) SetAttributes (attrs ... Attr ) { s .span .SetAttributes (attrs ... ) }
122+ func (s * otelSpan ) AddEvent (name string , attrs ... Attr ) {
121123 s .span .AddEvent (name , trace .WithAttributes (attrs ... ))
122124}
123125
@@ -131,8 +133,8 @@ func (noopTracer) Start(ctx context.Context, _ string, _ ...SpanOption) (context
131133
132134type noopSpan struct {}
133135
134- func (noopSpan ) End () {}
135- func (noopSpan ) SetStatus (codes.Code , string ) {}
136- func (noopSpan ) RecordError (error ) {}
137- func (noopSpan ) SetAttributes (... attribute. KeyValue ) {}
138- func (noopSpan ) AddEvent (string , ... attribute. KeyValue ) {}
136+ func (noopSpan ) End () {}
137+ func (noopSpan ) SetStatus (codes.Code , string ) {}
138+ func (noopSpan ) RecordError (error ) {}
139+ func (noopSpan ) SetAttributes (... Attr ) {}
140+ func (noopSpan ) AddEvent (string , ... Attr ) {}
0 commit comments