namingschematest

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2023 License: Apache-2.0, BSD-3-Clause, Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package namingschematest provides utilities to test naming schemas across different integrations.

Index

Constants

View Source
const (
	// TestDDService is a constant used in the test returned by NewServiceNameTest to set the value of DD_SERVICE.
	TestDDService = "dd-service"
	// TestServiceOverride is a constant used in the test returned by NewServiceNameTest to set the value of
	// the integration's WithServiceName option.
	TestServiceOverride = "service-override"
)

Variables

This section is empty.

Functions

func NewHTTPServerTest

func NewHTTPServerTest(genSpans GenSpansFn, defaultName string, opts ...Option) func(t *testing.T)

NewHTTPServerTest creates a new test for HTTP server naming schema.

func NewKafkaTest

func NewKafkaTest(genSpans GenSpansFn) func(t *testing.T)

NewKafkaTest creates a new test for Kafka naming schema.

func NewMongoDBTest

func NewMongoDBTest(genSpans GenSpansFn, defaultServiceName string) func(t *testing.T)

NewMongoDBTest creates a new test for MongoDB naming schema.

func NewOpNameTest

func NewOpNameTest(genSpans GenSpansFn, assertV0 AssertSpansFn, assertV1 AssertSpansFn) func(t *testing.T)

NewOpNameTest returns a new test that runs the provided assertion functions for each schema version.

func NewRedisTest

func NewRedisTest(genSpans GenSpansFn, defaultServiceName string) func(t *testing.T)

NewRedisTest creates a new test for Redis naming schema.

func NewServiceNameTest

func NewServiceNameTest(genSpans GenSpansFn, _ string, wantV0 ServiceNameAssertions) func(t *testing.T)

NewServiceNameTest generates a new test for span service names using the naming schema versioning. TODO(rarguelloF): remove the 2nd parameter as it's unused.

Types

type AssertSpansFn

type AssertSpansFn func(t *testing.T, spans []mocktracer.Span)

AssertSpansFn allows to make assertions on the generated spans.

type GenSpansFn

type GenSpansFn func(t *testing.T, serviceOverride string) []mocktracer.Span

GenSpansFn is used across different functions from this package to generate spans. It should be implemented in the tests that use this package. The provided serviceOverride string should be used to set the specific integration's WithServiceName option (if available) when initializing and configuring the package.

type Option

type Option func(*config)

Option is a type used to customize behavior of functions in this package.

func WithServiceNameAssertions

func WithServiceNameAssertions(v namingschema.Version, s ServiceNameAssertions) Option

WithServiceNameAssertions allows you to override the service name assertions for a specific naming schema version.

type ServiceNameAssertions

type ServiceNameAssertions struct {
	// WithDefaults is used for the test case where defaults are used.
	WithDefaults []string
	// WithDDService is used when the global DD_SERVICE configuration is enabled (in this case, the test will set the
	// value to TestDDService from this package).
	WithDDService []string
	// WithDDServiceAndOverride is used for the test case where the global DD_SERVICE configuration is enabled and the
	// contrib specific `WithServiceName` option is used (in this case, the test will set DD_SERVICE and serviceOverride
	// to the TestDDService and TestServiceOverride constants from this package, respectively).
	WithDDServiceAndOverride []string
}

ServiceNameAssertions contains assertions for different test cases used inside the generated test from NewServiceNameTest. []string fields in this struct represent the assertions to be made against the returned []mocktracer.Span from GenSpansFn in the same order.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL