Skip to content

Commit

Permalink
patch: Add ids to metric proto message and remove job reference message
Browse files Browse the repository at this point in the history
  • Loading branch information
cluttrdev committed Jul 18, 2024
1 parent 44bf374 commit f9c9fc2
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 132 deletions.
10 changes: 5 additions & 5 deletions internal/gitlab/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,18 +166,18 @@ func (c *Client) GetPipelineHierarchy(ctx context.Context, projectID int64, pipe
}

if opt.FetchJobMetrics {
var metricIID int = 0
for _, m := range data.Metrics {
metricIID++
metric := &typespb.Metric{
Id: []byte(fmt.Sprintf("%d-%d", job.Id, metricIID)),
Iid: int64(metricIID),
JobId: job.Id,
Name: m.Name,
Labels: convertLabels(m.Labels),
Value: m.Value,
Timestamp: convertUnixMilli(m.Timestamp),
Job: &typespb.Metric_JobReference{
Id: job.Id,
Name: job.Name,
},
}

metrics = append(metrics, metric)
}
}
Expand Down
175 changes: 59 additions & 116 deletions protobuf/typespb/metric.pb.go

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

19 changes: 8 additions & 11 deletions protos/gitlabexporter/protobuf/metric.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,19 @@ package gitlabexporter.protobuf;
import "google/protobuf/timestamp.proto";

message Metric {
string name = 1;
bytes id = 1;
int64 iid = 2;
int64 job_id = 3;

string name = 10;

message Label {
string name = 1;
string value = 2;
}
repeated Label labels = 2;

double value = 3;
repeated Label labels = 11;

google.protobuf.Timestamp timestamp = 4;

message JobReference {
int64 id = 1;
string name = 2;
}
double value = 12;

JobReference job = 5;
google.protobuf.Timestamp timestamp = 13;
}

0 comments on commit f9c9fc2

Please sign in to comment.