opencensus-go icon indicating copy to clipboard operation
opencensus-go copied to clipboard

zpages: add option for enabling / disabling zpages at startup time

Open toffaletti opened this issue 6 years ago • 4 comments

It is a bit surprising that just importing zpages package (even if you don't register a handler) causes the infinite memory growth described in #597 even if DefaultSampler is NeverSample because of

func init() {
	internal.LocalSpanStoreEnabled = true
}

and

	if !internal.LocalSpanStoreEnabled && !span.spanContext.IsSampled() {
		return span
	}

This means enabling / disabling has to be done with a build tag right now, but a runtime command line flag would be best.

toffaletti avatar Jun 01 '18 20:06 toffaletti

Agree this would be better enabled at runtime.

semistrict avatar Jun 01 '18 21:06 semistrict

Thank you for filing this @toffaletti and thanks @ramonza for working on it!

@ramonza do you think we should remove that init invocation that enables zpages on the zpages.Handler variable? What else could we do here? Thank you.

odeke-em avatar Aug 20 '18 07:08 odeke-em

FYI in Java ZPages needs to be explicitly initialized in application code: https://github.com/census-instrumentation/opencensus-java/blob/9d533927c764069641ed56dcdcd0a83d05a5a14a/examples/src/main/java/io/opencensus/examples/zpages/ZPagesTester.java#L105

songy23 avatar Aug 20 '18 16:08 songy23

I think we can go ahead now and remove the Handler var that causes eager init.

semistrict avatar Aug 21 '18 00:08 semistrict