-
Notifications
You must be signed in to change notification settings - Fork 565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
exception.stacktrace attribute isn't included in exception events #5139
Comments
The call to RecordError probably needs to add the WithStackTrace option. |
So it's an issue with otelmux and otelmux instrumentation needs to be updated? As calling RecordError manually, attaches 2nd duplicate exception event to the span, other than the exception event automatically added by otelmux. |
I'm not seeing the otelmux instrumentation calling So no, I'm not sure this is even otelmux related. |
Thanks for looking into this. I hope I understand your question correctly - if not, please let me know. package main
import (
"github.com/gorilla/mux"
"go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/exporters/stdout/stdouttrace"
"go.opentelemetry.io/otel/sdk/resource"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
semconv "go.opentelemetry.io/otel/semconv/v1.24.0"
"net/http"
)
func main() {
exp, _ := stdouttrace.New(stdouttrace.WithPrettyPrint())
r, _ := resource.Merge(
resource.Default(),
resource.NewWithAttributes(
semconv.SchemaURL,
semconv.ServiceName("MyService"),
semconv.ServiceVersion("1.0.0"),
attribute.String("library.language", "go"),
),
)
tp := sdktrace.NewTracerProvider(
sdktrace.WithSampler(sdktrace.AlwaysSample()),
sdktrace.WithBatcher(exp),
sdktrace.WithResource(r),
)
otel.SetTracerProvider(tp)
router := mux.NewRouter()
router.HandleFunc("/Hello", hello)
router.Use(otelmux.Middleware("MyService"))
srv := &http.Server{
Handler: router,
Addr: "127.0.0.1:8000",
}
_ = srv.ListenAndServe()
}
func hello(w http.ResponseWriter, req *http.Request) {
panic("Something went wrong!")
} The created span will contain the following:
|
Thank you. The solution here would be to close the span with a #5250 should be the fix you need though. |
That makes sense - thanks for the explanation. |
Urgh my bad, I did it on the wrong instrumentation 🤦 |
Thanks for all the help - it's greatly appreciated. |
Description
When a panic occurs in a request, an
exception
event is created, but theexception.stacktrace
attribute isn't set.According to the otel spec on exceptions, the
exception.stacktrace
attribute SHOULD be set. Currently it isn't, and I haven't been able to find a way to have it included.Environment
otelmux
version: 0.48.0Steps To Reproduce
exception
event, with nostacktrace
attributeExpected behavior
I would expect the exception event to include the stacktrace. I see how this may not always be desired, so an alternative to always including it, could be a way to explicitly tell the middleware to include it.
The text was updated successfully, but these errors were encountered: