From 605b02f484abbb2bc90367f2eb4320f7c6e07f50 Mon Sep 17 00:00:00 2001 From: Jonathan Wamsley Date: Mon, 21 Mar 2022 16:24:49 -0400 Subject: [PATCH 1/2] rename attribute --- receiver/varnishreceiver/documentation.md | 4 +- .../internal/metadata/generated_metrics_v2.go | 30 +- receiver/varnishreceiver/metadata.yaml | 6 +- receiver/varnishreceiver/metrics.go | 4 +- .../testdata/scraper/expected.json | 363 ------------------ 5 files changed, 22 insertions(+), 385 deletions(-) delete mode 100644 receiver/varnishreceiver/testdata/scraper/expected.json diff --git a/receiver/varnishreceiver/documentation.md b/receiver/varnishreceiver/documentation.md index f5a17a7e8..3f34a91cf 100644 --- a/receiver/varnishreceiver/documentation.md +++ b/receiver/varnishreceiver/documentation.md @@ -11,7 +11,7 @@ These are the metrics available for this scraper. | **varnish.backend.connections.count** | The backend connection type count. | {connections} | Sum(Int) | | | **varnish.backend.requests.count** | The backend requests count. | {requests} | Sum(Int) | | | **varnish.cache.operations.count** | The cache operation type count. | {operations} | Sum(Int) | | -| **varnish.client.requests.count** | The client request count. | {requests} | Sum(Int) | | +| **varnish.client.requests.count** | The client request count. | {requests} | Sum(Int) | | | **varnish.object.count** | The HTTP objects in the cache count. | {objects} | Sum(Int) | | | **varnish.object.expired.count** | The expired objects from old age count. | {objects} | Sum(Int) | | | **varnish.object.moved.count** | The moved operations done on the LRU list count. | {objects} | Sum(Int) | | @@ -35,6 +35,6 @@ metrics: | backend_connection_type | The backend connection types. | | cache_name | The varnish cache name. | | cache_operations | The cache operation types | -| client_requests | The client request types. | | session_type | The session connection types. | +| state | The client request states. | | thread_operations | The thread operation types. | diff --git a/receiver/varnishreceiver/internal/metadata/generated_metrics_v2.go b/receiver/varnishreceiver/internal/metadata/generated_metrics_v2.go index 7163b9158..826a24589 100644 --- a/receiver/varnishreceiver/internal/metadata/generated_metrics_v2.go +++ b/receiver/varnishreceiver/internal/metadata/generated_metrics_v2.go @@ -236,7 +236,7 @@ func (m *metricVarnishClientRequestsCount) init() { m.data.Sum().DataPoints().EnsureCapacity(m.capacity) } -func (m *metricVarnishClientRequestsCount) recordDataPoint(start pdata.Timestamp, ts pdata.Timestamp, val int64, clientRequestsAttributeValue string) { +func (m *metricVarnishClientRequestsCount) recordDataPoint(start pdata.Timestamp, ts pdata.Timestamp, val int64, stateAttributeValue string) { if !m.settings.Enabled { return } @@ -244,7 +244,7 @@ func (m *metricVarnishClientRequestsCount) recordDataPoint(start pdata.Timestamp dp.SetStartTimestamp(start) dp.SetTimestamp(ts) dp.SetIntVal(val) - dp.Attributes().Insert(A.ClientRequests, pdata.NewAttributeValueString(clientRequestsAttributeValue)) + dp.Attributes().Insert(A.State, pdata.NewAttributeValueString(stateAttributeValue)) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -660,8 +660,8 @@ func (mb *MetricsBuilder) RecordVarnishCacheOperationsCountDataPoint(ts pdata.Ti } // RecordVarnishClientRequestsCountDataPoint adds a data point to varnish.client.requests.count metric. -func (mb *MetricsBuilder) RecordVarnishClientRequestsCountDataPoint(ts pdata.Timestamp, val int64, clientRequestsAttributeValue string) { - mb.metricVarnishClientRequestsCount.recordDataPoint(mb.startTime, ts, val, clientRequestsAttributeValue) +func (mb *MetricsBuilder) RecordVarnishClientRequestsCountDataPoint(ts pdata.Timestamp, val int64, stateAttributeValue string) { + mb.metricVarnishClientRequestsCount.recordDataPoint(mb.startTime, ts, val, stateAttributeValue) } // RecordVarnishObjectCountDataPoint adds a data point to varnish.object.count metric. @@ -721,10 +721,10 @@ var Attributes = struct { CacheName string // CacheOperations (The cache operation types) CacheOperations string - // ClientRequests (The client request types.) - ClientRequests string // SessionType (The session connection types.) SessionType string + // State (The client request states.) + State string // ThreadOperations (The thread operation types.) ThreadOperations string }{ @@ -769,15 +769,6 @@ var AttributeCacheOperations = struct { "hit_pass", } -// AttributeClientRequests are the possible values that the attribute "client_requests" can have. -var AttributeClientRequests = struct { - Received string - Dropped string -}{ - "received", - "dropped", -} - // AttributeSessionType are the possible values that the attribute "session_type" can have. var AttributeSessionType = struct { Accepted string @@ -789,6 +780,15 @@ var AttributeSessionType = struct { "failed", } +// AttributeState are the possible values that the attribute "state" can have. +var AttributeState = struct { + Received string + Dropped string +}{ + "received", + "dropped", +} + // AttributeThreadOperations are the possible values that the attribute "thread_operations" can have. var AttributeThreadOperations = struct { Created string diff --git a/receiver/varnishreceiver/metadata.yaml b/receiver/varnishreceiver/metadata.yaml index fabd5f17a..ab4db501c 100644 --- a/receiver/varnishreceiver/metadata.yaml +++ b/receiver/varnishreceiver/metadata.yaml @@ -19,9 +19,9 @@ attributes: value: kind description: The session connection types. enum: [accepted, dropped, failed] - client_requests: + state: value: kind - description: The client request types. + description: The client request states. enum: [received, dropped] metrics: @@ -105,7 +105,7 @@ metrics: value_type: int monotonic: true aggregation: cumulative - attributes: [client_requests] + attributes: [state] varnish.backend.requests.count: enabled: true description: The backend requests count. diff --git a/receiver/varnishreceiver/metrics.go b/receiver/varnishreceiver/metrics.go index 3be3b6e0f..008402680 100644 --- a/receiver/varnishreceiver/metrics.go +++ b/receiver/varnishreceiver/metrics.go @@ -154,8 +154,8 @@ func (v *varnishScraper) recordVarnishSessionCountDataPoint(now pdata.Timestamp, func (v *varnishScraper) recordVarnishClientRequestsCountDataPoint(now pdata.Timestamp, stats *Stats) { attributeMappings := map[string]int64{ - metadata.AttributeClientRequests.Received: stats.MAINClientReq.Value, - metadata.AttributeClientRequests.Dropped: stats.MAINReqDropped.Value, + metadata.AttributeState.Received: stats.MAINClientReq.Value, + metadata.AttributeState.Dropped: stats.MAINReqDropped.Value, } for attributeName, attributeValue := range attributeMappings { diff --git a/receiver/varnishreceiver/testdata/scraper/expected.json b/receiver/varnishreceiver/testdata/scraper/expected.json deleted file mode 100644 index 3964e3396..000000000 --- a/receiver/varnishreceiver/testdata/scraper/expected.json +++ /dev/null @@ -1,363 +0,0 @@ -{ - "resourceMetrics": [ - { - "instrumentationLibraryMetrics": [ - { - "instrumentationLibrary": { - "name": "otelcol/varnishreceiver" - }, - "metrics": [ - { - "description": "The backend connection type count.", - "name": "varnish.backend.connections.count", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "0", - "attributes": [ - { - "key": "kind", - "value": { - "stringValue": "reuse" - } - } - ], - "startTimeUnixNano": "1647372655804888000", - "timeUnixNano": "1647372655804914000" - }, - { - "asInt": "0", - "attributes": [ - { - "key": "kind", - "value": { - "stringValue": "fail" - } - } - ], - "startTimeUnixNano": "1647372655804888000", - "timeUnixNano": "1647372655804914000" - }, - { - "asInt": "0", - "attributes": [ - { - "key": "kind", - "value": { - "stringValue": "unhealthy" - } - } - ], - "startTimeUnixNano": "1647372655804888000", - "timeUnixNano": "1647372655804914000" - }, - { - "asInt": "0", - "attributes": [ - { - "key": "kind", - "value": { - "stringValue": "busy" - } - } - ], - "startTimeUnixNano": "1647372655804888000", - "timeUnixNano": "1647372655804914000" - }, - { - "asInt": "0", - "attributes": [ - { - "key": "kind", - "value": { - "stringValue": "retry" - } - } - ], - "startTimeUnixNano": "1647372655804888000", - "timeUnixNano": "1647372655804914000" - }, - { - "asInt": "0", - "attributes": [ - { - "key": "kind", - "value": { - "stringValue": "success" - } - } - ], - "startTimeUnixNano": "1647372655804888000", - "timeUnixNano": "1647372655804914000" - }, - { - "asInt": "0", - "attributes": [ - { - "key": "kind", - "value": { - "stringValue": "recycle" - } - } - ], - "startTimeUnixNano": "1647372655804888000", - "timeUnixNano": "1647372655804914000" - } - ], - "isMonotonic": true - }, - "unit": "{connections}" - }, - { - "description": "The backend requests count.", - "name": "varnish.backend.requests.count", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "0", - "startTimeUnixNano": "1647372655804888000", - "timeUnixNano": "1647372655804914000" - } - ], - "isMonotonic": true - }, - "unit": "{requests}" - }, - { - "description": "The cache operation type count.", - "name": "varnish.cache.operations.count", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "0", - "attributes": [ - { - "key": "operation", - "value": { - "stringValue": "hit" - } - } - ], - "startTimeUnixNano": "1647372655804888000", - "timeUnixNano": "1647372655804914000" - }, - { - "asInt": "0", - "attributes": [ - { - "key": "operation", - "value": { - "stringValue": "hit_pass" - } - } - ], - "startTimeUnixNano": "1647372655804888000", - "timeUnixNano": "1647372655804914000" - }, - { - "asInt": "0", - "attributes": [ - { - "key": "operation", - "value": { - "stringValue": "miss" - } - } - ], - "startTimeUnixNano": "1647372655804888000", - "timeUnixNano": "1647372655804914000" - } - ], - "isMonotonic": true - }, - "unit": "{operations}" - }, - { - "description": "The client request count.", - "name": "varnish.client.requests.count", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "0", - "startTimeUnixNano": "1647372655804888000", - "timeUnixNano": "1647372655804914000" - } - ], - "isMonotonic": true - }, - "unit": "{requests}" - }, - { - "description": "The HTTP objects in the cache count.", - "name": "varnish.object.count", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "0", - "startTimeUnixNano": "1647372655804888000", - "timeUnixNano": "1647372655804914000" - } - ] - }, - "unit": "{objects}" - }, - { - "description": "The expired objects from old age count.", - "name": "varnish.object.expired.count", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "0", - "startTimeUnixNano": "1647372655804888000", - "timeUnixNano": "1647372655804914000" - } - ], - "isMonotonic": true - }, - "unit": "{objects}" - }, - { - "description": "The moved operations done on the LRU list count.", - "name": "varnish.object.moved.count", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "0", - "startTimeUnixNano": "1647372655804888000", - "timeUnixNano": "1647372655804914000" - } - ], - "isMonotonic": true - }, - "unit": "{objects}" - }, - { - "description": "The objects that have been forcefully evicted from storage count.", - "name": "varnish.object.nuked.count", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "0", - "startTimeUnixNano": "1647372655804888000", - "timeUnixNano": "1647372655804914000" - } - ], - "isMonotonic": true - }, - "unit": "{objects}" - }, - { - "description": "The session connection type count.", - "name": "varnish.session.count", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "0", - "attributes": [ - { - "key": "kind", - "value": { - "stringValue": "accepted" - } - } - ], - "startTimeUnixNano": "1647372655804888000", - "timeUnixNano": "1647372655804914000" - }, - { - "asInt": "0", - "attributes": [ - { - "key": "kind", - "value": { - "stringValue": "dropped" - } - } - ], - "startTimeUnixNano": "1647372655804888000", - "timeUnixNano": "1647372655804914000" - }, - { - "asInt": "0", - "attributes": [ - { - "key": "kind", - "value": { - "stringValue": "failed" - } - } - ], - "startTimeUnixNano": "1647372655804888000", - "timeUnixNano": "1647372655804914000" - } - ], - "isMonotonic": true - }, - "unit": "{connections}" - }, - { - "description": "The thread operation type count.", - "name": "varnish.thread.operations.count", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "0", - "attributes": [ - { - "key": "operation", - "value": { - "stringValue": "created" - } - } - ], - "startTimeUnixNano": "1647372655804888000", - "timeUnixNano": "1647372655804914000" - }, - { - "asInt": "0", - "attributes": [ - { - "key": "operation", - "value": { - "stringValue": "destroyed" - } - } - ], - "startTimeUnixNano": "1647372655804888000", - "timeUnixNano": "1647372655804914000" - }, - { - "asInt": "0", - "attributes": [ - { - "key": "operation", - "value": { - "stringValue": "failed" - } - } - ], - "startTimeUnixNano": "1647372655804888000", - "timeUnixNano": "1647372655804914000" - } - ], - "isMonotonic": true - }, - "unit": "{operations}" - } - ] - } - ], - "resource": {} - } - ] -} From f911fd2f357fe99ccdc10a3c96b7f9a50d42be21 Mon Sep 17 00:00:00 2001 From: Jonathan Wamsley Date: Mon, 21 Mar 2022 17:13:04 -0400 Subject: [PATCH 2/2] update attribute value --- .../varnishreceiver/internal/metadata/generated_metrics_v2.go | 2 +- receiver/varnishreceiver/metadata.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/receiver/varnishreceiver/internal/metadata/generated_metrics_v2.go b/receiver/varnishreceiver/internal/metadata/generated_metrics_v2.go index 826a24589..0d7929f95 100644 --- a/receiver/varnishreceiver/internal/metadata/generated_metrics_v2.go +++ b/receiver/varnishreceiver/internal/metadata/generated_metrics_v2.go @@ -732,7 +732,7 @@ var Attributes = struct { "cache_name", "operation", "kind", - "kind", + "state", "operation", } diff --git a/receiver/varnishreceiver/metadata.yaml b/receiver/varnishreceiver/metadata.yaml index ab4db501c..07e15cd17 100644 --- a/receiver/varnishreceiver/metadata.yaml +++ b/receiver/varnishreceiver/metadata.yaml @@ -20,7 +20,7 @@ attributes: description: The session connection types. enum: [accepted, dropped, failed] state: - value: kind + value: state description: The client request states. enum: [received, dropped]