Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pondzix committed Nov 12, 2024
1 parent a9eb3b0 commit 2ca8c97
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
5 changes: 5 additions & 0 deletions assets/docs/configuration/overview-full-example.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
30 changes: 30 additions & 0 deletions docs/configuration_metrics_docs_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
2 changes: 1 addition & 1 deletion pkg/models/observer_buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 2ca8c97

Please sign in to comment.