Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/bygui86/multi-profile/v2

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/bygui86/multi-profile/v2

  • v2.1.0
  • Source
  • Go
  • Socket score

Version published
Created
Source

multi-profile

PkgGoDev GoVersion License

BuildStatus LatestRelease

LatestTag LastCommit Issues PullRequests

Multi-profiling support package for Go.

This project was inspired by pkg/profile but there is a fundamental difference: multi-profile offers the possibility to start multiple profiling at the same time.

Installation

go get github.com/bygui86/multi-profile

Usage

Enabling profiling in your application is as simple as one line at the top of your main function.

For example:

package main

import "github.com/bygui86/multi-profile/v2"

func main() {
    defer profile.CPUProfile(&profile.Config{}).Start().Stop()
    
    // ...
}

Using profile specific method, you can create the kind of profiling you want giving a Config as input.

package main

import "github.com/bygui86/multi-profile/v2"

func main() {
    defer profile.CPUProfile(&profile.Config{}).Start().Stop()
    defer profile.MemProfile(&profile.Config{}).Start().Stop()
    defer profile.GoroutineProfile(&profile.Config{}).Start().Stop()

    // ...
}

(i)️ INFO see examples folder for all available profiles and samples.

/!\ WARN if not using EnableInterruptHook option (see below) ALWAYS remember to defer Stop() function, otherwise the profile won't stop and flush to file properly.

Options

(i)️️ INFO see examples for all usage samples.

Path

You can customize the path in which a profile file is going to be written.

Use field Path and UseTempPath in the Config.

Interruption hook

You can enable an interruption hook that runs a new goroutine waiting for interruption signals (syscall.SIGTERM, syscall.SIGINT and os.Interrupt). If one of those signals arrives, the profiling packages stop the Profile and flushes results to file. Enabling this option, you can avoid deferring Stop() function in the main.

Use EnableInterruptHook field in the Config.

Quiet mode

You can suppress all logs.

Use field Quiet in the Config.

Closer function

You can call a function right after stopping the profiling.

Use CloserHook field in the Config.

Panic in case of profile failure

Per default the profile won't cause a panic in case of failure, it will simply log the error. In case you want to panic the whole application just set PanicIfFail to true in the Config.

Contributing

I welcome pull requests, bug fixes and issue reports.

To propose an extensive change, please discuss it first by opening an issue.

Thanks

FAQs

Package last updated on 14 Oct 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc