Skip to content

Commit

Permalink
chore: Bump azure/login from 2.1.0 to 2.1.1 (ratify-project#1507)
Browse files Browse the repository at this point in the history
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

feat: add namespace label to metrics
  • Loading branch information
dependabot[bot] authored and binbin-li committed May 27, 2024
1 parent 368c676 commit 3c51027
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
go-version: '1.21'

- name: Az CLI login
uses: azure/login@6b2456866fc08b011acb422a92a4aa20e2c4de32 # v2.1.0
uses: azure/login@6c251865b4e6290e7b78be643ea2d005bc51f69a # v2.1.1
with:
client-id: ${{ env.AZURE_CLIENT_ID }}
tenant-id: ${{ env.AZURE_TENANT_ID }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-aks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
with:
go-version: '1.21'
- name: Az CLI login
uses: azure/login@6b2456866fc08b011acb422a92a4aa20e2c4de32 # v2.1.0
uses: azure/login@6c251865b4e6290e7b78be643ea2d005bc51f69a # v2.1.1
with:
client-id: ${{ env.AZURE_CLIENT_ID }}
tenant-id: ${{ env.AZURE_TENANT_ID }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-full-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
go-version: '1.21'

- name: Az CLI login
uses: azure/login@6b2456866fc08b011acb422a92a4aa20e2c4de32 # v2.1.0
uses: azure/login@6c251865b4e6290e7b78be643ea2d005bc51f69a # v2.1.1
with:
client-id: ${{ env.AZURE_CLIENT_ID }}
tenant-id: ${{ env.AZURE_TENANT_ID }}
Expand Down
30 changes: 24 additions & 6 deletions pkg/metrics/stats_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package metrics
import (
"context"

ctxUtils "github.com/deislabs/ratify/internal/context"
"github.com/sirupsen/logrus"
"go.opentelemetry.io/otel/attribute"
instrument "go.opentelemetry.io/otel/metric"
Expand Down Expand Up @@ -221,6 +222,10 @@ func ReportVerifierDuration(ctx context.Context, duration int64, veriferName str
Key: "error",
Value: attribute.BoolValue(isError),
},
attribute.KeyValue{
Key: "namespace",
Value: attribute.StringValue(ctxUtils.GetNamespace(ctx)),
},
))
}
}
Expand All @@ -230,7 +235,9 @@ func ReportVerifierDuration(ctx context.Context, duration int64, veriferName str
// errorString: the error message
func ReportSystemError(ctx context.Context, errorString string) {
if systemErrorCount != nil {
systemErrorCount.Add(ctx, 1, instrument.WithAttributes(attribute.KeyValue{Key: "error", Value: attribute.StringValue(errorString)}))
systemErrorCount.Add(ctx, 1, instrument.WithAttributes(
attribute.KeyValue{Key: "error", Value: attribute.StringValue(errorString)},
attribute.KeyValue{Key: "namespace", Value: attribute.StringValue(ctxUtils.GetNamespace(ctx))}))
}
}

Expand All @@ -240,7 +247,10 @@ func ReportSystemError(ctx context.Context, errorString string) {
// registryHost: the host name of the registry
func ReportRegistryRequestCount(ctx context.Context, statusCode int, registryHost string) {
if registryRequestCount != nil {
registryRequestCount.Add(ctx, 1, instrument.WithAttributes(attribute.KeyValue{Key: "status_code", Value: attribute.IntValue(statusCode)}, attribute.KeyValue{Key: "registry_host", Value: attribute.StringValue(registryHost)}))
registryRequestCount.Add(ctx, 1, instrument.WithAttributes(
attribute.KeyValue{Key: "status_code", Value: attribute.IntValue(statusCode)},
attribute.KeyValue{Key: "registry_host", Value: attribute.StringValue(registryHost)},
attribute.KeyValue{Key: "namespace", Value: attribute.StringValue(ctxUtils.GetNamespace(ctx))}))
}
}

Expand All @@ -249,7 +259,9 @@ func ReportRegistryRequestCount(ctx context.Context, statusCode int, registryHos
// resourceType: the scope of resource being exchanged (AKV or ACR)
func ReportAADExchangeDuration(ctx context.Context, duration int64, resourceType string) {
if aadExchangeDuration != nil {
aadExchangeDuration.Record(ctx, duration, instrument.WithAttributes(attribute.KeyValue{Key: "resource_type", Value: attribute.StringValue(resourceType)}))
aadExchangeDuration.Record(ctx, duration, instrument.WithAttributes(
attribute.KeyValue{Key: "resource_type", Value: attribute.StringValue(resourceType)},
attribute.KeyValue{Key: "namespace", Value: attribute.StringValue(ctxUtils.GetNamespace(ctx))}))
}
}

Expand All @@ -258,7 +270,9 @@ func ReportAADExchangeDuration(ctx context.Context, duration int64, resourceType
// repository: the repository being accessed
func ReportACRExchangeDuration(ctx context.Context, duration int64, repository string) {
if acrExchangeDuration != nil {
acrExchangeDuration.Record(ctx, duration, instrument.WithAttributes(attribute.KeyValue{Key: "repository", Value: attribute.StringValue(repository)}))
acrExchangeDuration.Record(ctx, duration, instrument.WithAttributes(
attribute.KeyValue{Key: "repository", Value: attribute.StringValue(repository)},
attribute.KeyValue{Key: "namespace", Value: attribute.StringValue(ctxUtils.GetNamespace(ctx))}))
}
}

Expand All @@ -267,7 +281,9 @@ func ReportACRExchangeDuration(ctx context.Context, duration int64, repository s
// certificateName: the object name of the certificate
func ReportAKVCertificateDuration(ctx context.Context, duration int64, certificateName string) {
if akvCertificateDuration != nil {
akvCertificateDuration.Record(ctx, duration, instrument.WithAttributes(attribute.KeyValue{Key: "certificate_name", Value: attribute.StringValue(certificateName)}))
akvCertificateDuration.Record(ctx, duration, instrument.WithAttributes(
attribute.KeyValue{Key: "certificate_name", Value: attribute.StringValue(certificateName)},
attribute.KeyValue{Key: "namespace", Value: attribute.StringValue(ctxUtils.GetNamespace(ctx))}))
}
}

Expand All @@ -276,6 +292,8 @@ func ReportAKVCertificateDuration(ctx context.Context, duration int64, certifica
// hit: whether the blob was found in the cache
func ReportBlobCacheCount(ctx context.Context, hit bool) {
if cacheBlobCount != nil {
cacheBlobCount.Add(ctx, 1, instrument.WithAttributes(attribute.KeyValue{Key: "hit", Value: attribute.BoolValue(hit)}))
cacheBlobCount.Add(ctx, 1, instrument.WithAttributes(
attribute.KeyValue{Key: "hit", Value: attribute.BoolValue(hit)},
attribute.KeyValue{Key: "namespace", Value: attribute.StringValue(ctxUtils.GetNamespace(ctx))}))
}
}

0 comments on commit 3c51027

Please sign in to comment.