forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
factory.go
48 lines (40 loc) · 1.34 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
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package awsproxy // import "github.com/open-telemetry/opentelemetry-collector-contrib/extension/awsproxy"
import (
"context"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/confignet"
"go.opentelemetry.io/collector/config/configtls"
"go.opentelemetry.io/collector/extension"
"github.com/open-telemetry/opentelemetry-collector-contrib/extension/awsproxy/internal/metadata"
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/proxy"
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/localhostgate"
)
const (
defaultPort = 2000
)
// NewFactory creates a factory for awsproxy extension.
func NewFactory() extension.Factory {
return extension.NewFactory(
metadata.Type,
createDefaultConfig,
createExtension,
metadata.ExtensionStability,
)
}
func createDefaultConfig() component.Config {
return &Config{
ProxyConfig: proxy.Config{
TCPAddrConfig: confignet.TCPAddrConfig{
Endpoint: localhostgate.EndpointForPort(defaultPort),
},
TLSSetting: configtls.ClientConfig{
Insecure: false,
},
},
}
}
func createExtension(_ context.Context, params extension.Settings, cfg component.Config) (extension.Extension, error) {
return newXrayProxy(cfg.(*Config), params.TelemetrySettings)
}