{"id":13827354,"url":"https://github.com/stackimpact/stackimpact-go","last_synced_at":"2025-07-09T03:31:55.825Z","repository":{"id":38628436,"uuid":"70309414","full_name":"stackimpact/stackimpact-go","owner":"stackimpact","description":"DEPRECATED StackImpact Go Profiler - Production-Grade Performance Profiler: CPU, memory allocations, blocking calls, errors, metrics, and more","archived":false,"fork":false,"pushed_at":"2020-01-16T11:43:36.000Z","size":299,"stargazers_count":291,"open_issues_count":3,"forks_count":36,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-08-04T09:06:39.625Z","etag":null,"topics":["agent","cpu-profiling","go","golang","hot-spot-profiles","memory-leak-detection","memory-profiler","monitor-performance","monitoring","performance-analysis","performance-metrics","performance-tuning","pprof","profiler","profiling-library","tracing"],"latest_commit_sha":null,"homepage":"https://stackimpact.com","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stackimpact.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-08T06:31:11.000Z","updated_at":"2024-07-09T09:49:41.000Z","dependencies_parsed_at":"2022-09-26T17:50:29.758Z","dependency_job_id":null,"html_url":"https://github.com/stackimpact/stackimpact-go","commit_stats":null,"previous_names":[],"tags_count":54,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackimpact%2Fstackimpact-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackimpact%2Fstackimpact-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackimpact%2Fstackimpact-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackimpact%2Fstackimpact-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stackimpact","download_url":"https://codeload.github.com/stackimpact/stackimpact-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225481528,"owners_count":17481175,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent","cpu-profiling","go","golang","hot-spot-profiles","memory-leak-detection","memory-profiler","monitor-performance","monitoring","performance-analysis","performance-metrics","performance-tuning","pprof","profiler","profiling-library","tracing"],"created_at":"2024-08-04T09:01:54.503Z","updated_at":"2024-11-20T06:31:40.634Z","avatar_url":"https://github.com/stackimpact.png","language":"Go","readme":"# StackImpact Go Profiler\n\n## Overview\n\nStackImpact is a production-grade performance profiler built for both production and development environments. It gives developers continuous and historical code-level view of application performance that is essential for locating CPU, memory allocation and I/O hot spots as well as latency bottlenecks. Included runtime metrics and error monitoring complement profiles for extensive performance analysis. Learn more at [stackimpact.com](https://stackimpact.com/).\n\n![dashboard](https://stackimpact.com/img/readme/hotspots-cpu-1.5-go.png)\n\n#### Features\n\n* Continuous hot spot profiling of CPU usage, memory allocation and blocking calls.\n* Continuous latency bottleneck tracing.\n* Error and panic monitoring.\n* Health monitoring including CPU, memory, garbage collection and other runtime metrics.\n* Alerts on profile anomalies.\n* Team access.\n\nLearn more on the [features](https://stackimpact.com/features/) page (with screenshots).\n\n\n#### How it works\n\nThe StackImpact profiler agent is imported into a program and used as a normal package. When the program runs, various sampling profilers are started and stopped automatically by the agent and/or programmatically using the agent methods. The agent periodically reports recorded profiles and metrics to the StackImpact Dashboard. The agent can also operate in manual mode, which should be used in development only.\n\n\n#### Documentation\n\nSee full [documentation](https://stackimpact.com/docs/) for reference.\n\n\n\n## Requirements\n\nLinux, OS X or Windows. Go version 1.5+.\n\n\n## Getting started\n\n\n#### Create StackImpact account\n\nSign up for a free trial account at [stackimpact.com](https://stackimpact.com) (also with GitHub login).\n\n\n#### Installing the agent\n\nInstall the Go agent by running\n\n```\ngo get github.com/stackimpact/stackimpact-go\n```\n\nAnd import the package `github.com/stackimpact/stackimpact-go` in your application.\n\n\n#### Configuring the agent\n\nStart the agent by specifying the agent key and application name. The agent key can be found in your account's Configuration section.\n\n```go\nagent := stackimpact.Start(stackimpact.Options{\n\tAgentKey: \"agent key here\",\n\tAppName: \"MyGoApp\",\n})\n```\n\nAll initialization options:\n\n* `AgentKey` (Required) The access key for communication with the StackImpact servers.\n* `AppName` (Required) A name to identify and group application data. Typically, a single codebase, deployable unit or executable module corresponds to one application. Sometimes also referred as a service.\n* `AppVersion` (Optional) Sets application version, which can be used to associate profiling information with the source code release.\n* `AppEnvironment` (Optional) Used to differentiate applications in different environments.\n* `HostName` (Optional) By default, host name will be the OS hostname.\n* `ProxyAddress` (Optional) Proxy server URL to use when connecting to the Dashboard servers.\n* `HTTPClient` (Optional) An `http.Client` instance to be used instead of the default client for reporting data to Dashboard servers.\n* `DisableAutoProfiling` (Optional) If set to `true`, disables the default automatic profiling and reporting. Focused or manual profiling should be used instead. Useful for environments without support for timers or background tasks.\n* `Debug` (Optional) Enables debug logging.\n* `Logger` (Optional) A `log.Logger` instance to be used instead of default `STDOUT` logger.\n\n\n#### Basic example\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\n\t\"github.com/stackimpact/stackimpact-go\"\n)\n\nfunc handler(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintf(w, \"Hello world!\")\n}\n\nfunc main() {\n\tagent := stackimpact.Start(stackimpact.Options{\n\t\tAgentKey: \"agent key here\",\n\t\tAppName: \"Basic Go Server\",\n\t\tAppVersion: \"1.0.0\",\n\t\tAppEnvironment: \"production\",\n\t})\n\n\thttp.HandleFunc(agent.ProfileHandlerFunc(\"/\", handler)) \n\thttp.ListenAndServe(\":8080\", nil)\n}\n```\n\n\n#### Focused profiling\n\nFocused profiling is suitable for repeating code, such as request or event handlers. By default, the agent starts and stops profiling automatically. In order to make sure the agent profiles the most relevant execution intervals, the following methods can be used. In addition to more precise profiling, timing information will also be reported for the profiled spans.\n\n```go\n// Use this method to instruct the agent to start and stop \n// profiling. It does not guarantee that any profiler will be \n// started. The decision is made by the agent based on the \n// overhead constraints. The method returns Span object, on \n// which the Stop() method should be called. \nspan := agent.Profile();\ndefer span.Stop();\n```\n\n```go\n// This method is similar to the Profile() method. It additionally\n// allows to specify a span name to group span timing measurements.\nspan := agent.ProfileWithName(name);\ndefer span.Stop();\n```\n\n```go\n// A helper function to profile HTTP handler execution by wrapping \n// http.Handle method parameters.\n// Usage example:\n//   http.Handle(agent.ProfileHandler(\"/some-path\", someHandler))\npattern, wrappedHandler := agent.ProfileHandler(pattern, handler)\n```\n\n```go\n// A helper function to profile HTTP handler function execution \n// by wrapping http.HandleFunc method parameters.\n// Usage example:\n//   http.HandleFunc(agent.ProfileHandlerFunc(\"/some-path\", someHandlerFunc))\npattern, wrappedHandlerFunc := agent.ProfileHandlerFunc(pattern, handlerFunc)\n```\n\n\n#### Error reporting\n\nTo monitor exceptions and panics with stack traces, the error recording API can be used.\n\nRecording handled errors:\n\n```go\n// Aggregates and reports errors with regular intervals.\nagent.RecordError(someError)\n```\n\nRecording panics without recovering:\n\n```go\n// Aggregates and reports panics with regular intervals.\ndefer agent.RecordPanic()\n```\n\nRecording and recovering from panics:\n\n```go\n// Aggregates and reports panics with regular intervals. This function also\n// recovers from panics.\ndefer agent.RecordAndRecoverPanic()\n```\n\n\n#### Manual profiling\n\n*Manual profiling should not be used in production!*\n\nBy default, the agent starts and stops profiling automatically. Manual profiling allows to start and stop profilers directly. It is suitable for profiling short-lived programs and should not be used for long-running production applications. Automatic profiling should be disabled with `DisableAutoProfiling: true`.\n\n```go\n// Start CPU profiler.\nagent.StartCPUProfiler();\n```\n\n```go\n// Stop CPU profiler and report the recorded profile to the Dashboard.\n// Automatic profiling should be disabled.\nagent.StopCPUProfiler();\n```\n\n```go\n// Start blocking call profiler.\nagent.StartBlockProfiler();\n```\n\n```go\n// Stop blocking call profiler and report the recorded profile to the Dashboard.\nagent.StopBlockProfiler();\n```\n\n```go\n// Report current allocation profile to the Dashboard.\nagent.ReportAllocationProfile();\n```\n\n\n#### Analyzing performance data in the Dashboard\n\nOnce your application is restarted, you can start observing continuously recorded CPU, memory, I/O, and other hot spot profiles, execution bottlenecks as well as process metrics in the [Dashboard](https://dashboard.stackimpact.com/).\n\n\n#### Troubleshooting\n\nTo enable debug logging, add `Debug: true` to startup options. If the debug log doesn't give you any hints on how to fix a problem, please report it to our support team in your account's Support section.\n\n\n## Overhead\n\nThe agent overhead is measured to be less than 1% for applications under high load.\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackimpact%2Fstackimpact-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstackimpact%2Fstackimpact-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackimpact%2Fstackimpact-go/lists"}