feat(BRIDGE-218): observability adapter; gluon observability metrics and tests;

This commit is contained in:
Atanas Janeshliev
2024-10-08 13:13:07 +00:00
parent 3710dff0cd
commit 040d887aae
13 changed files with 281 additions and 26 deletions

View File

@ -0,0 +1,58 @@
// Copyright (c) 2024 Proton AG
//
// This file is part of Proton Mail Bridge.
//
// Proton Mail Bridge is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Proton Mail Bridge is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Proton Mail Bridge. If not, see <https://www.gnu.org/licenses/>.
package observability
import (
"fmt"
"testing"
"time"
"github.com/stretchr/testify/require"
)
func Test_AdapterCustomMetrics(t *testing.T) {
customMetric := map[string]interface{}{
"Name": "name",
"Version": 1,
"Timestamp": time.Now().Unix(),
"Data": map[string]interface{}{
"Value": 1,
"Labels": map[string]string{
"error": "customError",
},
},
}
ok, metric := VerifyAndParseGenericMetrics(customMetric)
require.True(t, ok)
require.Equal(t, metric.Name, customMetric["Name"])
require.Equal(t, metric.Timestamp, customMetric["Timestamp"])
require.Equal(t, metric.Version, customMetric["Version"])
require.Equal(t, metric.Data, customMetric["Data"])
}
func Test_AdapterGluonMetrics(t *testing.T) {
metrics := GenerateAllGluonMetrics()
for _, metric := range metrics {
ok, m := VerifyAndParseGenericMetrics(metric)
fmt.Println(m)
require.True(t, ok)
}
}