diff --git a/exporter/splunkhecexporter/README.md b/exporter/splunkhecexporter/README.md index bb8e967ef805..d064bd156dfb 100644 --- a/exporter/splunkhecexporter/README.md +++ b/exporter/splunkhecexporter/README.md @@ -57,7 +57,7 @@ The following configuration options can also be configured: - `otel_to_hec_fields/severity_text` (default = `otel.log.severity.text`): Specifies the name of the field to map the severity text field of log events. - `otel_to_hec_fields/severity_number` (default = `otel.log.severity.number`): Specifies the name of the field to map the severity number field of log events. - `otel_to_hec_fields/name` (default = `"otel.log.name`): Specifies the name of the field to map the name field of log events. -- `hec_heartbeat/interval` (no default): Specifies the interval of sending hec heartbeat to the destination. If not specified, heartbeat is not enabled. +- `heartbeat/interval` (no default): Specifies the interval of sending hec heartbeat to the destination. If not specified, heartbeat is not enabled. - `telemetry/enabled` (default: false): Specifies whether to enable telemetry inside splunk hec exporter. - `telemetry/override_metrics_names` (default: empty map): Specifies the metrics name to overrides in splunk hec exporter. - `telemetry/extra_attributes` (default: empty map): Specifies the extra metrics attributes in splunk hec exporter. @@ -119,7 +119,7 @@ exporters: splunk_app_name: "OpenTelemetry-Collector Splunk Exporter" # Application version is used to track telemetry information for Splunk App's using HEC by App version. splunk_app_version: "v0.0.1" - hec_heartbeat: + heartbeat: interval: 30s telemetry: enabled: true diff --git a/exporter/splunkhecexporter/client_test.go b/exporter/splunkhecexporter/client_test.go index 61589ea83a87..7eccabaf80f5 100644 --- a/exporter/splunkhecexporter/client_test.go +++ b/exporter/splunkhecexporter/client_test.go @@ -1515,7 +1515,7 @@ func TestAllowedLogDataTypes(t *testing.T) { func Test_heartbeat_success(t *testing.T) { config := NewFactory().CreateDefaultConfig().(*Config) - config.HecHeartbeat = HecHeartbeat{ + config.Heartbeat = HecHeartbeat{ Interval: 10 * time.Millisecond, } diff --git a/exporter/splunkhecexporter/config.go b/exporter/splunkhecexporter/config.go index 5bcf5ebde10b..c0e514768b4c 100644 --- a/exporter/splunkhecexporter/config.go +++ b/exporter/splunkhecexporter/config.go @@ -139,11 +139,11 @@ type Config struct { // UseMultiMetricFormat combines metric events to save space during ingestion. UseMultiMetricFormat bool `mapstructure:"use_multi_metric_format"` - // HecHeartbeat is the configuration to enable heartbeat - HecHeartbeat HecHeartbeat `mapstructure:"hec_heartbeat"` + // Heartbeat is the configuration to enable heartbeat + Heartbeat HecHeartbeat `mapstructure:"heartbeat"` - // HecTelemetry is the configuration for splunk hec exporter telemetry - HecTelemetry HecTelemetry `mapstructure:"telemetry"` + // Telemetry is the configuration for splunk hec exporter telemetry + Telemetry HecTelemetry `mapstructure:"telemetry"` } func (cfg *Config) getURL() (out *url.URL, err error) { diff --git a/exporter/splunkhecexporter/config_test.go b/exporter/splunkhecexporter/config_test.go index 36983472d7e5..f5fbfeb0c714 100644 --- a/exporter/splunkhecexporter/config_test.go +++ b/exporter/splunkhecexporter/config_test.go @@ -109,10 +109,10 @@ func TestLoadConfig(t *testing.T) { }, HealthPath: "/services/collector/health", HecHealthCheckEnabled: false, - HecHeartbeat: HecHeartbeat{ + Heartbeat: HecHeartbeat{ Interval: 30 * time.Second, }, - HecTelemetry: HecTelemetry{ + Telemetry: HecTelemetry{ Enabled: true, OverrideMetricsNames: map[string]string{ "otelcol_exporter_splunkhec_heartbeat_sent": "app_heartbeats_success_total", diff --git a/exporter/splunkhecexporter/factory.go b/exporter/splunkhecexporter/factory.go index c47a6272e2f9..47fbd1e32ebb 100644 --- a/exporter/splunkhecexporter/factory.go +++ b/exporter/splunkhecexporter/factory.go @@ -94,7 +94,7 @@ func createDefaultConfig() component.Config { HealthPath: splunk.DefaultHealthPath, HecHealthCheckEnabled: false, ExportRaw: false, - HecTelemetry: HecTelemetry{ + Telemetry: HecTelemetry{ Enabled: false, OverrideMetricsNames: map[string]string{}, ExtraAttributes: map[string]string{}, diff --git a/exporter/splunkhecexporter/factory_test.go b/exporter/splunkhecexporter/factory_test.go index 310d8737f9d2..4200988acaae 100644 --- a/exporter/splunkhecexporter/factory_test.go +++ b/exporter/splunkhecexporter/factory_test.go @@ -39,7 +39,6 @@ func TestCreateMetricsExporter(t *testing.T) { params := exportertest.NewNopCreateSettings() _, err := createMetricsExporter(context.Background(), params, cfg) assert.NoError(t, err) - assert.NoError(t, err) } func TestCreateTracesExporter(t *testing.T) { diff --git a/exporter/splunkhecexporter/heartbeat.go b/exporter/splunkhecexporter/heartbeat.go index 8df954707c63..4538cd919f16 100644 --- a/exporter/splunkhecexporter/heartbeat.go +++ b/exporter/splunkhecexporter/heartbeat.go @@ -30,9 +30,9 @@ import ( ) const ( - metricsPrefix = "otelcol_exporter_splunkhec_heartbeat" - defaultHBSentMetricsName = metricsPrefix + "_sent" - defaultHBFailedMetricsName = metricsPrefix + "_failed" + metricsPrefix = "otelcol_exporter_splunkhec_" + defaultHBSentMetricsName = metricsPrefix + "heartbeat_sent" + defaultHBFailedMetricsName = metricsPrefix + "heartbeat_failed" ) type heartbeater struct { @@ -55,16 +55,16 @@ func getMetricsName(overrides map[string]string, metricName string) string { } func newHeartbeater(config *Config, pushLogFn func(ctx context.Context, ld plog.Logs) error) *heartbeater { - interval := config.HecHeartbeat.Interval + interval := config.Heartbeat.Interval if interval == 0 { return nil } - var heartbeatSentTotal, heartbeatFailedTotal *stats.Int64Measure + var heartbeatSent, heartbeatFailed *stats.Int64Measure var tagMutators []tag.Mutator - if config.HecTelemetry.Enabled { - overrides := config.HecTelemetry.OverrideMetricsNames - extraAttributes := config.HecTelemetry.ExtraAttributes + if config.Telemetry.Enabled { + overrides := config.Telemetry.OverrideMetricsNames + extraAttributes := config.Telemetry.ExtraAttributes var tags []tag.Key tagMutators = []tag.Mutator{} for key, val := range extraAttributes { @@ -73,33 +73,33 @@ func newHeartbeater(config *Config, pushLogFn func(ctx context.Context, ld plog. tagMutators = append(tagMutators, tag.Insert(newTag, val)) } - heartbeatSentTotal = stats.Int64( + heartbeatSent = stats.Int64( getMetricsName(overrides, defaultHBSentMetricsName), - "number of heartbeats made to the destination", + "number of heartbeats sent", stats.UnitDimensionless) - heartbeatSuccessTotalView := &view.View{ - Name: heartbeatSentTotal.Name(), - Description: heartbeatSentTotal.Description(), + heartbeatSentView := &view.View{ + Name: heartbeatSent.Name(), + Description: heartbeatSent.Description(), TagKeys: tags, - Measure: heartbeatSentTotal, + Measure: heartbeatSent, Aggregation: view.Sum(), } - heartbeatFailedTotal = stats.Int64( + heartbeatFailed = stats.Int64( getMetricsName(overrides, defaultHBFailedMetricsName), - "number of heartbeats made to destination that failed", + "number of heartbeats failed", stats.UnitDimensionless) - heartbeatErrorTotalView := &view.View{ - Name: heartbeatFailedTotal.Name(), - Description: heartbeatFailedTotal.Description(), + heartbeatFailedView := &view.View{ + Name: heartbeatFailed.Name(), + Description: heartbeatFailed.Description(), TagKeys: tags, - Measure: heartbeatFailedTotal, + Measure: heartbeatFailed, Aggregation: view.Sum(), } - if err := view.Register(heartbeatSuccessTotalView, heartbeatErrorTotalView); err != nil { + if err := view.Register(heartbeatSentView, heartbeatFailedView); err != nil { return nil } } @@ -108,8 +108,8 @@ func newHeartbeater(config *Config, pushLogFn func(ctx context.Context, ld plog. config: config, pushLogFn: pushLogFn, hbDoneChan: make(chan struct{}), - heartbeatSuccessTotal: heartbeatSentTotal, - heartbeatErrorTotal: heartbeatFailedTotal, + heartbeatSuccessTotal: heartbeatSent, + heartbeatErrorTotal: heartbeatFailed, tagMutators: tagMutators, } } @@ -119,7 +119,7 @@ func (h *heartbeater) shutdown() { } func (h *heartbeater) initHeartbeat(buildInfo component.BuildInfo) { - interval := h.config.HecHeartbeat.Interval + interval := h.config.Heartbeat.Interval if interval == 0 { return } @@ -143,7 +143,7 @@ func (h *heartbeater) initHeartbeat(buildInfo component.BuildInfo) { // there is only use case for open census metrics recording for now. Extend to use open telemetry in the future. func (h *heartbeater) observe(err error) { - if !h.config.HecTelemetry.Enabled { + if !h.config.Telemetry.Enabled { return } diff --git a/exporter/splunkhecexporter/heartbeat_test.go b/exporter/splunkhecexporter/heartbeat_test.go index 0cdd81810c8f..cd8e5678bf38 100644 --- a/exporter/splunkhecexporter/heartbeat_test.go +++ b/exporter/splunkhecexporter/heartbeat_test.go @@ -34,10 +34,10 @@ const ( func createTestConfig(metricsOverrides map[string]string, enableMetrics bool) *Config { config := NewFactory().CreateDefaultConfig().(*Config) - config.HecHeartbeat = HecHeartbeat{ + config.Heartbeat = HecHeartbeat{ Interval: 10 * time.Millisecond, } - config.HecTelemetry = HecTelemetry{ + config.Telemetry = HecTelemetry{ Enabled: enableMetrics, OverrideMetricsNames: metricsOverrides, ExtraAttributes: map[string]string{ @@ -93,7 +93,7 @@ func resetMetrics(metricsNames ...string) { func Test_newHeartbeater_disabled(t *testing.T) { config := createTestConfig(map[string]string{}, false) - config.HecHeartbeat.Interval = 0 + config.Heartbeat.Interval = 0 hb := newHeartbeater(config, func(ctx context.Context, ld plog.Logs) error { return nil }) diff --git a/exporter/splunkhecexporter/testdata/config.yaml b/exporter/splunkhecexporter/testdata/config.yaml index f78def12c68b..92d882fc830f 100644 --- a/exporter/splunkhecexporter/testdata/config.yaml +++ b/exporter/splunkhecexporter/testdata/config.yaml @@ -36,7 +36,7 @@ splunk_hec/allsettings: otel_to_hec_fields: severity_text: "myseverityfield" severity_number: "myseveritynumfield" - hec_heartbeat: + heartbeat: interval: 30s telemetry: enabled: true