Skip to content

Commit

Permalink
Make global cache OLAP multi-value
Browse files Browse the repository at this point in the history
  • Loading branch information
kwapik committed Dec 11, 2023
1 parent a927175 commit 211ec2d
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ and behavior. The stream can be stored and visualized in

<!-- vale off -->

| Name | Type | Example Values | Description | Flow Control Integrations |
| -------------------------------------- | ------ | -------------- | ------------------------------------------------ | ------------------------- |
| aperture.cache_lookup_status | single | HIT, MISS | Result of result cache lookup | SDKs |
| aperture.cache_operation_status | single | SUCCESS, ERROR | Result of result cache operation | SDKs |
| aperture.global_cache_lookup_status | single | HIT, MISS | Result of global cache lookup | SDKs |
| aperture.global_cache_operation_status | single | SUCCESS, ERROR | Result of global cache operation | SDKs |
| {user-defined-labels} | | | Explicitly passed through FlowStart call in SDKs | SDKs |
| Name | Type | Example Values | Description | Flow Control Integrations |
| ---------------------------------------- | ----------- | -------------- | ------------------------------------------------ | ------------------------- |
| aperture.cache_lookup_status | single | HIT, MISS | Result of result cache lookup | SDKs |
| aperture.cache_operation_status | single | SUCCESS, ERROR | Result of result cache operation | SDKs |
| aperture.global_cache_lookup_statuses | multi-value | HIT, MISS | Results of global cache lookups | SDKs |
| aperture.global_cache_operation_statuses | multi-value | SUCCESS, ERROR | Results of global cache operations | SDKs |
| {user-defined-labels} | | | Explicitly passed through FlowStart call in SDKs | SDKs |

<!-- vale on -->

Expand Down
8 changes: 4 additions & 4 deletions pkg/otelcollector/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ const (
ApertureResultCacheLookupStatusLabel = "aperture.cache_lookup_status"
// ApertureResultCacheOperationStatusLabel describes status of the cache operation.
ApertureResultCacheOperationStatusLabel = "aperture.cache_operation_status"
// ApertureGlobalCacheLookupStatusLabel describes status of the cache lookup.
ApertureGlobalCacheLookupStatusLabel = "aperture.global_cache_lookup_status"
// ApertureGlobalCacheOperationStatusLabel describes status of the cache operation.
ApertureGlobalCacheOperationStatusLabel = "aperture.global_cache_operation_status"
// ApertureGlobalCacheLookupStatusesLabel describes statuses of the global cache lookups.
ApertureGlobalCacheLookupStatusesLabel = "aperture.global_cache_lookup_statuses"
// ApertureGlobalCacheOperationStatusesLabel describes statuses of the global cache operations.
ApertureGlobalCacheOperationStatusesLabel = "aperture.global_cache_operation_statuses"

/* HTTP Specific labels. */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import (
// * otelconsts.ApertureRejectReasonLabel
// * otelconsts.ApertureResultCacheLookupStatusLabel
// * otelconsts.ApertureResultCacheOperationStatusLabel
// * otelconsts.ApertureGlobalCacheLookupStatusLabel
// * otelconsts.ApertureGlobalCacheOperationStatusLabel
// * otelconsts.ApertureGlobalCacheLookupStatusesLabel
// * otelconsts.ApertureGlobalCacheOperationStatusesLabel
// * dynamic flow labels.
func AddCheckResponseBasedLabels(attributes pcommon.Map, checkResponse *flowcontrolv1.CheckResponse, sourceStr string) {
// Aperture Processing Duration
Expand Down Expand Up @@ -69,12 +69,14 @@ func AddCheckResponseBasedLabels(attributes pcommon.Map, checkResponse *flowcont
attributes.PutStr(otelconsts.ApertureResultCacheLookupStatusLabel, resultCacheResponse.LookupStatus.String())
attributes.PutStr(otelconsts.ApertureResultCacheOperationStatusLabel, resultCacheResponse.OperationStatus.String())
}
globalCacheLookupStatuses := attributes.PutEmptySlice(otelconsts.ApertureGlobalCacheLookupStatusesLabel)
globalCacheOperationStatuses := attributes.PutEmptySlice(otelconsts.ApertureGlobalCacheOperationStatusesLabel)
for _, globalCacheResponse := range checkResponse.CacheLookupResponse.GlobalCacheResponses {
if globalCacheResponse == nil {
continue
}
attributes.PutStr(otelconsts.ApertureGlobalCacheLookupStatusLabel, globalCacheResponse.LookupStatus.String())
attributes.PutStr(otelconsts.ApertureGlobalCacheOperationStatusLabel, globalCacheResponse.OperationStatus.String())
globalCacheLookupStatuses.AppendEmpty().SetStr(globalCacheResponse.LookupStatus.String())
globalCacheOperationStatuses.AppendEmpty().SetStr(globalCacheResponse.OperationStatus.String())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,42 @@ var _ = DescribeTable("Check Response labels", func(checkResponse *flowcontrolv1
otelconsts.ApertureClassifierErrorsLabel: []interface{}{"ERROR_MULTI_EXPRESSION,policy_name:foo,classifier_index:42,policy_hash:bar"},
},
),

Entry("Sets result cache dimensions",
&flowcontrolv1.CheckResponse{
CacheLookupResponse: &flowcontrolv1.CacheLookupResponse{
ResultCacheResponse: &flowcontrolv1.KeyLookupResponse{
LookupStatus: flowcontrolv1.CacheLookupStatus_MISS,
OperationStatus: flowcontrolv1.CacheOperationStatus_ERROR,
},
},
},
map[string]interface{}{
otelconsts.ApertureResultCacheLookupStatusLabel: "MISS",
otelconsts.ApertureResultCacheOperationStatusLabel: "ERROR",
},
),

Entry("Sets global cache dimensions",
&flowcontrolv1.CheckResponse{
CacheLookupResponse: &flowcontrolv1.CacheLookupResponse{
GlobalCacheResponses: map[string]*flowcontrolv1.KeyLookupResponse{
"foo": {
LookupStatus: flowcontrolv1.CacheLookupStatus_HIT,
OperationStatus: flowcontrolv1.CacheOperationStatus_SUCCESS,
},
"bar": {
LookupStatus: flowcontrolv1.CacheLookupStatus_MISS,
OperationStatus: flowcontrolv1.CacheOperationStatus_ERROR,
},
},
},
},
map[string]interface{}{
otelconsts.ApertureGlobalCacheLookupStatusesLabel: []interface{}{"HIT", "MISS"},
otelconsts.ApertureGlobalCacheOperationStatusesLabel: []interface{}{"SUCCESS", "ERROR"},
},
),
)

var _ = Describe("AddFlowLabels", func() {
Expand Down
4 changes: 2 additions & 2 deletions pkg/otelcollector/metricsprocessor/internal/labels_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ var (
otelconsts.ApertureFlowStatusLabel,
otelconsts.ApertureResultCacheLookupStatusLabel,
otelconsts.ApertureResultCacheOperationStatusLabel,
otelconsts.ApertureGlobalCacheLookupStatusLabel,
otelconsts.ApertureGlobalCacheOperationStatusLabel,
otelconsts.ApertureGlobalCacheLookupStatusesLabel,
otelconsts.ApertureGlobalCacheOperationStatusesLabel,
}

includeListHTTP = utils.SliceToSet(append(_includeAttributesCommon, _includeAttributesHTTP...))
Expand Down

0 comments on commit 211ec2d

Please sign in to comment.