{"id":18575380,"url":"https://github.com/keymetrics/pm2-io-apm-go","last_synced_at":"2025-09-12T00:44:48.235Z","repository":{"id":57490388,"uuid":"134246279","full_name":"keymetrics/pm2-io-apm-go","owner":"keymetrics","description":"Golang APM for PM2 Enterprise","archived":false,"fork":false,"pushed_at":"2019-04-23T12:20:40.000Z","size":249,"stargazers_count":16,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-13T23:52:02.024Z","etag":null,"topics":["alert","apm","go","golang","logs","metrics","monitoring","pm2","profiling"],"latest_commit_sha":null,"homepage":"https://pm2.io/enterprise","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/keymetrics.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":"2018-05-21T09:16:31.000Z","updated_at":"2024-05-06T00:32:06.000Z","dependencies_parsed_at":"2022-09-02T10:51:12.981Z","dependency_job_id":null,"html_url":"https://github.com/keymetrics/pm2-io-apm-go","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/keymetrics/pm2-io-apm-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keymetrics%2Fpm2-io-apm-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keymetrics%2Fpm2-io-apm-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keymetrics%2Fpm2-io-apm-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keymetrics%2Fpm2-io-apm-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/keymetrics","download_url":"https://codeload.github.com/keymetrics/pm2-io-apm-go/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keymetrics%2Fpm2-io-apm-go/sbom","scorecard":{"id":558022,"data":{"date":"2025-08-11","repo":{"name":"github.com/keymetrics/pm2-io-apm-go","commit":"63b337a500c597d1088c15c0cff28d981ecc4b6a"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.9,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/27 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":9,"reason":"1 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2020-0019 / GHSA-3xh2-74w9-5vxm"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 6 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-20T12:51:45.040Z","repository_id":57490388,"created_at":"2025-08-20T12:51:45.040Z","updated_at":"2025-08-20T12:51:45.040Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274732497,"owners_count":25339345,"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","status":"online","status_checked_at":"2025-09-11T02:00:13.660Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["alert","apm","go","golang","logs","metrics","monitoring","pm2","profiling"],"created_at":"2024-11-06T23:19:29.435Z","updated_at":"2025-09-12T00:44:48.214Z","avatar_url":"https://github.com/keymetrics.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"![](assets/gopher-pm2.png)\n\n# PM2/io APM Golang\nThis PM2 module is standalone and must include a public/private key to working properly with PM2 Plus.\n\n## Init\n\n```golang\npackage main\n\nimport (\n  \"github.com/keymetrics/pm2-io-apm-go/services\"\n  \"github.com/keymetrics/pm2-io-apm-go/structures\"\n)\n\nfunc main() {\n  // Create PM2 connector\n  pm2 := pm2io.Pm2Io{\n    Config: \u0026structures.Config{\n      PublicKey:  \"myPublic\",\n      PrivateKey: \"myPrivate\",\n      Name:       \"Golang app\",\n    },\n  }\n  \n  // Add an action who can be triggered from PM2 Plus\n  services.AddAction(\u0026structures.Action{\n    ActionName: \"Get env\",\n    Callback: func(_ map[string]interface{}) string {\n      return strings.Join(os.Environ(), \"\\n\")\n    },\n  })\n  \n  // Add a function metric who will be aggregated\n  nbd := structures.CreateFuncMetric(\"Function metric\", \"metric\", \"stable/integer\", func() float64 {\n    // For a FuncMetric, this will be called every ~1sec\n    return float64(10)\n  })\n  services.AddMetric(\u0026nbd)\n  \n  // Add a normal metric\n  nbreq := structures.CreateMetric(\"Incrementable\", \"metric\", \"increments\")\n  services.AddMetric(\u0026nbreq)\n\n  // Goroutine who increment the value each 4 seconds\n  go func() {\n    ticker := time.NewTicker(4 * time.Second)\n    for {\n      \u003c-ticker.C\n      nbreq.Value++\n\n      // Log to PM2 Plus\n      pm2io.Notifier.Log(\"Value incremented\")\n    }\n  }()\n\n  // Start the connection to PM2 Plus servers\n  pm2.Start()\n\n  // Log that we started the program (optional, just for example)\n  pm2io.Notifier.Log(\"Started\")\n  \n  // Wait infinitely (for example)\n  \u003c-time.After(time.Duration(math.MaxInt64))\n}\n```\n\n## Send error then panic\nYou can send an error to PM2 Plus before panic your program\n```golang\nname, err := os.Hostname()\nif err != nil {\n  pm2io.Panic(err)\n  // The program will crash with panic just after the message is sent\n}\n```\n\n## Use a proxy for APM requests and WebSocket\n```golang\n  pm2io.Pm2Io{\n    Config: \u0026structures.Config{\n      PublicKey:  \"myPublic\",\n      PrivateKey: \"myPrivate\",\n      Name:       \"Golang app\",\n      Proxy:      \"socks5://localhost:1080/\",\n    },\n  }\n```\n\n## Connect logrus to PM2 Plus\nIf you are using logrus, this is an example to send logs and create exceptions on PM2 Plus when you log an error\n\n```golang\npackage main\n\nimport (\n  pm2io \"github.com/keymetrics/pm2-io-apm-go\"\n  \"github.com/sirupsen/logrus\"\n)\n\n// HookLog will send logs to PM2 Plus\ntype HookLog struct {\n  Pm2 *pm2io.Pm2Io\n}\n\n// HookErr will send all errors to PM2 Plus\ntype HookErr struct {\n  Pm2 *pm2io.Pm2Io\n}\n\n// Fire event\nfunc (hook *HookLog) Fire(e *logrus.Entry) error {\n  str, err := e.String()\n  if err == nil {\n    hook.Pm2.Notifier.Log(str)\n  }\n  return err\n}\n\n// Levels for all possible logs\nfunc (*HookLog) Levels() []logrus.Level {\n  return logrus.AllLevels\n}\n\n// Fire an error and notify it as exception\nfunc (hook *HookErr) Fire(e *logrus.Entry) error {\n  if err, ok := e.Data[\"error\"].(error); ok {\n    hook.Pm2.Notifier.Error(err)\n  }\n  return nil\n}\n\n// Levels only for errors\nfunc (*HookErr) Levels() []logrus.Level {\n  return []logrus.Level{logrus.ErrorLevel}\n}\n\nfunc main() {\n  pm2 := pm2io.Pm2Io{\n    Config: \u0026structures.Config{\n      PublicKey:  \"myPublic\",\n      PrivateKey: \"myPrivate\",\n      Name:       \"Golang app\",\n    },\n  }\n\n  logrus.AddHook(\u0026HookLog{\n    Pm2: pm2,\n  })\n  logrus.AddHook(\u0026HookErr{\n    Pm2: pm2,\n  })\n}\n```\n\n## Distributed Tracing\nNB: you must pass the same `context.Context` to your subfuncs (same traceID).\nIt's very useful when you want the same trace for HTTP spans and your database spans\n\n[More informations on OpenCensus](https://opencensus.io/guides/)\n\n### HTTP\nOpenCensus will create another handler with wrapped functions. It's important to use contexts everytime\n\nFor client and server, it use B3 for communication by default\n\n[OpenCensus Documentation about ochttp](https://opencensus.io/guides/http/go/net_http/)\n```golang\nimport (\n  \"net/http\"\n\n  \"go.opencensus.io/plugin/ochttp\"\n)\n\nhandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n  context := r.Context()\n  // Not used here, but you must pass it to lower functions (espacially databases one)\n\n  log.Println(\"request\")\n  for i := 0; i \u003c 1000; i++ {\n    fmt.Fprintf(w, \"Hello\")\n  }\n})\n\nocHandler := \u0026ochttp.Handler{Handler: handler, IsPublicEndpoint: true}\nhttp.ListenAndServe(\":8089\", ocHandler)\n```\n\n### Mongo\nWith MongoDB wrapper you have to use a context, do don't create a new one and use the first one created\n\n[OpenCensus Documentation about mongowrapper](https://opencensus.io/guides/integrations/mongodb/go_driver/)\n\n### SQL\nYou can use it by registration or wrapping, here we use the first one\n\nNB: if you have some ocsql.warning, try to update your dependency\n\n[OpenCensus Documentation about ocsql](https://opencensus.io/guides/integrations/sql/go_sql/)\n\n```golang\nimport (\n  \"database/sql\"\n\n  \"contrib.go.opencensus.io/integrations/ocsql\"\n)\n\n// Create a new driver registred with OpenCensus\ndriverName, err := ocsql.Register(\"postgres\", ocsql.WithOptions(ocsql.TraceOptions{\n  AllowRoot:    true,\n  Ping:         true,\n  RowsNext:     false,\n  RowsClose:    false,\n  RowsAffected: true,\n  LastInsertID: true,\n  Query:        true,\n  QueryParams:  false, // Don't send value of $1, $2... args\n}))\nif err != nil {\n  log.Fatalf(\"Failed to register the ocsql driver: %v\", err)\n  return\n}\n\n// Then use the OpenCensus driver as usual\ndb, err := sql.Open(driverName, fmt.Sprintf(\n  \"user=%s password=%s dbname=%s host=%s port=%s sslmode=disable\",\n  cfg.User, cfg.Password, cfg.Database, cfg.Host, cfg.Port))\nif err != nil {\n  err = errors.Wrapf(err,\n    \"Couldn't open connection to postgre database\",\n  )\n  return\n}\n\n// Use QueryContext for each query\nfunc DeleteThings(ctx context.Context) error {\n  q, err := db.QueryContext(ctx, \"DROP TABLE things;\")\n\tq.Close()\n\treturn err\n}\n```\n\n### Other integrations\nWe didn't test others integrations, but everything compatible with OpenCensus/Zipkin should work without any problem\n\n## Known problems\n### x509: unknown authority\nYou must have the **Let's Encrypt Authority X3** certificate on your machine/container to connect to our backend\n\n#### Alpine based container\n```sh\napk add -U --no-cache ca-certificates\n```\n\n#### Debian based container\n```sh\napt-get install -y ca-certificates\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeymetrics%2Fpm2-io-apm-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeymetrics%2Fpm2-io-apm-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeymetrics%2Fpm2-io-apm-go/lists"}