Skip to content

Commit 8bfaf2c

Browse files
authored
Fix to start the NGINX plus scraper (#1072)
1 parent 735f503 commit 8bfaf2c

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

internal/collector/nginxplusreceiver/factory.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import (
99
"errors"
1010
"time"
1111

12+
"go.opentelemetry.io/collector/scraper"
13+
"go.opentelemetry.io/collector/scraper/scraperhelper"
14+
1215
"go.opentelemetry.io/collector/component"
1316
"go.opentelemetry.io/collector/consumer"
1417
"go.opentelemetry.io/collector/receiver"
@@ -43,6 +46,19 @@ func createMetricsReceiver(
4346
}
4447

4548
nps := newNginxPlusScraper(params, cfg)
49+
npsMetrics, npsMetricsError := scraper.NewMetrics(
50+
nps.Scrape,
51+
scraper.WithStart(nps.Start),
52+
scraper.WithShutdown(nps.Shutdown),
53+
)
54+
if npsMetricsError != nil {
55+
return nil, npsMetricsError
56+
}
4657

47-
return nps, nil
58+
return scraperhelper.NewMetricsController(
59+
&cfg.ControllerConfig,
60+
params,
61+
metricsConsumer,
62+
scraperhelper.AddScraper(metadata.Type, npsMetrics),
63+
)
4864
}

internal/config/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ type (
231231
}
232232

233233
ContainerMetricsReceiver struct {
234-
CollectionInterval time.Duration `yaml:"-" mapstructure:"collection_interval"`
234+
CollectionInterval time.Duration `yaml:"collection_interval" mapstructure:"collection_interval"`
235235
}
236236

237237
HostMetrics struct {

test/mock/collector/nginx-agent.conf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@ allowed_directories:
2828
- /var/run/nginx
2929

3030
client:
31-
timeout: 10s
31+
http:
32+
timeout: 10s
3233

3334
collector:
3435
log:
3536
level: DEBUG
3637
receivers:
3738
container_metrics:
38-
collection_interval: 10s
39+
collection_interval: 1m0s
3940
host_metrics:
4041
collection_interval: 1m0s
4142
initial_delay: 1s
@@ -49,9 +50,8 @@ collector:
4950
- server:
5051
host: "127.0.0.1"
5152
port: 4317
52-
type: 0
5353
auth:
54-
Token: secret-receiver-token
54+
token: secret-receiver-token
5555
tls:
5656
server_name: test-local-server
5757
ca: /tmp/ca.pem

0 commit comments

Comments
 (0)