diff --git a/exporter/tencentcloudlogserviceexporter/config.go b/exporter/tencentcloudlogserviceexporter/config.go index b471c53d3b3d..6dd2d8f1a8d7 100644 --- a/exporter/tencentcloudlogserviceexporter/config.go +++ b/exporter/tencentcloudlogserviceexporter/config.go @@ -16,16 +16,15 @@ package tencentcloudlogserviceexporter import ( "go.opentelemetry.io/collector/config" - "go.opentelemetry.io/collector/config/confignet" ) // Config defines configuration for TencentCloud Log Service exporter. type Config struct { config.ExporterSettings `mapstructure:",squash"` - // LogService's Endpoint, https://cloud.tencent.com/document/product/614/18940 - // for TencentCloud Kubernetes(or CVM), set ap-{region-id}.cls.tencentyun.com, eg ap-beijing.cls.tencentyun.com; - // others set ap-{region-id}.cls.tencentcs.com, eg ap-beijing.cls.tencentcs.com - confignet.TCPAddr `mapstructure:",squash"` + // LogService's Region, https://cloud.tencent.com/document/product/614/18940 + // for TencentCloud Kubernetes(or CVM), set ap-{region}.cls.tencentyun.com, eg ap-beijing.cls.tencentyun.com; + // others set ap-{region}.cls.tencentcs.com, eg ap-beijing.cls.tencentcs.com + Region string `mapstructure:"region"` // LogService's LogSet Name LogSet string `mapstructure:"logset"` // LogService's Topic Name diff --git a/exporter/tencentcloudlogserviceexporter/config_test.go b/exporter/tencentcloudlogserviceexporter/config_test.go index b4709bf1cbd3..4da9d11bea1b 100644 --- a/exporter/tencentcloudlogserviceexporter/config_test.go +++ b/exporter/tencentcloudlogserviceexporter/config_test.go @@ -23,7 +23,6 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/config" - "go.opentelemetry.io/collector/config/confignet" "go.opentelemetry.io/collector/config/configtest" ) @@ -42,21 +41,18 @@ func TestLoadConfig(t *testing.T) { // Endpoint doesn't have a default value so set it directly. defaultCfg := factory.CreateDefaultConfig().(*Config) - defaultCfg.TCPAddr = confignet.TCPAddr{ - Endpoint: "cls.ap-beijing.tencentcloudapi.com", - } + defaultCfg.Region = "ap-beijing" + assert.Equal(t, defaultCfg, e0) e1 := cfg.Exporters[config.NewComponentIDWithName(typeStr, "2")] expectedCfg := Config{ ExporterSettings: config.NewExporterSettings(config.NewComponentIDWithName(typeStr, "2")), - TCPAddr: confignet.TCPAddr{ - Endpoint: "cls.ap-beijing.tencentcloudapi.com", - }, - LogSet: "demo-logset", - Topic: "demo-topic", - SecretID: "demo-secret-id", - SecretKey: "demo-secret-key", + Region: "ap-beijing", + LogSet: "demo-logset", + Topic: "demo-topic", + SecretID: "demo-secret-id", + SecretKey: "demo-secret-key", } assert.Equal(t, &expectedCfg, e1) diff --git a/exporter/tencentcloudlogserviceexporter/example/config.yaml b/exporter/tencentcloudlogserviceexporter/example/config.yaml index cd5ba662fefa..8e6a67075d74 100644 --- a/exporter/tencentcloudlogserviceexporter/example/config.yaml +++ b/exporter/tencentcloudlogserviceexporter/example/config.yaml @@ -1,19 +1,14 @@ receivers: - prometheus: - config: - scrape_configs: - - job_name: 'otel-collector' - scrape_interval: 10s - static_configs: - - targets: ['localhost:8890'] - - targets: ['localhost:8889'] - - targets: ['localhost:8888'] + otlp: + protocols: + grpc: + endpoint: ":4317" exporters: tencentcloud_logservice: - # LogService's Endpoint, https://cloud.tencent.com/document/product/614/18940 - # set cls.{region-id}.tencentcloudapi.com, eg cls.ap-beijing.tencentcloudapi.com; - endpoint: "cls.ap-beijing.tencentcloudapi.com" + # LogService's Region, https://cloud.tencent.com/document/product/614/18940 + # set cls.{region}.tencentcloudapi.com, eg cls.ap-beijing.tencentcloudapi.com; + region: "ap-beijing" # LogService's LogSet ID logset: "demo-logset" # LogService's Topic ID @@ -26,5 +21,5 @@ exporters: service: pipelines: metrics: - receivers: [prometheus] + receivers: [otlp] exporters: [tencentcloud_logservice] diff --git a/exporter/tencentcloudlogserviceexporter/logs_exporter_test.go b/exporter/tencentcloudlogserviceexporter/logs_exporter_test.go index 2ed6a28364d9..b23e44324ca1 100644 --- a/exporter/tencentcloudlogserviceexporter/logs_exporter_test.go +++ b/exporter/tencentcloudlogserviceexporter/logs_exporter_test.go @@ -23,7 +23,6 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/config" - "go.opentelemetry.io/collector/config/confignet" "go.opentelemetry.io/collector/model/pdata" conventions "go.opentelemetry.io/collector/model/semconv/v1.5.0" ) @@ -53,11 +52,9 @@ func createSimpleLogData(numberOfLogs int) pdata.Logs { func TestNewLogsExporter(t *testing.T) { got, err := newLogsExporter(componenttest.NewNopExporterCreateSettings(), &Config{ ExporterSettings: config.NewExporterSettings(config.NewComponentID(typeStr)), - TCPAddr: confignet.TCPAddr{ - Endpoint: "cls.ap-beijing.tencentcloudapi.com", - }, - LogSet: "demo-logset", - Topic: "demo-topic", + Region: "ap-beijing", + LogSet: "demo-logset", + Topic: "demo-topic", }) assert.NoError(t, err) require.NotNil(t, got) diff --git a/exporter/tencentcloudlogserviceexporter/testdata/config.yaml b/exporter/tencentcloudlogserviceexporter/testdata/config.yaml index 1d3052566427..b61742330000 100644 --- a/exporter/tencentcloudlogserviceexporter/testdata/config.yaml +++ b/exporter/tencentcloudlogserviceexporter/testdata/config.yaml @@ -6,9 +6,9 @@ processors: exporters: tencentcloud_logservice: - endpoint: "cls.ap-beijing.tencentcloudapi.com" + region: "ap-beijing" tencentcloud_logservice/2: - endpoint: "cls.ap-beijing.tencentcloudapi.com" + region: "ap-beijing" # LogService's LogSet ID logset: "demo-logset" # LogService's Topic ID diff --git a/exporter/tencentcloudlogserviceexporter/uploader.go b/exporter/tencentcloudlogserviceexporter/uploader.go index e0e054fe0617..7d8c9533299f 100644 --- a/exporter/tencentcloudlogserviceexporter/uploader.go +++ b/exporter/tencentcloudlogserviceexporter/uploader.go @@ -22,7 +22,6 @@ import ( "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common" tchttp "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http" "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile" - "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/regions" "go.uber.org/zap" pb "google.golang.org/protobuf/proto" @@ -45,8 +44,8 @@ type logServiceClientImpl struct { // newLogServiceClient Create Log Service client func newLogServiceClient(config *Config, logger *zap.Logger) (logServiceClient, error) { - if config == nil || config.TCPAddr.Endpoint == "" || config.LogSet == "" || config.Topic == "" { - return nil, errors.New("missing logservice params: TCPAddr, LogSet, Topic") + if config == nil || config.Region == "" || config.LogSet == "" || config.Topic == "" { + return nil, errors.New("missing logservice params: Region, LogSet, Topic") } var credential *common.Credential @@ -59,7 +58,7 @@ func newLogServiceClient(config *Config, logger *zap.Logger) (logServiceClient, } c := &logServiceClientImpl{ - clientInstance: common.NewCommonClient(credential, regions.Beijing, profile.NewClientProfile()), + clientInstance: common.NewCommonClient(credential, config.Region, profile.NewClientProfile()), logset: config.LogSet, topic: config.Topic, logger: logger,