-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
factory.go
50 lines (42 loc) · 1.28 KB
/
factory.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package jmxreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jmxreceiver"
import (
"context"
"time"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/exporter/exporterhelper"
"go.opentelemetry.io/collector/receiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/jmxreceiver/internal/metadata"
)
const (
otlpEndpoint = "0.0.0.0:0"
)
func NewFactory() receiver.Factory {
return receiver.NewFactory(
metadata.Type,
createDefaultConfig,
receiver.WithMetrics(createReceiver, metadata.MetricsStability))
}
func createDefaultConfig() component.Config {
return &Config{
JARPath: "/opt/opentelemetry-java-contrib-jmx-metrics.jar",
CollectionInterval: 10 * time.Second,
OTLPExporterConfig: otlpExporterConfig{
Endpoint: otlpEndpoint,
TimeoutSettings: exporterhelper.TimeoutSettings{
Timeout: 5 * time.Second,
},
},
}
}
func createReceiver(
_ context.Context,
params receiver.CreateSettings,
cfg component.Config,
consumer consumer.Metrics,
) (receiver.Metrics, error) {
jmxConfig := cfg.(*Config)
return newJMXMetricReceiver(params, jmxConfig, consumer), nil
}