Skip to content

Commit

Permalink
some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
naman47vyas committed Dec 12, 2024
1 parent c4e660e commit 3085c04
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 71 deletions.
18 changes: 9 additions & 9 deletions receiver/nginxreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ The number of responses with 1xx status code.
The number of responses with 2xx status code.
| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| response | Gauge | Int |
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| response | Sum | Int | Cumulative | true |
#### Attributes
Expand All @@ -142,9 +142,9 @@ The number of responses with 3xx status code.
The number of responses with 4xx status code.
| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| response | Gauge | Int |
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| response | Sum | Int | Cumulative | true |
#### Attributes
Expand All @@ -156,9 +156,9 @@ The number of responses with 4xx status code.
The number of responses with 5xx status code.
| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| response | Gauge | Int |
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| response | Sum | Int | Cumulative | true |
#### Attributes
Expand Down
42 changes: 24 additions & 18 deletions receiver/nginxreceiver/internal/metadata/generated_metrics.go

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

24 changes: 15 additions & 9 deletions receiver/nginxreceiver/internal/metadata/generated_metrics_test.go

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

41 changes: 12 additions & 29 deletions receiver/nginxreceiver/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ metrics:
value_type: int
monotonic: true
aggregation_temporality: cumulative
attributes: []
attributes: []
nginx.connections_accepted:
enabled: true
description: The total number of accepted client connections
Expand Down Expand Up @@ -120,11 +120,12 @@ metrics:
attributes:
- serverzone_name
description: The number of responses with 2xx status code.
gauge:
sum:
value_type: int
monotonic: true
aggregation_temporality: cumulative
unit:
response

nginx.server_zone.responses.3xx:
enabled: true
attributes:
Expand All @@ -140,21 +141,23 @@ metrics:
attributes:
- serverzone_name
description: The number of responses with 4xx status code.
gauge:
sum:
value_type: int
monotonic: true
aggregation_temporality: cumulative
unit:
response

nginx.server_zone.responses.5xx:
enabled: true
attributes:
- serverzone_name
description: The number of responses with 5xx status code.
gauge:
sum:
value_type: int
monotonic: true
aggregation_temporality: cumulative
unit:
response

nginx.server_zone.received:
enabled: true
attributes:
Expand All @@ -165,7 +168,6 @@ metrics:
monotonic: true
aggregation_temporality: cumulative
unit: By

nginx.server_zone.sent:
enabled: true
attributes:
Expand All @@ -176,12 +178,6 @@ metrics:
monotonic: true
aggregation_temporality: cumulative
unit: By

### Request and Traffic
# - `nginx.upstream.peers.requests` - Number of requests made to upstream servers
# - `nginx.upstream.peers.received` - Bytes received from upstream servers
# - `nginx.upstream.peers.sent` - Bytes sent to upstream servers

nginx.upstream.peers.requests:
enabled: true
attributes:
Expand All @@ -193,7 +189,6 @@ metrics:
monotonic: true
aggregation_temporality: cumulative
unit: requests

nginx.upstream.peers.received:
enabled: true
attributes:
Expand All @@ -218,13 +213,6 @@ metrics:
aggregation_temporality: cumulative
unit: By

### Response Codes
# - `nginx.upstream.peers.responses.1xx` - Number of responses from upstream with 1xx status codes
# - `nginx.upstream.peers.responses.2xx` - Number of responses from upstream with 2xx status codes
# - `nginx.upstream.peers.responses.3xx` - Number of responses from upstream with 3xx status codes
# - `nginx.upstream.peers.responses.4xx` - Number of responses from upstream with 4xx status codes
# - `nginx.upstream.peers.responses.5xx` - Number of responses from upstream with 5xx status codes

nginx.upstream.peers.responses.1xx:
enabled: true
attributes:
Expand All @@ -248,7 +236,7 @@ metrics:
monotonic: true
aggregation_temporality: cumulative
unit: responses

nginx.upstream.peers.responses.3xx:
enabled: true
attributes:
Expand All @@ -272,7 +260,7 @@ metrics:
monotonic: true
aggregation_temporality: cumulative
unit: responses

nginx.upstream.peers.responses.5xx:
enabled: true
attributes:
Expand All @@ -284,11 +272,6 @@ metrics:
monotonic: true
aggregation_temporality: cumulative
unit: responses

### Server Configuration
# - `nginx.upstream.peers.weight` - Weight of upstream server
# - `nginx.upstream.peers.backup` - Whether upstream server is a backup server
# - `nginx.upstream.peers.health_checks.last_passed` - Status of last health check for upstream server

nginx.upstream.peers.weight:
enabled: true
Expand Down
6 changes: 0 additions & 6 deletions receiver/nginxreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"go.opentelemetry.io/collector/receiver"
"go.uber.org/zap"

"github.com/k0kubun/pp"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/nginxreceiver/internal/metadata"
)

Expand Down Expand Up @@ -50,7 +49,6 @@ func (r *nginxScraper) start(ctx context.Context, host component.Host) error {
}

func (r *nginxScraper) scrape(context.Context) (pmetric.Metrics, error) {
// Init client in scrape method in case there are transient errors in the constructor.
if r.client == nil {
var err error
r.client, err = NewNginxClient(r.httpClient, r.cfg.ClientConfig.Endpoint, r.cfg.VTSEndpoint)
Expand All @@ -74,8 +72,6 @@ func (r *nginxScraper) scrape(context.Context) (pmetric.Metrics, error) {
return pmetric.Metrics{}, err
}

// pp.Println(vtsStats)

now := pcommon.NewTimestampFromTime(time.Now())

r.recordVtsStats(now, vtsStats)
Expand Down Expand Up @@ -182,8 +178,6 @@ func (r *nginxScraper) recordTimingStats(now pcommon.Timestamp, vtsStats *NginxV

for upstreamZones, v := range vtsStats.UpstreamZones {
for _, val := range v {
pp.Println(val.Server)
pp.Println(val.ResponseMsec)

r.mb.RecordNginxUpstreamPeersResponseTimeDataPoint(
now, val.ResponseMsec, upstreamZones, val.Server,
Expand Down

0 comments on commit 3085c04

Please sign in to comment.