diff --git a/assets/docs/configuration/overview-full-example.hcl b/assets/docs/configuration/overview-full-example.hcl index a2e13703..61f245a7 100644 --- a/assets/docs/configuration/overview-full-example.hcl +++ b/assets/docs/configuration/overview-full-example.hcl @@ -108,6 +108,11 @@ retry { } } +metrics { + # Optional toggle for E2E latency (difference between Snowplow collector timestamp and target write timestamp) + enable_e2e_latency = true +} + license { accept = true } diff --git a/config/config.go b/config/config.go index d1634e16..41dec9ea 100644 --- a/config/config.go +++ b/config/config.go @@ -56,7 +56,7 @@ type configurationData struct { DisableTelemetry bool `hcl:"disable_telemetry,optional"` License *licenseConfig `hcl:"license,block"` Retry *retryConfig `hcl:"retry,block"` - Metrics *metricsConfig `hcl:"metrics,block` + Metrics *metricsConfig `hcl:"metrics,block"` } // component is a type to abstract over configuration blocks. diff --git a/docs/configuration_metrics_docs_test.go b/docs/configuration_metrics_docs_test.go new file mode 100644 index 00000000..248d214f --- /dev/null +++ b/docs/configuration_metrics_docs_test.go @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2020-present Snowplow Analytics Ltd. + * All rights reserved. + * + * This software is made available by Snowplow Analytics, Ltd., + * under the terms of the Snowplow Limited Use License Agreement, Version 1.0 + * located at https://docs.snowplow.io/limited-use-license-1.0 + * BY INSTALLING, DOWNLOADING, ACCESSING, USING OR DISTRIBUTING ANY PORTION + * OF THE SOFTWARE, YOU AGREE TO THE TERMS OF SUCH LICENSE AGREEMENT. + */ + +package docs + +import ( + "path/filepath" + "testing" + + "github.com/snowplow/snowbridge/assets" + "github.com/stretchr/testify/assert" +) + +func TestMetricsConfigDocumentation(t *testing.T) { + assert := assert.New(t) + configPath := filepath.Join(assets.AssetsRootDir, "docs", "configuration", "metrics", "e2e-latency-example.hcl") + c := getConfigFromFilepath(t, configPath) + + metricsConfig := c.Data.Metrics + assert.NotNil(metricsConfig) + assert.Equal(true, metricsConfig.E2ELatencyEnabled) +} diff --git a/pkg/models/observer_buffer.go b/pkg/models/observer_buffer.go index e9f5fd5d..a5e2d133 100644 --- a/pkg/models/observer_buffer.go +++ b/pkg/models/observer_buffer.go @@ -191,7 +191,7 @@ func (b *ObserverBuffer) GetAvgRequestLatency() time.Duration { return common.GetAverageFromDuration(b.SumRequestLatency, b.MsgTotal) } -// GetAvgRequestLatency calculates average request latency +// GetAvgE2ELatency calculates average E2E latency func (b *ObserverBuffer) GetAvgE2ELatency() time.Duration { return common.GetAverageFromDuration(b.SumE2ELatency, b.MsgTotal) }