@@ -137,7 +137,7 @@ func new` + g.Endpoint.MethodWithNamespace() + `Func(t Transport) ` + g.Endpoint
137
137
}
138
138
139
139
if transport, ok := t.(Instrumented); ok {
140
- r.instrument = transport.InstrumentationEnabled()
140
+ r.Instrument = transport.InstrumentationEnabled()
141
141
}
142
142
143
143
return r.Do(r.ctx, t)
@@ -287,7 +287,7 @@ type ` + g.Endpoint.MethodWithNamespace() + `Request struct {`)
287
287
g .w ("\n \n \t Header\t http.Header\n " )
288
288
289
289
g .w ("\n \t ctx context.Context\n " )
290
- g .w ("\n \t instrument Instrumentation\n " )
290
+ g .w ("\n \t Instrument Instrumentation\n " )
291
291
g .w ("}\n " )
292
292
}
293
293
@@ -341,6 +341,8 @@ func (f ` + g.Endpoint.MethodWithNamespace() + `) WithContext(v context.Context)
341
341
pDesc = strings .Replace (pDesc , "use `_all` or empty string" , "use _all" , - 1 )
342
342
}
343
343
344
+ pDesc = strings .Replace (pDesc , "\n " , "" , - 1 )
345
+
344
346
// Generate annotation
345
347
b .WriteString ("\n // With" + pFieldName )
346
348
if typ == "*gensource.Part" {
@@ -509,7 +511,7 @@ func (r ` + g.Endpoint.MethodWithNamespace() + `Request) Do(providedCtx context.
509
511
ctx context.Context
510
512
)` + "\n \n " )
511
513
512
- g .w (`if instrument, ok := r.instrument .(Instrumentation); ok {
514
+ g .w (`if instrument, ok := r.Instrument .(Instrumentation); ok {
513
515
ctx = instrument.Start(providedCtx, "` + g .Endpoint .Name + `")
514
516
defer instrument.Close(ctx)
515
517
}
@@ -655,27 +657,27 @@ func (r ` + g.Endpoint.MethodWithNamespace() + `Request) Do(providedCtx context.
655
657
requiredArgsValidation .WriteString (`if r.` + p + ` == nil { return nil, errors.New("` + a .Name + ` is required and cannot be nil") }` + "\n " )
656
658
pathGrow .WriteString (`len(strconv.Itoa(*r.` + p + `)) + ` )
657
659
pathContent .WriteString (` path.WriteString(strconv.Itoa(*r.` + p + `))` + "\n " )
658
- pathContent .WriteString (`if instrument, ok := r.instrument .(Instrumentation); ok {
660
+ pathContent .WriteString (`if instrument, ok := r.Instrument .(Instrumentation); ok {
659
661
instrument.RecordPathPart(ctx, "` + a .Name + `", strconv.Itoa(*r.` + p + `))
660
662
}` + "\n " )
661
663
case "string" :
662
664
pathGrow .WriteString (`len(r.` + p + `) + ` )
663
665
pathContent .WriteString (` path.WriteString(r.` + p + `)` + "\n " )
664
- pathContent .WriteString (`if instrument, ok := r.instrument .(Instrumentation); ok {
666
+ pathContent .WriteString (`if instrument, ok := r.Instrument .(Instrumentation); ok {
665
667
instrument.RecordPathPart(ctx, "` + a .Name + `", r.` + p + `)
666
668
}` + "\n " )
667
669
case "list" :
668
670
requiredArgsValidation .WriteString (`if len(r.` + p + `) == 0 { return nil, errors.New("` + a .Name + ` is required and cannot be nil or empty") }` + "\n " )
669
671
pathGrow .WriteString (`len(strings.Join(r.` + p + `, ",")) + ` )
670
672
pathContent .WriteString (` path.WriteString(strings.Join(r.` + p + `, ","))` + "\n " )
671
- pathContent .WriteString (`if instrument, ok := r.instrument .(Instrumentation); ok {
673
+ pathContent .WriteString (`if instrument, ok := r.Instrument .(Instrumentation); ok {
672
674
instrument.RecordPathPart(ctx, "` + a .Name + `", strings.Join(r.` + p + `, ","))
673
675
}` + "\n " )
674
676
case "long" :
675
677
requiredArgsValidation .WriteString (`if r.` + p + ` == nil { return nil, errors.New("` + a .Name + ` is required and cannot be nil") }` + "\n " )
676
678
pathGrow .WriteString (`len(strconv.Itoa(*r.` + p + `)) + ` )
677
679
pathContent .WriteString (` path.WriteString(strconv.Itoa(*r.` + p + `))` + "\n " )
678
- pathContent .WriteString (`if instrument, ok := r.instrument .(Instrumentation); ok {
680
+ pathContent .WriteString (`if instrument, ok := r.Instrument .(Instrumentation); ok {
679
681
instrument.RecordPathPart(ctx, "` + a .Name + `", strconv.Itoa(*r.` + p + `))
680
682
}` + "\n " )
681
683
default :
@@ -698,7 +700,7 @@ func (r ` + g.Endpoint.MethodWithNamespace() + `Request) Do(providedCtx context.
698
700
pathContent .WriteString (` if r.` + p + ` != "" {` + "\n " )
699
701
pathContent .WriteString (` path.WriteString("/")` + "\n " )
700
702
pathContent .WriteString (` path.WriteString(r.` + p + `)` + "\n " )
701
- pathContent .WriteString (`if instrument, ok := r.instrument .(Instrumentation); ok {
703
+ pathContent .WriteString (`if instrument, ok := r.Instrument .(Instrumentation); ok {
702
704
instrument.RecordPathPart(ctx, "` + a .Name + `", r.` + p + `)
703
705
}` + "\n " )
704
706
pathContent .WriteString (` }` + "\n " )
@@ -707,7 +709,7 @@ func (r ` + g.Endpoint.MethodWithNamespace() + `Request) Do(providedCtx context.
707
709
pathContent .WriteString (` if len(r.` + p + `) > 0 {` + "\n " )
708
710
pathContent .WriteString (` path.WriteString("/")` + "\n " )
709
711
pathContent .WriteString (` path.WriteString(strings.Join(r.` + p + `, ","))` + "\n " )
710
- pathContent .WriteString (`if instrument, ok := r.instrument .(Instrumentation); ok {
712
+ pathContent .WriteString (`if instrument, ok := r.Instrument .(Instrumentation); ok {
711
713
instrument.RecordPathPart(ctx, "` + a .Name + `", strings.Join(r.` + p + `, ","))
712
714
}` + "\n " )
713
715
pathContent .WriteString (` }` + "\n " )
@@ -717,7 +719,7 @@ func (r ` + g.Endpoint.MethodWithNamespace() + `Request) Do(providedCtx context.
717
719
pathContent .WriteString (` path.Grow(1 + len(value))` + "\n " )
718
720
pathContent .WriteString (` path.WriteString("/")` + "\n " )
719
721
pathContent .WriteString (` path.WriteString(value)` + "\n " )
720
- pathContent .WriteString (`if instrument, ok := r.instrument .(Instrumentation); ok {
722
+ pathContent .WriteString (`if instrument, ok := r.Instrument .(Instrumentation); ok {
721
723
instrument.RecordPathPart(ctx, "` + a .Name + `", value)
722
724
}` + "\n " )
723
725
pathContent .WriteString (` }` + "\n " )
@@ -857,7 +859,7 @@ func (r ` + g.Endpoint.MethodWithNamespace() + `Request) Do(providedCtx context.
857
859
g .w (`req, err := newRequest(method, path.String(), ` + httpBody + `)` + "\n " )
858
860
859
861
g .w (`if err != nil {
860
- if instrument, ok := r.instrument .(Instrumentation); ok {
862
+ if instrument, ok := r.Instrument .(Instrumentation); ok {
861
863
instrument.RecordError(ctx, err)
862
864
}
863
865
return nil, err
@@ -894,7 +896,7 @@ func (r ` + g.Endpoint.MethodWithNamespace() + `Request) Do(providedCtx context.
894
896
}` + "\n \n " )
895
897
896
898
g .w (`
897
- if instrument, ok := r.instrument .(Instrumentation); ok {
899
+ if instrument, ok := r.Instrument .(Instrumentation); ok {
898
900
instrument.BeforeRequest(req, "` + g .Endpoint .Name + `")
899
901
` )
900
902
if g .Endpoint .Body != nil {
@@ -906,11 +908,11 @@ func (r ` + g.Endpoint.MethodWithNamespace() + `Request) Do(providedCtx context.
906
908
g .w (`}` )
907
909
g .w (`
908
910
res, err := transport.Perform(req)
909
- if instrument, ok := r.instrument .(Instrumentation); ok {
911
+ if instrument, ok := r.Instrument .(Instrumentation); ok {
910
912
instrument.AfterRequest(req, "elasticsearch", "` + g .Endpoint .Name + `")
911
913
}
912
914
if err != nil {
913
- if instrument, ok := r.instrument .(Instrumentation); ok {
915
+ if instrument, ok := r.Instrument .(Instrumentation); ok {
914
916
instrument.RecordError(ctx, err)
915
917
}
916
918
return nil, err
0 commit comments