Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

trace: add support for stacktraces #912

Closed
odeke-em opened this issue Sep 13, 2018 · 2 comments
Closed

trace: add support for stacktraces #912

odeke-em opened this issue Sep 13, 2018 · 2 comments

Comments

@odeke-em
Copy link
Member

I was just going through useful signals to help distinguish a trace, I noticed in the OpenCensus Proto specs that we have a definition for StackTrace
https://github.com/census-instrumentation/opencensus-proto/blob/d3b7200dbd14743faa22c6642291d76030833cbd/src/opencensus/proto/trace/v1/trace.proto#L300-L350
screen shot 2018-09-12 at 9 40 18 pm

Perhaps we should support for stacktraces as fields of a span and provide helpers.

Options available

package main

import (
	"fmt"
	"runtime"
)

func main() {
	e := func() {
		pc := make([]uintptr, 10)
		n := runtime.Callers(0, pc)
		if n == 0 {
			return
		}
		pc = pc[:n]
		frames := runtime.CallersFrames(pc)

		for {
			frame, more := frames.Next()
			fmt.Printf("- more:%v | %s\n%#v\n", more, frame.Function, frame)
			if !more {
				break
			}
		}
	}

	d := func() { e() }
	c := func() { d() }
	b := func() { c() }
	a := func() { b() }
	a()
}
  • Panic/Byteslice translators
    In the case of panics. if users invoke recover() or they can invoke
    runtime.Stack or runtime/debug.Stack and from that we can provide a translator that basically translator an error, string, byte slice into *StackFrames e.g. in package trace
func ParseStackFrames(source interface{}) (*StackFrames, error) 

where StackFrames is a translation of the proto definition

Exporter support

Stackdriver Trace supports exporting Stacktraces https://godoc.org/google.golang.org/genproto/googleapis/devtools/cloudtrace/v2#StackTrace
and I think other APM providers would be interested in following too.

@odeke-em odeke-em changed the title trace: allow setting of stacktraces trace: add support for stacktraces Sep 13, 2018
@semistrict
Copy link
Contributor

I think this needs to be specified in OpenCensus specs first.

@rakyll
Copy link
Contributor

rakyll commented Sep 18, 2018

We deprecated stacktrace support from OpenCensus. AFAIK, they ended up being in the proto in the first place to comply with some legacy stuff we are not interested in supporting anymore. Please open an issue at the specs repo, https://github.com/census-instrumentation/opencensus-proto, if we need to reconsider them.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants