From 251d2d4507126a8a4444b6536d00a3f7deb9d7e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Flc=E3=82=9B?= Date: Wed, 27 Nov 2024 19:30:08 +0800 Subject: [PATCH] fix(otelgin): remove redundant error handling from HTML (#6373) Originating from https://github.com/open-telemetry/opentelemetry-go-contrib/issues/5088#issuecomment-2499904424 --- CHANGELOG.md | 1 + .../github.com/gin-gonic/gin/otelgin/gintrace.go | 11 +---------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26f1b9bdd15..af73b4f1a18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Fix broken AWS presigned URLs when using instrumentation in `go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-sdk-go-v2/otelaws`. (#5975) - Fixed the value for configuring the OTLP exporter to use `grpc` instead of `grpc/protobuf` in `go.opentelemetry.io/contrib/config`. (#6338) - Allow marshaling types in `go.opentelemetry.io/contrib/config`. (#6347) +- Removed the redundant handling of panic from the `HTML` function in `go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin`. (#6373) diff --git a/instrumentation/github.com/gin-gonic/gin/otelgin/gintrace.go b/instrumentation/github.com/gin-gonic/gin/otelgin/gintrace.go index ef666d37cac..3a676586212 100644 --- a/instrumentation/github.com/gin-gonic/gin/otelgin/gintrace.go +++ b/instrumentation/github.com/gin-gonic/gin/otelgin/gintrace.go @@ -125,15 +125,6 @@ func HTML(c *gin.Context, code int, name string, obj interface{}) { }() opt := oteltrace.WithAttributes(attribute.String("go.template", name)) _, span := tracer.Start(savedContext, "gin.renderer.html", opt) - defer func() { - if r := recover(); r != nil { - err := fmt.Errorf("error rendering template:%s: %s", name, r) - span.RecordError(err) - span.SetStatus(codes.Error, "template failure") - span.End() - panic(r) - } - span.End() - }() + defer span.End() c.HTML(code, name, obj) }