Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TT-9476]: add graphstats to analytics record proto #736

Merged
merged 6 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion analytics/analytics.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ type AnalyticsRecord struct {
ExpireAt time.Time `bson:"expireAt" json:"expireAt"`
ApiSchema string `json:"api_schema" bson:"-" gorm:"-:all"` //nolint

CollectionName string `json:"-" bson:"-" gorm:"-:all"`
GraphQLStats GraphQLStats `json:"-" bson:"-" gorm:"-:all"`
CollectionName string `json:"-" bson:"-" gorm:"-:all"`
}

func (a *AnalyticsRecord) TableName() string {
Expand All @@ -92,6 +93,25 @@ func (a *AnalyticsRecord) SetObjectID(id model.ObjectID) {
a.id = id
}

type GraphQLOperations int

const (
Operation_Unknown GraphQLOperations = iota
Operation_Query
Operation_Mutation
Operation_Subscription
)

type GraphQLStats struct {
IsGraphQL bool
Types map[string][]string
OperationType GraphQLOperations
Variables string
RootFields []string
HasErrors bool
Errors []GraphError
}

type GraphError struct {
Message string `json:"message"`
Path []interface{} `json:"path"`
Expand Down
22 changes: 22 additions & 0 deletions analytics/analytics.proto
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ message AnalyticsRecord {
string OauthID = 29;
string TimeZone = 30;
string ApiSchema = 31;
GraphQLStats GraphQLStats = 32;
}

message Latency {
Expand Down Expand Up @@ -74,3 +75,24 @@ message NetworkStats {
int64 BytesIn = 3;
int64 BytesOut = 4;
}

enum GraphQLOperations{
OPERATION_UNKNOWN = 0;
OPERATION_QUERY = 1;
OPERATION_MUTATION = 2;
OPERATION_SUBSCRIPTION = 3;
}

message GraphQLStats{
bool IsGraphQL = 1;
map<string, RepeatedFields> Types = 2;
GraphQLOperations OperationType = 3;
string Variables = 4;
repeated string RootFields = 5;
bool HasError = 6;
repeated string GraphErrors = 7;
}

message RepeatedFields{
repeated string fields = 1;
}
Loading
Loading