Skip to content

Commit

Permalink
so many go dependency upgrades (#107)
Browse files Browse the repository at this point in the history
* upgrade argoproj/argo-cd-v2 to 2.7.15

* more upgrades!

* even more upgrades

* many upgrades

* more upgrades

* upgrade prometheus client to v1.18.0

* upgrade github.com/rs/zerolog to v1.31.0

* upgrade github.com/sashabaranov/go-openai to v1.17.11

* upgrade github.com/xanzy/go-gitlab to v0.95.2

* upgrade golang.org/x/oauth2 to v0.16.0

* upgrade github.com/argoproj/argo-cd/v2 to v2.9.3

* upgrade k8s.io to v0.26.12

* more upgrades

* a few more upgrades

* upgrade github.com/golang/protobuf to v1.5.3

* remove deprecated stuff
  • Loading branch information
djeebus authored Jan 12, 2024
1 parent 8545f82 commit c7c9779
Show file tree
Hide file tree
Showing 7 changed files with 557 additions and 1,890 deletions.
328 changes: 163 additions & 165 deletions go.mod

Large diffs are not rendered by default.

1,996 changes: 386 additions & 1,610 deletions go.sum

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion pkg/argo_client/manifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ func GetManifestsLocal(ctx context.Context, name string, tempRepoDir string, cha
KustomizeOptions: argoSettings.KustomizeOptions,
KubeVersion: cluster.Info.ServerVersion,
ApiVersions: cluster.Info.APIVersions,
Plugins: argoSettings.ConfigManagementPlugins,
TrackingMethod: argoSettings.TrackingMethod,
}, true, &git.NoopCredsStore{}, resource.MustParse("0"), nil)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/vcs/gitlab_client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (c *Client) buildRepoFromEvent(event *gitlab.MergeEvent) *repo.Repo {
// Convert all labels from this MR to a string array of label names
var labels []string
for _, label := range event.Labels {
labels = append(labels, label.Name)
labels = append(labels, label.Title)
}

return &repo.Repo{
Expand Down
12 changes: 6 additions & 6 deletions pkg/vcs/gitlab_client/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"context"
"strings"

"github.com/zapier/kubechecks/pkg/repo_config"
"github.com/zapier/kubechecks/telemetry"
"github.com/xanzy/go-gitlab"
"go.opentelemetry.io/otel"

"github.com/xanzy/go-gitlab"
"github.com/zapier/kubechecks/pkg/repo_config"
"github.com/zapier/kubechecks/telemetry"
)

type Changes struct {
Expand All @@ -26,14 +26,14 @@ func (c *Client) GetMergeChanges(ctx context.Context, projectId int, mergeReqId
_, span := otel.Tracer("Kubechecks").Start(ctx, "GetMergeChanges")
defer span.End()

changes := []*Changes{}
mr, _, err := c.MergeRequests.GetMergeRequestChanges(projectId, mergeReqId, &gitlab.GetMergeRequestChangesOptions{})
var changes []*Changes
diffs, _, err := c.MergeRequests.ListMergeRequestDiffs(projectId, mergeReqId, &gitlab.ListMergeRequestDiffsOptions{})
if err != nil {
telemetry.SetError(span, err, "Get MergeRequest Changes")
return changes, err
}

for _, change := range mr.Changes {
for _, change := range diffs {
changes = append(changes, &Changes{
OldPath: change.OldPath,
NewPath: change.NewPath,
Expand Down
104 changes: 0 additions & 104 deletions telemetry/metric.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package telemetry

import (
"context"
"fmt"

"go.opentelemetry.io/otel/attribute"
otelMetric "go.opentelemetry.io/otel/metric"
)

type MetricType int
Expand Down Expand Up @@ -77,59 +73,13 @@ func intToBool(i int64) bool {
return i == 1
}

func boolToInt(v bool) int64 {
if v {
return 1
}
return 0
}

func BoolAttribute(key string, value bool) Attrs {
return Attrs{
Key: key,
Value: AttrsValue{
Type: BOOL,
Numberic: boolToInt(value),
},
}
}

func StringAttribute(key, value string) Attrs {
return Attrs{
Key: key,
Value: AttrsValue{
Type: STRING,
Stringly: value,
},
}
}

func StringSliceAttribute(key string, value []string) Attrs {
return Attrs{
Key: key,
Value: AttrsValue{
Type: STRINGSLICE,
Slice: value,
},
}
}

type MetricData struct {
Name string
MetricType MetricType
Value interface{}
Attrs []Attrs
}

func NewMetricData(name string, metricType MetricType, value interface{}, attrs ...Attrs) *MetricData {
return &MetricData{
Name: name,
MetricType: metricType,
Value: value,
Attrs: attrs,
}
}

func (md MetricData) ConvertAttrs() []attribute.KeyValue {
attrs := []attribute.KeyValue{}

Expand All @@ -148,57 +98,3 @@ func (md MetricData) ConvertAttrs() []attribute.KeyValue {

return attrs
}

func RecordGaugeFloat(ctx context.Context, meter otelMetric.Meter, metricName string, value float64, attrs ...attribute.KeyValue) error {
h, err := meter.SyncFloat64().UpDownCounter(metricName)
if err != nil {
return fmt.Errorf("error creating %s gauge: %s", metricName, err.Error())
}
h.Add(ctx, value, attrs...)
return nil
}

func RecordGaugeInt(ctx context.Context, meter otelMetric.Meter, metricName string, value int64, attrs ...attribute.KeyValue) error {
h, err := meter.SyncInt64().UpDownCounter(metricName)
if err != nil {
return fmt.Errorf("error creating %s gauge: %s", metricName, err.Error())
}
h.Add(ctx, value, attrs...)
return nil
}

func RecordCounterFloat(ctx context.Context, meter otelMetric.Meter, metricName string, value float64, attrs ...attribute.KeyValue) error {
h, err := meter.SyncFloat64().Counter(metricName)
if err != nil {
return fmt.Errorf("error creating %s counter: %s", metricName, err.Error())
}
h.Add(ctx, value, attrs...)
return nil
}

func RecordCounterInt(ctx context.Context, meter otelMetric.Meter, metricName string, value int64, attrs ...attribute.KeyValue) error {
h, err := meter.SyncInt64().Counter(metricName)
if err != nil {
return fmt.Errorf("error creating %s counter: %s", metricName, err.Error())
}
h.Add(ctx, value, attrs...)
return nil
}

func RecordHistogramInt(ctx context.Context, meter otelMetric.Meter, metricName string, value int64, attrs ...attribute.KeyValue) error {
h, err := meter.SyncInt64().Histogram(metricName)
if err != nil {
return fmt.Errorf("error creating %s counter: %s", metricName, err.Error())
}
h.Record(ctx, value, attrs...)
return nil
}

func RecordHistogramFloat(ctx context.Context, meter otelMetric.Meter, metricName string, value float64, attrs ...attribute.KeyValue) error {
h, err := meter.SyncFloat64().Histogram(metricName)
if err != nil {
return fmt.Errorf("error creating %s counter: %s", metricName, err.Error())
}
h.Record(ctx, value, attrs...)
return nil
}
4 changes: 1 addition & 3 deletions telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
mGlobal "go.opentelemetry.io/otel/metric/global"
"go.opentelemetry.io/otel/propagation"
"go.opentelemetry.io/otel/sdk/metric"
"go.opentelemetry.io/otel/sdk/resource"
Expand Down Expand Up @@ -184,7 +183,6 @@ func (bt *BaseTelemetry) initOTLPMetric(conn *grpc.ClientConn, res *resource.Res

otelReader := metric.NewPeriodicReader(
mClient,
metric.WithAggregationSelector(metric.DefaultAggregationSelector),
metric.WithInterval(DefaultMetricInterval*time.Second),
)

Expand All @@ -193,7 +191,7 @@ func (bt *BaseTelemetry) initOTLPMetric(conn *grpc.ClientConn, res *resource.Res
metric.WithReader(otelReader),
)

mGlobal.SetMeterProvider(bt.metric)
otel.SetMeterProvider(bt.metric)

return nil
}

0 comments on commit c7c9779

Please sign in to comment.