Skip to content
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

Runtime instrumentation: GC "total time spent" metric #316

Closed
jmacd opened this issue Aug 29, 2020 · 7 comments
Closed

Runtime instrumentation: GC "total time spent" metric #316

jmacd opened this issue Aug 29, 2020 · 7 comments
Labels
area: instrumentation Related to an instrumentation package instrumentation: runtime

Comments

@jmacd
Copy link
Contributor

jmacd commented Aug 29, 2020

I noticed a few things that I'd like to change about the GC timing metrics emitted by instrumentation/runtime.

--

runtime.go.gc.pause_total_ns should not include a "_ns" unit suffix.
runtime.go.gc.pause_ns as well.

The main repository does not have a Unit declared for Nanoseconds. It's appropriate to report these in nanoseconds, since they are provided in nanoseconds, but I'd like to set the units being used so that downstream systems can normalize them into seconds.

--

There is a field MemStats.GCCPUFraction that is not being reported. This is a cumulative summary computed over the process lifetime, which the Metrics SIG has come to realize is rarely useful for direct monitoring. The comment reads:

    // GCCPUFraction is expressed as a number between 0 and 1,
    // where 0 means GC has consumed none of this program's CPU. A
    // program's available CPU time is defined as the integral of
    // GOMAXPROCS since the program started. That is, if
    // GOMAXPROCS is 2 and a program has been running for 10
    // seconds, its "available CPU" is 20 seconds. GCCPUFraction
    // does not include CPU time used for write barrier activity.

Therefore, the total time spent performing GC can be computed as follows:

	uptime := time.Since(processStartTime)
        gomaxprocs := float64(runtime.GOMAXPROCS(0))
	gcSeconds := memStats.GCCPUFraction * uptime.Seconds() * gomaxprocs

This gcSeconds is a number that we should be monitoring, as this can be compared directly with process.cpu.usage.

This works as long as GOMAXPROCS() does not change, and with more sophisticated logic it could approximately track changes in GOMAXPROCS() as well.

@chrisleavoy
Copy link
Contributor

I can take on adding a nannoseconds unit and updating the runtime instruments.

But GOMAXPROCS() indeed can change dynamically at runtime. It wasn't apparent to me how I could approximate a value for gcSeconds if maxprocs were to change after a long period at a different value.

@skonto
Copy link

skonto commented Jan 27, 2021

@jmacd is there a pointer for what the Metrics SIG has considered as useful for direct monitoring? I am planning to use the runtime plugin in knative/pkg but it seems to me that some metrics are not exposed like NextGC and I am wondering if we should have like a full mode in case a user wants the raw dump as it comes from runtime.memstats (beyond having just what the specs describe which seem unfinished at this point of time).
Is there a way I can help to finalize the go part?

@MrAlias MrAlias removed this from the RC1 milestone Feb 18, 2021
plantfansam referenced this issue in plantfansam/opentelemetry-go-contrib Mar 18, 2022
@jmacd
Copy link
Contributor Author

jmacd commented Aug 5, 2022

@skonto I want to address your question above, have filed #2624

@jmacd
Copy link
Contributor Author

jmacd commented Aug 5, 2022

@skonto See also golang/go#47216

@MrAlias
Copy link
Contributor

MrAlias commented Jan 18, 2024

From SIG

  • Try to add to semconv prior to adding
  • Otherwise, just have this exported from a 3rd-party package.

@AkhigbeEromo
Copy link
Contributor

Hello @jmacd
Has this issue been solved?

@MrAlias
Copy link
Contributor

MrAlias commented Oct 17, 2024

Superseded by #5655

@MrAlias MrAlias closed this as not planned Won't fix, can't repro, duplicate, stale Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: instrumentation Related to an instrumentation package instrumentation: runtime
Projects
Development

No branches or pull requests

5 participants