* fix(incidentio): Implement deduplication key generation for alerts * fix(incidentio): Merge metadata from config and endpoint extra labels in request body * fix(incidentio): Update comments for clarity and consistency in deduplication key generation and metadata merging * fix(incidentio): Update comments for clarity and consistency in metadata merging and deduplication key generation * fix(incidentio): Remove duplicate Metadata assignment in request body construction * refactor(incidentio): Reformat code for consistency and readability in request body construction * fix(incidentio): Remove unnecessary newline in buildRequestBody function * Initial plan * Fix incidentio tests to handle dynamic deduplication_key field Co-authored-by: NerdySoftPaw <7468547+NerdySoftPaw@users.noreply.github.com> --------- Co-authored-by: TwiN <twin@linux.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
19 lines
511 B
Go
19 lines
511 B
Go
package incidentio
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
"encoding/hex"
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/TwiN/gatus/v5/alerting/alert"
|
|
"github.com/TwiN/gatus/v5/config/endpoint"
|
|
)
|
|
|
|
// generateDeduplicationKey generates a unique deduplication_key for incident.io
|
|
func generateDeduplicationKey(ep *endpoint.Endpoint, alert *alert.Alert) string {
|
|
data := fmt.Sprintf("%s|%s|%s|%d", ep.Key(), alert.Type, alert.GetDescription(), time.Now().UnixNano())
|
|
hash := sha256.Sum256([]byte(data))
|
|
return hex.EncodeToString(hash[:])
|
|
}
|