Skip to content

Commit

Permalink
add trace_id to metering events
Browse files Browse the repository at this point in the history
  • Loading branch information
fschoell committed Aug 7, 2023
1 parent e1df53e commit cdbd987
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 27 deletions.
5 changes: 5 additions & 0 deletions metering.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Event struct {
UserID string `json:"user_id"`
ApiKeyID string `json:"api_key_id"`
IpAddress string `json:"ip_address"`
TraceId string `json:"trace_id"`

Timestamp time.Time `json:"timestamp"`
}
Expand All @@ -33,6 +34,9 @@ func (ev Event) MarshalLogObject(enc zapcore.ObjectEncoder) error {
if ev.IpAddress != "" {
enc.AddString("ip_address", ev.IpAddress)
}
if ev.TraceId != "" {
enc.AddString("trace_id", ev.TraceId)
}

enc.AddString("endpoint", ev.Endpoint)
enc.AddTime("timestamp", ev.Timestamp)
Expand All @@ -52,6 +56,7 @@ func (ev Event) ToProto(network string) *pbmetering.Event {
pbev.UserId = ev.UserID
pbev.ApiKeyId = ev.ApiKeyID
pbev.IpAddress = ev.IpAddress
pbev.TraceId = ev.TraceId

pbev.Metrics = []*pbmetering.Metric{}
for k, v := range ev.Metrics {
Expand Down
4 changes: 2 additions & 2 deletions pb/last_generate.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
generate.sh - Fri 28 Jul 2023 09:19:28 EDT - julien
streamingfast/proto revision: cd783a0fb6717a2a1aa98db6b4cd4a8cf3568a3f
generate.sh - Mon Aug 7 16:11:09 CEST 2023 - fred
streamingfast/proto revision: e1df53e362aa4c4e9c884de5d51f5b671d8e93fa
56 changes: 33 additions & 23 deletions pb/sf/metering/v1/metering.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pb/sf/metering/v1/metering_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion proto/sf/metering/v1/metering.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ message Events {

message Event {
string user_id = 1;
string api_key_id = 2;
string api_key_id = 2;
string ip_address = 3;

// Defines the endpoint that emitted the event (sf.firehose.v1/Blocks ...)
Expand All @@ -26,6 +26,8 @@ message Event {
// Defines the blockchain (eth-mainnet, sol-mainnet ...)
string network = 5;

string trace_id = 6;

repeated Metric metrics = 20;

google.protobuf.Timestamp timestamp = 30;
Expand Down

0 comments on commit cdbd987

Please sign in to comment.