monitoring

package
v0.0.0-...-22e38cd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Example

nolint:govet

package main

import (
	"context"
	"os"

	"github.com/takuoki/golib/monitoring"
)

// nolint:govet
func main() {

	ctx := context.Background()
	ctx = monitoring.Record(ctx, "main start")
	defer func() {
		ctx = monitoring.Record(ctx, "main end")
		monitoring.Output(ctx, os.Stdout, nil)
	}()

	foo(ctx)

	
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Output

func Output(ctx context.Context, w io.Writer, formatFunc OutputFormatFunc)

Output outputs a record of memory usage. If `formatFunc` == nil, the output will be in the default format.

func OutputFile

func OutputFile(ctx context.Context, dirPath string, formatFunc OutputFormatFunc) error

OutputFile outputs a memory usage record to a file. The file is output to the specified directory with the file name `YYYYMMDDTHHmmss.md`. If `formatFunc` == nil, the output will be in the default format.

func Record

func Record(ctx context.Context, name string) context.Context

Record records the memory usage at the time of the call.

Types

type OutputFormatFunc

type OutputFormatFunc func(w io.Writer, names []string, memStats []runtime.MemStats)

OutputFormatFunc is a function that specifies the output format. The arguments `names` and` memStats` have the same number of elements.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL