-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(BRIDGE-218): observability support & metrics; reviewed remaining…
… sentry events
- Loading branch information
1 parent
d23b4be
commit 173859b
Showing
22 changed files
with
204 additions
and
17 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
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
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
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,22 @@ | ||
package observability | ||
|
||
import "context" | ||
|
||
type observabilitySenderKeyType struct{} | ||
|
||
var observabilitySenderKeyVal observabilitySenderKeyType | ||
|
||
func NewContextWithObservabilitySender(ctx context.Context, sender Sender) context.Context { | ||
return context.WithValue(ctx, observabilitySenderKeyVal, sender) | ||
} | ||
|
||
func getObservabilitySenderFromContext(ctx context.Context) (Sender, bool) { | ||
v := ctx.Value(observabilitySenderKeyVal) | ||
if v == nil { | ||
return nil, false | ||
} | ||
|
||
sender, ok := v.(Sender) | ||
|
||
return sender, ok | ||
} |
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,73 @@ | ||
package metrics | ||
|
||
import "time" | ||
|
||
const schemaName = "bridge_gluon_errors_total" | ||
const schemaVersion = 1 | ||
|
||
func generateGluonErrorMetric(errorType string) map[string]interface{} { | ||
return map[string]interface{}{ | ||
"Name": schemaName, | ||
"Version": schemaVersion, | ||
"Timestamp": time.Now().Unix(), | ||
"Data": map[string]interface{}{ | ||
"Value": 1, | ||
"Labels": map[string]string{ | ||
"errorType": errorType, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func GenerateFailedParseIMAPCommandMetric() map[string]interface{} { | ||
return generateGluonErrorMetric("failedParseIMAPCommand") | ||
} | ||
|
||
func GenerateFailedToCreateMailbox() map[string]interface{} { | ||
return generateGluonErrorMetric("failedCreateMailbox") | ||
} | ||
|
||
func GenerateFailedToDeleteMailboxMetric() map[string]interface{} { | ||
return generateGluonErrorMetric("failedDeleteMailbox") | ||
} | ||
|
||
func GenerateFailedToCopyMessagesMetric() map[string]interface{} { | ||
return generateGluonErrorMetric("failedCopyMessages") | ||
} | ||
|
||
func GenerateFailedToMoveMessagesFromMailboxMetric() map[string]interface{} { | ||
return generateGluonErrorMetric("failedMoveMessagesFromMailbox") | ||
} | ||
|
||
func GenerateFailedToRemoveDeletedMessagesMetric() map[string]interface{} { | ||
return generateGluonErrorMetric("failedRemoveDeletedMessages") | ||
} | ||
|
||
func GenerateFailedToCommitDatabaseTransactionMetric() map[string]interface{} { | ||
return generateGluonErrorMetric("failedCommitDatabaseTransaction") | ||
} | ||
|
||
func GenerateAppendToDraftsMustNotReturnExistingRemoteID() map[string]interface{} { | ||
return generateGluonErrorMetric("appendToDraftsReturnedExistingRemoteID") | ||
} | ||
|
||
func GenerateDatabaseMigrationFailed() map[string]interface{} { | ||
return generateGluonErrorMetric("databaseMigrationFailed") | ||
} | ||
|
||
func GenerateAllMetrics() []map[string]interface{} { | ||
var metrics []map[string]interface{} | ||
metrics = append(metrics, | ||
GenerateFailedParseIMAPCommandMetric(), | ||
GenerateFailedToCreateMailbox(), | ||
GenerateFailedToDeleteMailboxMetric(), | ||
GenerateFailedToCopyMessagesMetric(), | ||
GenerateFailedToMoveMessagesFromMailboxMetric(), | ||
GenerateFailedToRemoveDeletedMessagesMetric(), | ||
GenerateFailedToCommitDatabaseTransactionMetric(), | ||
GenerateAppendToDraftsMustNotReturnExistingRemoteID(), | ||
GenerateDatabaseMigrationFailed(), | ||
) | ||
|
||
return metrics | ||
} |
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,16 @@ | ||
package observability | ||
|
||
var imapErrorMetricType int | ||
var messageErrorMetricType int | ||
var otherErrorMetricType int | ||
|
||
type Sender interface { | ||
AddMetrics(metrics ...map[string]interface{}) | ||
AddDistinctMetrics(errType interface{}, metrics ...map[string]interface{}) | ||
} | ||
|
||
func SetupMetricTypes(imapErrorType, messageErrorType, otherErrorType int) { | ||
imapErrorMetricType = imapErrorType | ||
messageErrorMetricType = messageErrorType | ||
otherErrorMetricType = otherErrorType | ||
} |
Oops, something went wrong.