@@ -37,6 +37,8 @@ type SpanOption interface {
3737type spanOptions struct {
3838 kind trace.SpanKind
3939 attributes []attribute.KeyValue
40+ links []trace.Link
41+ otelOpts []trace.SpanStartOption
4042}
4143
4244type kindOption trace.SpanKind
@@ -53,6 +55,21 @@ func (a attrOption) apply(o *spanOptions) { o.attributes = append(o.attributes,
5355// WithAttributes adds attributes to the span.
5456func WithAttributes (attrs ... attribute.KeyValue ) SpanOption { return attrOption (attrs ) }
5557
58+ type linkOption []trace.Link
59+
60+ func (l linkOption ) apply (o * spanOptions ) { o .links = append (o .links , l ... ) }
61+
62+ // WithLinks adds links to the span.
63+ func WithLinks (links ... trace.Link ) SpanOption { return linkOption (links ) }
64+
65+ type otelOption []trace.SpanStartOption
66+
67+ func (t otelOption ) apply (o * spanOptions ) { o .otelOpts = append (o .otelOpts , t ... ) }
68+
69+ // WithOTELOptions allows passing raw OpenTelemetry options directly.
70+ // This is an escape hatch for advanced features not yet wrapped by Ion.
71+ func WithOTELOptions (opts ... trace.SpanStartOption ) SpanOption { return otelOption (opts ) }
72+
5673// --- OTEL Tracer Implementation ---
5774
5875type otelTracer struct {
@@ -73,6 +90,12 @@ func (t *otelTracer) Start(ctx context.Context, spanName string, opts ...SpanOpt
7390 if len (o .attributes ) > 0 {
7491 traceOpts = append (traceOpts , trace .WithAttributes (o .attributes ... ))
7592 }
93+ if len (o .links ) > 0 {
94+ traceOpts = append (traceOpts , trace .WithLinks (o .links ... ))
95+ }
96+ if len (o .otelOpts ) > 0 {
97+ traceOpts = append (traceOpts , o .otelOpts ... )
98+ }
7699
77100 ctx , span := t .tracer .Start (ctx , spanName , traceOpts ... )
78101 return ctx , & otelSpan {span : span }
0 commit comments