forked from gojekfarm/ogi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix test; remove newrelic add dummy log metric
Signed-off-by: AbhishekKr <[email protected]>
- Loading branch information
1 parent
07395c6
commit c56e90b
Showing
12 changed files
with
79 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
module github.com/OpenChaos/ogi | ||
|
||
go 1.15 | ||
go 1.22.6 | ||
|
||
require ( | ||
bou.ke/monkey v1.0.2 | ||
github.com/gol-gol/golconv v0.0.0-20230302172921-7c155f24578e // indirect | ||
github.com/gol-gol/golenv v0.0.0-20230302172901-210791b57f21 | ||
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect | ||
github.com/newrelic/go-agent v3.8.1+incompatible | ||
github.com/oklog/ulid/v2 v2.1.0 | ||
github.com/sirupsen/logrus v1.9.3 | ||
github.com/stretchr/testify v1.7.0 | ||
golang.org/x/sys v0.24.0 // indirect | ||
github.com/stretchr/testify v1.9.0 | ||
) | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/gol-gol/golconv v0.0.0-20230302154024-425de09df6c5 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package instrumentation | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/gol-gol/golenv" | ||
|
||
logger "github.com/OpenChaos/ogi/logger" | ||
) | ||
|
||
type MetricTxn struct { | ||
Key string | ||
StartedAt time.Time | ||
} | ||
|
||
var ( | ||
ENABLE_INSTRUMENTATION = golenv.OverrideIfEnvBool("OGI_INSTRUMENTATION", false) | ||
) | ||
|
||
func init() { | ||
if !ENABLE_INSTRUMENTATION { | ||
return | ||
} | ||
} | ||
|
||
func StartTransaction(key string) MetricTxn { | ||
if !ENABLE_INSTRUMENTATION { | ||
return MetricTxn{} | ||
} | ||
return MetricTxn{ | ||
Key: key, | ||
StartedAt: time.Now(), | ||
} | ||
} | ||
|
||
func EndTransaction(txn *MetricTxn) { | ||
if !ENABLE_INSTRUMENTATION { | ||
return | ||
} | ||
logger.Infof("[METRIC] %s (%v)", txn.Key, time.Since(txn.StartedAt)) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.