Skip to content

Commit

Permalink
Make corrections based o reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
AkhigbeEromo committed Jan 9, 2025
1 parent 8177f6c commit 4b8dfa5
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 30 deletions.
6 changes: 3 additions & 3 deletions exporter/sematextexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The following configuration options are supported:
* `region` Region specifies the Sematext region the user is operating in; must be one of:
* `US`
* `EU`
* `app_token` App token specifies the token of Sematext Monitoring App to which the user wants to send data to.
* `app_token` specifies the token of the Sematext Monitoring App to which the user wants to send data. It must be a valid UUID string in the format `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`. For example: `2064e37c-4fac-45f6-831d-922d43fde759`.
* `payload_max_lines` (default = 1_000) Maximum number of lines allowed per HTTP POST request
* `payload_max_bytes` (default = 300_000) Maximum number of bytes allowed per HTTP POST request
* `metrics_schema` (default = telegraf-prometheus-v2) The chosen metrics schema to write
Expand All @@ -46,13 +46,13 @@ retry_on_failure:
max_interval: 3s
max_elapsed_time: 10s
metrics:
app_token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
app_token: 2064e37c-4fac-45f6-831d-922d43fde759
sending_queue:
enabled: true
num_consumers: 3
queue_size: 10
payload_max_lines: 100
payload_max_bytes: 1000
logs:
app_token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
app_token: 9064e37c-4gac-49f6-831d-922l43fse759
```
2 changes: 1 addition & 1 deletion exporter/sematextexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type MetricsConfig struct {
PayloadMaxBytes int `mapstructure:"payload_max_bytes"`
}
type LogsConfig struct {
// App token is the token of Sematext Monitoring App to which you want to send the logs.
// App token is the token of Sematext Logs App to which you want to send the logs.
AppToken string `mapstructure:"app_token"`
// LogsEndpoint specifies the endpoint for receiving logs in Sematext
LogsEndpoint string `mapstructure:"logs_endpoint"`
Expand Down
34 changes: 17 additions & 17 deletions exporter/sematextexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@ func TestLoadConfig(t *testing.T) {
Headers: map[string]configopaque.String{"User-Agent": "OpenTelemetry -> Sematext"},
},
MetricsConfig: MetricsConfig{
MetricsEndpoint: "https://spm-receiver.sematext.com",
MetricsEndpoint: usMetricsEndpoint,
QueueSettings: exporterhelper.QueueConfig{
Enabled: true,
NumConsumers: 3,
QueueSize: 10,
},
AppToken: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
AppToken: metricsAppToken,
MetricsSchema: "telegraf-prometheus-v2",
PayloadMaxLines: 72,
PayloadMaxBytes: 27,
},
LogsConfig: LogsConfig{
AppToken: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
LogsEndpoint: "https://logsene-receiver.sematext.com",
AppToken: logsAppToken,
LogsEndpoint: usLogsEndpoint,
},

BackOffConfig: configretry.BackOffConfig{
Expand All @@ -67,7 +67,7 @@ func TestLoadConfig(t *testing.T) {
RandomizationFactor: backoff.DefaultRandomizationFactor,
Multiplier: backoff.DefaultMultiplier,
},
Region: "us",
Region: usRegion,
},
},
}
Expand Down Expand Up @@ -95,25 +95,25 @@ func TestConfigValidation(t *testing.T) {
{
name: "Valid configuration 1",
config: &Config{
Region: "US",
Region: usRegion,
MetricsConfig: MetricsConfig{
AppToken: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
AppToken: metricsAppToken,
},
LogsConfig: LogsConfig{
AppToken: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
AppToken: logsAppToken,
},
},
expectError: false,
},
{
name: "Valid configuration 2",
config: &Config{
Region: "EU",
Region: euRegion,
MetricsConfig: MetricsConfig{
AppToken: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
AppToken: metricsAppToken,
},
LogsConfig: LogsConfig{
AppToken: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
AppToken: logsAppToken,
},
},
expectError: false,
Expand All @@ -123,33 +123,33 @@ func TestConfigValidation(t *testing.T) {
config: &Config{
Region: "ASIA",
MetricsConfig: MetricsConfig{
AppToken: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
AppToken: metricsAppToken,
},
LogsConfig: LogsConfig{
AppToken: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
AppToken: logsAppToken,
},
},
expectError: true,
},
{
name: "Invalid metrics AppToken length",
config: &Config{
Region: "US",
Region: usRegion,
MetricsConfig: MetricsConfig{
AppToken: "short-token",
},
LogsConfig: LogsConfig{
AppToken: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
AppToken: logsAppToken,
},
},
expectError: true,
},
{
name: "Invalid logs AppToken length",
config: &Config{
Region: "EU",
Region: euRegion,
MetricsConfig: MetricsConfig{
AppToken: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
AppToken: metricsAppToken,
},
LogsConfig: LogsConfig{
AppToken: "short-token",
Expand Down
2 changes: 1 addition & 1 deletion exporter/sematextexporter/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

//go:generate mdatagen metadata.yaml

// Package sematextexporter sends metrics to sematext cloud.
// Package sematextexporter sends metrics and logs to sematext cloud.
package sematextexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/sematextexporter"
15 changes: 9 additions & 6 deletions exporter/sematextexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/sematextexporter/internal/metadata"
)

const appToken string = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
const(
metricsAppToken = "2064e37c-4fac-45f6-831d-922d43fde759"
logsAppToken = "9064e37c-4gac-49f6-831d-922l43fse759"
)

// NewFactory creates a factory for the Sematext metrics exporter.
func NewFactory() exporter.Factory {
Expand All @@ -43,19 +46,19 @@ func createDefaultConfig() component.Config {
},
},
MetricsConfig: MetricsConfig{
MetricsEndpoint: "https://spm-receiver.sematext.com",
MetricsEndpoint: usMetricsEndpoint,
MetricsSchema: common.MetricsSchemaTelegrafPrometheusV2.String(),
AppToken: appToken,
AppToken: metricsAppToken,
QueueSettings: exporterhelper.NewDefaultQueueConfig(),
PayloadMaxLines: 1_000,
PayloadMaxBytes: 300_000,
},
LogsConfig: LogsConfig{
LogsEndpoint: "https://logsene-receiver.sematext.com",
AppToken: appToken,
LogsEndpoint: usLogsEndpoint,
AppToken: logsAppToken,
},
BackOffConfig: configretry.NewDefaultBackOffConfig(),
Region: "us",
Region: usRegion,
}
return cfg
}
Expand Down
4 changes: 2 additions & 2 deletions exporter/sematextexporter/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ sematext/override-config:
max_interval: 3s
max_elapsed_time: 10s
metrics:
app_token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
app_token: 2064e37c-4fac-45f6-831d-922d43fde759
sending_queue:
enabled: true
num_consumers: 3
queue_size: 10
payload_max_lines: 72
payload_max_bytes: 27
logs:
app_token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
app_token: 9064e37c-4gac-49f6-831d-922l43fse759

0 comments on commit 4b8dfa5

Please sign in to comment.