-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Emit metrics for MLS sent messages (#355)
* feat: emit metrics for mls sent messages * Fix lint errors 👮
- Loading branch information
Steven Normore
authored
Feb 21, 2024
1 parent
10e6617
commit fad7a17
Showing
4 changed files
with
66 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package metrics | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/prometheus/client_golang/prometheus" | ||
mlsstore "github.com/xmtp/xmtp-node-go/pkg/mls/store" | ||
"go.uber.org/zap" | ||
) | ||
|
||
var mlsSentGroupMessageSize = prometheus.NewHistogramVec( | ||
prometheus.HistogramOpts{ | ||
Name: "mls_sent_group_message_size", | ||
Help: "Size of a sent group message in bytes", | ||
Buckets: []float64{100, 1000, 10000, 100000}, | ||
}, | ||
appClientVersionTagKeys, | ||
) | ||
|
||
var mlsSentGroupMessageCount = prometheus.NewCounterVec( | ||
prometheus.CounterOpts{ | ||
Name: "mls_sent_group_messages", | ||
Help: "Count of sent group messages", | ||
}, | ||
appClientVersionTagKeys, | ||
) | ||
|
||
func EmitMLSSentGroupMessage(ctx context.Context, log *zap.Logger, msg *mlsstore.GroupMessage) { | ||
labels := contextLabels(ctx) | ||
mlsSentGroupMessageSize.With(labels).Observe(float64(len(msg.Data))) | ||
mlsSentGroupMessageCount.With(labels).Inc() | ||
} | ||
|
||
var mlsSentWelcomeMessageSize = prometheus.NewHistogramVec( | ||
prometheus.HistogramOpts{ | ||
Name: "mls_sent_welcome_message_size", | ||
Help: "Size of a sent welcome message in bytes", | ||
Buckets: []float64{100, 1000, 10000, 100000}, | ||
}, | ||
appClientVersionTagKeys, | ||
) | ||
|
||
var mlsSentWelcomeMessageCount = prometheus.NewCounterVec( | ||
prometheus.CounterOpts{ | ||
Name: "mls_sent_welcome_messages", | ||
Help: "Count of sent welcome messages", | ||
}, | ||
appClientVersionTagKeys, | ||
) | ||
|
||
func EmitMLSSentWelcomeMessage(ctx context.Context, log *zap.Logger, msg *mlsstore.WelcomeMessage) { | ||
labels := contextLabels(ctx) | ||
mlsSentWelcomeMessageSize.With(labels).Observe(float64(len(msg.Data))) | ||
mlsSentWelcomeMessageCount.With(labels).Inc() | ||
} |
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