Documentation
¶
Index ¶
- Constants
- Variables
- func ConvertResourceMetrics(pdataMetrics pmetric.Metrics) []*metricdata.ResourceMetrics
- func NewTestExporterSettings(logger *zap.Logger, meterProvider metric.MeterProvider) exporter.Settings
- func NormalizeLogFixture(t testing.TB, fixture *protos.LogExpectFixture)
- func NormalizeMetricFixture(t testing.TB, fixture *protos.MetricExpectFixture)
- func NormalizeTraceFixture(t testing.TB, fixture *protos.TraceExpectFixture)
- func SetTestUserAgent(cfg *collector.Config, buildInfo component.BuildInfo)
- func UserAgentRemoveRuntimeInfo(userAgent string) string
- type TestCase
- func (tc *TestCase) CreateCollectorMetricConfig() collector.Config
- func (tc *TestCase) CreateLogConfig() collector.Config
- func (tc *TestCase) CreateTraceConfig() collector.Config
- func (tc *TestCase) LoadLogExpectFixture(t testing.TB, timestamp time.Time) *protos.LogExpectFixture
- func (tc *TestCase) LoadMetricFixture(t testing.TB, path string, startTime time.Time, endTime time.Time) *protos.MetricExpectFixture
- func (tc *TestCase) LoadOTLPLogsInput(t testing.TB, timestamp time.Time) plog.Logs
- func (tc *TestCase) LoadOTLPMetricsInput(t testing.TB, startTime time.Time, endTime time.Time) pmetric.Metrics
- func (tc *TestCase) LoadOTLPTracesInput(t testing.TB, startTimestamp time.Time, endTimestamp time.Time) ptrace.Traces
- func (tc *TestCase) LoadTraceExpectFixture(t testing.TB, startTimestamp time.Time, endTimestamp time.Time) *protos.TraceExpectFixture
- func (tc *TestCase) SaveRecordedLogFixtures(t testing.TB, fixture *protos.LogExpectFixture)
- func (tc *TestCase) SaveRecordedMetricFixtures(t testing.TB, fixture *protos.MetricExpectFixture)
- func (tc *TestCase) SaveRecordedTraceFixtures(t testing.TB, fixture *protos.TraceExpectFixture)
- func (tc *TestCase) SkipIfNeeded(t testing.TB)
- func (tc *TestCase) SkipIfNeededForSDK(t testing.TB)
Constants ¶
View Source
const SecondProjectEnv = "SECOND_PROJECT_ID"
Variables ¶
View Source
var LogsTestCases = []TestCase{ { Name: "Apache access log with HTTPRequest", OTLPInputFixturePath: "testdata/fixtures/logs/logs_apache_access.json", ExpectFixturePath: "testdata/fixtures/logs/logs_apache_access_expected.json", }, { Name: "Apache error log with severity", OTLPInputFixturePath: "testdata/fixtures/logs/logs_apache_error.json", ExpectFixturePath: "testdata/fixtures/logs/logs_apache_error_expected.json", }, { Name: "Apache error log (text payload) with severity converted to Error Reporting type", OTLPInputFixturePath: "testdata/fixtures/logs/logs_apache_text_error.json", ExpectFixturePath: "testdata/fixtures/logs/logs_apache_text_error_reporting_expected.json", ConfigureCollector: func(cfg *collector.Config) { cfg.LogConfig.ErrorReportingType = true }, }, { Name: "Apache error log (json payload) with severity converted to Error Reporting type", OTLPInputFixturePath: "testdata/fixtures/logs/logs_apache_error.json", ExpectFixturePath: "testdata/fixtures/logs/logs_apache_json_error_reporting_expected.json", ConfigureCollector: func(cfg *collector.Config) { cfg.LogConfig.ErrorReportingType = true }, }, { Name: "Multi-project logs", OTLPInputFixturePath: "testdata/fixtures/logs/logs_multi_project.json", ExpectFixturePath: "testdata/fixtures/logs/logs_multi_project_expected.json", }, { Name: "Multi-project logs with destination_project_quota enabled", OTLPInputFixturePath: "testdata/fixtures/logs/logs_multi_project.json", ExpectFixturePath: "testdata/fixtures/logs/logs_multi_project_destination_quota_expected.json", ConfigureCollector: func(cfg *collector.Config) { cfg.DestinationProjectQuota = true }, }, { Name: "Logs with scope information", OTLPInputFixturePath: "testdata/fixtures/logs/logs_apache_error_scope.json", ExpectFixturePath: "testdata/fixtures/logs/logs_apache_error_scope_expected.json", }, { Name: "Logs with trace/span info", OTLPInputFixturePath: "testdata/fixtures/logs/logs_span_trace_id.json", ExpectFixturePath: "testdata/fixtures/logs/logs_span_trace_id_expected.json", }, { Name: "Logs with additional resource attributes", OTLPInputFixturePath: "testdata/fixtures/logs/logs_apache_access_resource_attributes.json", ExpectFixturePath: "testdata/fixtures/logs/logs_apache_access_resource_attributes_expected.json", ConfigureCollector: func(cfg *collector.Config) { cfg.LogConfig.ResourceFilters = []collector.ResourceFilter{ {Prefix: "custom."}, } }, }, { Name: "Logs with multiple batches", OTLPInputFixturePath: "testdata/fixtures/logs/logs_apache_access.json", ExpectFixturePath: "testdata/fixtures/logs/logs_apache_access_batches_expected.json", ConfigureLogsExporter: &logsutil.ExporterConfig{ MaxEntrySize: 50, MaxRequestSize: 550, }, }, { Name: "Logs custom user-agent", OTLPInputFixturePath: "testdata/fixtures/logs/logs_span_trace_id.json", ExpectFixturePath: "testdata/fixtures/logs/logs_user_agent_expected.json", ConfigureCollector: func(cfg *collector.Config) { cfg.UserAgent = "custom-user-agent {{version}}" }, }, }
View Source
var MetricsTestCases = []TestCase{ { Name: "Sum becomes a GCM Cumulative", OTLPInputFixturePath: "testdata/fixtures/metrics/counter.json", ExpectFixturePath: "testdata/fixtures/metrics/counter_expect.json", ConfigureCollector: func(cfg *collector.Config) { cfg.MetricConfig.InstrumentationLibraryLabels = true cfg.MetricConfig.ServiceResourceLabels = false }, MetricSDKExporterOptions: []metric.Option{metric.WithFilteredResourceAttributes(metric.NoAttributes)}, }, { Name: "Delta Sum becomes a GCM cumulative", OTLPInputFixturePath: "testdata/fixtures/metrics/delta_counter.json", ExpectFixturePath: "testdata/fixtures/metrics/delta_counter_expect.json", ConfigureCollector: func(cfg *collector.Config) { cfg.MetricConfig.ServiceResourceLabels = false }, MetricSDKExporterOptions: []metric.Option{metric.WithFilteredResourceAttributes(metric.NoAttributes)}, }, { Name: "Non-monotonic Sum becomes a GCM Gauge", OTLPInputFixturePath: "testdata/fixtures/metrics/nonmonotonic_counter.json", ExpectFixturePath: "testdata/fixtures/metrics/nonmonotonic_counter_expect.json", ConfigureCollector: func(cfg *collector.Config) { cfg.MetricConfig.ServiceResourceLabels = false }, MetricSDKExporterOptions: []metric.Option{metric.WithFilteredResourceAttributes(metric.NoAttributes)}, }, { Name: "Summary becomes a GCM Cumulative for sum/count, Gauges for quantiles", OTLPInputFixturePath: "testdata/fixtures/metrics/summary.json", ExpectFixturePath: "testdata/fixtures/metrics/summary_expect.json", ConfigureCollector: func(cfg *collector.Config) { cfg.MetricConfig.ServiceResourceLabels = false }, SkipForSDK: true, }, { Name: "Gauge becomes a GCM Gauge", OTLPInputFixturePath: "testdata/fixtures/metrics/gauge.json", ExpectFixturePath: "testdata/fixtures/metrics/gauge_expect.json", ConfigureCollector: func(cfg *collector.Config) { cfg.MetricConfig.InstrumentationLibraryLabels = true cfg.MetricConfig.ServiceResourceLabels = false }, MetricSDKExporterOptions: []metric.Option{metric.WithFilteredResourceAttributes(metric.NoAttributes)}, }, { Name: "Boolean-valued Gauge metric becomes an Int Gauge", OTLPInputFixturePath: "testdata/fixtures/metrics/boolean_gauge.json", ExpectFixturePath: "testdata/fixtures/metrics/boolean_gauge_expect.json", ConfigureCollector: func(cfg *collector.Config) { cfg.MetricConfig.ServiceResourceLabels = false }, SkipForSDK: true, }, { Name: "Gauge with Untyped label is a standard GCM Gauge without GMP", OTLPInputFixturePath: "testdata/fixtures/metrics/untyped_gauge.json", ExpectFixturePath: "testdata/fixtures/metrics/untyped_gauge_expect.json", ConfigureCollector: func(cfg *collector.Config) { cfg.MetricConfig.ServiceResourceLabels = false }, SkipForSDK: true, }, { Name: "Histogram becomes a GCM Distribution", OTLPInputFixturePath: "testdata/fixtures/metrics/histogram.json", ExpectFixturePath: "testdata/fixtures/metrics/histogram_expect.json", ConfigureCollector: func(cfg *collector.Config) { cfg.MetricConfig.ServiceResourceLabels = false cfg.MetricConfig.InstrumentationLibraryLabels = true cfg.MetricConfig.EnableSumOfSquaredDeviation = true }, MetricSDKExporterOptions: []metric.Option{ metric.WithFilteredResourceAttributes(metric.NoAttributes), metric.WithSumOfSquaredDeviation(), }, }, { Name: "Exponential Histogram becomes a GCM Distribution with exponential bucketOptions", OTLPInputFixturePath: "testdata/fixtures/metrics/exponential_histogram.json", ExpectFixturePath: "testdata/fixtures/metrics/exponential_histogram_expect.json", ConfigureCollector: func(cfg *collector.Config) { cfg.MetricConfig.ServiceResourceLabels = false }, SkipForSDK: true, }, { Name: "Metrics from the Prometheus receiver can be successfully delivered", OTLPInputFixturePath: "testdata/fixtures/metrics/prometheus.json", ExpectFixturePath: "testdata/fixtures/metrics/prometheus_expect.json", ConfigureCollector: func(cfg *collector.Config) { cfg.MetricConfig.EnableSumOfSquaredDeviation = true }, MetricSDKExporterOptions: []metric.Option{ metric.WithSumOfSquaredDeviation(), }, }, { Name: "Prometheus stale data point is dropped", OTLPInputFixturePath: "testdata/fixtures/metrics/prometheus_stale.json", ExpectFixturePath: "testdata/fixtures/metrics/prometheus_stale_expect.json", CompareFixturePath: "testdata/fixtures/metrics/prometheus_expect.json", ConfigureCollector: func(cfg *collector.Config) { cfg.MetricConfig.EnableSumOfSquaredDeviation = true }, SkipForSDK: true, }, { Name: "Project not found return code", OTLPInputFixturePath: "testdata/fixtures/metrics/counter.json", ExpectFixturePath: "testdata/fixtures/metrics/counter_notfound_expect.json", ConfigureCollector: func(cfg *collector.Config) { cfg.ProjectID = "notfoundproject" cfg.MetricConfig.ServiceResourceLabels = false }, MetricSDKExporterOptions: []metric.Option{metric.WithProjectID("notfoundproject"), metric.WithFilteredResourceAttributes(metric.NoAttributes)}, ExpectErr: true, }, { Name: "Modified prefix unknown domain", OTLPInputFixturePath: "testdata/fixtures/metrics/counter.json", ExpectFixturePath: "testdata/fixtures/metrics/counter_unknown_domain_expect.json", ConfigureCollector: func(cfg *collector.Config) { cfg.MetricConfig.Prefix = "custom.googleapis.com/foobar.org" cfg.MetricConfig.ServiceResourceLabels = false }, MetricSDKExporterOptions: []metric.Option{ metric.WithMetricDescriptorTypeFormatter(func(m metricdata.Metrics) string { return "custom.googleapis.com/foobar.org/" + m.Name }), metric.WithFilteredResourceAttributes(metric.NoAttributes), }, }, { Name: "Modified prefix workload.googleapis.com", OTLPInputFixturePath: "testdata/fixtures/metrics/counter.json", ExpectFixturePath: "testdata/fixtures/metrics/counter_workloadgoogleapis_prefix_expect.json", ConfigureCollector: func(cfg *collector.Config) { cfg.MetricConfig.Prefix = "workload.googleapis.com" cfg.MetricConfig.ServiceResourceLabels = false }, MetricSDKExporterOptions: []metric.Option{metric.WithFilteredResourceAttributes(metric.NoAttributes)}, }, { Name: "Batching only sends 200 timeseries per-batch", OTLPInputFixturePath: "testdata/fixtures/metrics/batching.json", ExpectFixturePath: "testdata/fixtures/metrics/batching_expect.json", SkipForSDK: true, }, { Name: "WithResourceFilter adds the appropriate resource attributes", OTLPInputFixturePath: "testdata/fixtures/metrics/with_resource_filter.json", ExpectFixturePath: "testdata/fixtures/metrics/with_resource_filter_expect.json", ConfigureCollector: func(cfg *collector.Config) { cfg.MetricConfig.ResourceFilters = []collector.ResourceFilter{ {Prefix: "telemetry.sdk."}, } }, MetricSDKExporterOptions: []metric.Option{ metric.WithFilteredResourceAttributes(func(kv attribute.KeyValue) bool { if metric.DefaultResourceAttributesFilter(kv) { return true } return strings.HasPrefix(string(kv.Key), "telemetry.sdk.") }), }, }, { Name: "Multi-project metrics splits into multiple requests to different projects", OTLPInputFixturePath: "testdata/fixtures/metrics/multi_project.json", ExpectFixturePath: "testdata/fixtures/metrics/multi_project_expected.json", SkipForSDK: true, }, { Name: "Metrics with only one +inf bucket can be sent", OTLPInputFixturePath: "testdata/fixtures/metrics/prometheus_empty_buckets.json", ExpectFixturePath: "testdata/fixtures/metrics/prometheus_empty_buckets_expected.json", SkipForSDK: true, }, { Name: "Gzip compression enabled", OTLPInputFixturePath: "testdata/fixtures/metrics/counter.json", ExpectFixturePath: "testdata/fixtures/metrics/counter_compressed_expect.json", ConfigureCollector: func(cfg *collector.Config) { cfg.MetricConfig.ClientConfig.Compression = "gzip" cfg.MetricConfig.ServiceResourceLabels = false }, SkipForSDK: true, }, { Name: "CreateServiceTimeSeries option enabled makes CreateServiceTimeSeries calls", OTLPInputFixturePath: "testdata/fixtures/metrics/create_service_timeseries.json", ExpectFixturePath: "testdata/fixtures/metrics/create_service_timeseries_expect.json", ConfigureCollector: func(cfg *collector.Config) { cfg.MetricConfig.CreateServiceTimeSeries = true }, SkipForSDK: true, }, { Name: "Write ahead log enabled", OTLPInputFixturePath: "testdata/fixtures/metrics/counter.json", ExpectFixturePath: "testdata/fixtures/metrics/counter_wal_expect.json", CompareFixturePath: "testdata/fixtures/metrics/counter_expect.json", ConfigureCollector: func(cfg *collector.Config) { dir, _ := os.MkdirTemp("", "test-wal-") cfg.MetricConfig.WALConfig = &collector.WALConfig{ Directory: dir, MaxBackoff: time.Duration(1 * time.Second), } cfg.MetricConfig.ServiceResourceLabels = false }, SkipForSDK: true, }, { Name: "Write ahead log enabled, basic prometheus metrics", OTLPInputFixturePath: "testdata/fixtures/metrics/prometheus.json", ExpectFixturePath: "testdata/fixtures/metrics/prometheus_wal_expect.json", CompareFixturePath: "testdata/fixtures/metrics/prometheus_expect.json", ConfigureCollector: func(cfg *collector.Config) { dir, _ := os.MkdirTemp("", "test-wal-") cfg.MetricConfig.WALConfig = &collector.WALConfig{ Directory: dir, MaxBackoff: time.Duration(1 * time.Second), } cfg.MetricConfig.EnableSumOfSquaredDeviation = true }, SkipForSDK: true, }, { Name: "Write ahead log enabled, basic Counter with unavailable return code", OTLPInputFixturePath: "testdata/fixtures/metrics/counter.json", ExpectFixturePath: "testdata/fixtures/metrics/counter_wal_unavailable_expect.json", ConfigureCollector: func(cfg *collector.Config) { cfg.ProjectID = "unavailableproject" dir, _ := os.MkdirTemp("", "test-wal-") cfg.MetricConfig.WALConfig = &collector.WALConfig{ Directory: dir, MaxBackoff: time.Duration(2 * time.Second), } cfg.MetricConfig.ServiceResourceLabels = false }, SkipForSDK: true, ExpectRetries: true, }, { Name: "Write ahead log enabled, basic Counter with deadline_exceeded return code", OTLPInputFixturePath: "testdata/fixtures/metrics/counter.json", ExpectFixturePath: "testdata/fixtures/metrics/counter_wal_deadline_expect.json", ConfigureCollector: func(cfg *collector.Config) { cfg.ProjectID = "deadline_exceededproject" dir, _ := os.MkdirTemp("", "test-wal-") cfg.MetricConfig.WALConfig = &collector.WALConfig{ Directory: dir, MaxBackoff: time.Duration(2 * time.Second), } cfg.MetricConfig.ServiceResourceLabels = false }, SkipForSDK: true, ExpectRetries: true, }, { Name: "Write ahead log enabled, CreateServiceTimeSeries", OTLPInputFixturePath: "testdata/fixtures/metrics/create_service_timeseries.json", ExpectFixturePath: "testdata/fixtures/metrics/create_service_timeseries_wal_expect.json", ConfigureCollector: func(cfg *collector.Config) { cfg.MetricConfig.CreateServiceTimeSeries = true dir, _ := os.MkdirTemp("", "test-wal-") cfg.MetricConfig.WALConfig = &collector.WALConfig{ Directory: dir, MaxBackoff: time.Duration(1 * time.Second), } }, SkipForSDK: true, }, { Name: "Custom User Agent", OTLPInputFixturePath: "testdata/fixtures/metrics/counter.json", ExpectFixturePath: "testdata/fixtures/metrics/counter_user_agent_expect.json", ConfigureCollector: func(cfg *collector.Config) { cfg.UserAgent = "custom-user-agent" }, MetricSDKExporterOptions: []metric.Option{ metric.WithMonitoringClientOptions(option.WithGRPCDialOption(grpc.WithUserAgent("custom-user-agent"))), }, }, { Name: "[GMP] prometheus receiver metrics", OTLPInputFixturePath: "testdata/fixtures/metrics/google_managed_prometheus.json", ExpectFixturePath: "testdata/fixtures/metrics/google_managed_prometheus_expect.json", ConfigureCollector: configureGMPCollector, SkipForSDK: true, }, { Name: "[GMP] Gauge becomes a GCM Gauge with /gauge suffix", OTLPInputFixturePath: "testdata/fixtures/metrics/gauge.json", ExpectFixturePath: "testdata/fixtures/metrics/gauge_gmp_expect.json", ConfigureCollector: configureGMPCollector, SkipForSDK: true, }, { Name: "[GMP] Untyped Gauge becomes a GCM Gauge and a Cumulative with /unknown and /unknown:counter suffixes", OTLPInputFixturePath: "testdata/fixtures/metrics/untyped_gauge.json", ExpectFixturePath: "testdata/fixtures/metrics/untyped_gauge_gmp_expect.json", ConfigureCollector: configureGMPCollector, SkipForSDK: true, }, { Name: "[GMP] Sum becomes a GCM Cumulative with /counter suffix", OTLPInputFixturePath: "testdata/fixtures/metrics/counter.json", ExpectFixturePath: "testdata/fixtures/metrics/counter_gmp_expect.json", ConfigureCollector: configureGMPCollector, SkipForSDK: true, }, { Name: "[GMP] Delta Sum becomes a GCM Cumulative with a /counter suffix", OTLPInputFixturePath: "testdata/fixtures/metrics/delta_counter.json", ExpectFixturePath: "testdata/fixtures/metrics/delta_counter_gmp_expect.json", ConfigureCollector: configureGMPCollector, SkipForSDK: true, }, { Name: "[GMP] Non-Monotonic Sum becomes a GCM Gauge with a /gauge suffix", OTLPInputFixturePath: "testdata/fixtures/metrics/nonmonotonic_counter.json", ExpectFixturePath: "testdata/fixtures/metrics/nonmonotonic_counter_gmp_expect.json", ConfigureCollector: configureGMPCollector, SkipForSDK: true, }, { Name: "[GMP] Histogram becomes a GCM Histogram with a /histogram suffix", OTLPInputFixturePath: "testdata/fixtures/metrics/histogram.json", ExpectFixturePath: "testdata/fixtures/metrics/histogram_gmp_expect.json", ConfigureCollector: configureGMPCollector, SkipForSDK: true, }, { Name: "[GMP] Exponential Histogram becomes a GCM Distribution with exponential bucketOptions and a /histogram suffix", OTLPInputFixturePath: "testdata/fixtures/metrics/exponential_histogram.json", ExpectFixturePath: "testdata/fixtures/metrics/exponential_histogram_gmp_expect.json", ConfigureCollector: configureGMPCollector, SkipForSDK: true, }, { Name: "[GMP] Summary becomes a GCM Cumulative for sum/count, Gauges for quantiles", OTLPInputFixturePath: "testdata/fixtures/metrics/summary.json", ExpectFixturePath: "testdata/fixtures/metrics/summary_gmp_expect.json", ConfigureCollector: configureGMPCollector, SkipForSDK: true, }, { Name: "Ops Agent Self-Reported metrics", OTLPInputFixturePath: "testdata/fixtures/metrics/ops_agent_self_metrics.json", ExpectFixturePath: "testdata/fixtures/metrics/ops_agent_self_metrics_expect.json", ConfigureCollector: func(cfg *collector.Config) { cfg.MetricConfig.SkipCreateMetricDescriptor = true cfg.MetricConfig.ServiceResourceLabels = false }, SkipForSDK: true, }, { Name: "Ops Agent Host Metrics", OTLPInputFixturePath: "testdata/fixtures/metrics/ops_agent_host_metrics.json", ExpectFixturePath: "testdata/fixtures/metrics/ops_agent_host_metrics_expect.json", ConfigureCollector: func(cfg *collector.Config) { cfg.MetricConfig.SkipCreateMetricDescriptor = true }, SkipForSDK: true, }, { Name: "GKE Workload Metrics", OTLPInputFixturePath: "testdata/fixtures/metrics/workload_metrics.json", ExpectFixturePath: "testdata/fixtures/metrics/workload_metrics_expect.json", ConfigureCollector: func(cfg *collector.Config) { cfg.MetricConfig.Prefix = "workload.googleapis.com/" cfg.MetricConfig.SkipCreateMetricDescriptor = true cfg.MetricConfig.ServiceResourceLabels = false }, SkipForSDK: true, }, { Name: "GKE Metrics Agent", OTLPInputFixturePath: "testdata/fixtures/metrics/gke_metrics_agent.json", ExpectFixturePath: "testdata/fixtures/metrics/gke_metrics_agent_expect.json", ConfigureCollector: func(cfg *collector.Config) { cfg.MetricConfig.CreateServiceTimeSeries = true }, SkipForSDK: true, }, { Name: "GKE Control Plane Metrics Agent", OTLPInputFixturePath: "testdata/fixtures/metrics/gke_control_plane.json", ExpectFixturePath: "testdata/fixtures/metrics/gke_control_plane_expect.json", ConfigureCollector: func(cfg *collector.Config) { cfg.MetricConfig.CreateServiceTimeSeries = true cfg.MetricConfig.ServiceResourceLabels = false }, SkipForSDK: true, }, { Name: "BMS Ops Agent Host Metrics", OTLPInputFixturePath: "testdata/fixtures/metrics/bms_ops_agent_host_metrics.json", ExpectFixturePath: "testdata/fixtures/metrics/bms_ops_agent_host_metrics_expect.json", ConfigureCollector: func(cfg *collector.Config) { cfg.MetricConfig.SkipCreateMetricDescriptor = true }, SkipForSDK: true, }, }
View Source
var TracesTestCases = []TestCase{ { Name: "Basic traces", OTLPInputFixturePath: "testdata/fixtures/traces/traces_basic.json", ExpectFixturePath: "testdata/fixtures/traces/traces_basic_expected.json", }, { Name: "Custom User Agent", OTLPInputFixturePath: "testdata/fixtures/traces/traces_basic.json", ExpectFixturePath: "testdata/fixtures/traces/traces_user_agent_expected.json", ConfigureCollector: func(cfg *collector.Config) { cfg.UserAgent = "custom-user-agent {{version}}" }, }, }
Functions ¶
func ConvertResourceMetrics ¶
func ConvertResourceMetrics(pdataMetrics pmetric.Metrics) []*metricdata.ResourceMetrics
ConvertResourceMetrics converts a (collector) pdata metrics to an SDK ResourceMetrics This is useful for testing the SDK with the same data used to test the collector.
func NewTestExporterSettings ¶ added in v0.51.0
func NormalizeLogFixture ¶
func NormalizeLogFixture(t testing.TB, fixture *protos.LogExpectFixture)
Normalizes timestamps which create noise in the fixture because they can vary each test run.
func NormalizeMetricFixture ¶
func NormalizeMetricFixture(t testing.TB, fixture *protos.MetricExpectFixture)
Normalizes timestamps which create noise in the fixture because they can vary each test run.
func NormalizeTraceFixture ¶
func NormalizeTraceFixture(t testing.TB, fixture *protos.TraceExpectFixture)
func SetTestUserAgent ¶ added in v0.51.0
func UserAgentRemoveRuntimeInfo ¶ added in v0.51.0
Types ¶
type TestCase ¶
type TestCase struct { // ConfigureCollector will be called to modify the default configuration for this test case. Optional. ConfigureCollector func(cfg *collector.Config) // ConfigureLogsExporter uses internal types to add extra post-init config to an exporter object. ConfigureLogsExporter *logsutil.ExporterConfig // Name of the test case Name string // OTLPInputFixturePath is the path to the JSON encoded OTLP // ExportMetricsServiceRequest input metrics fixture. OTLPInputFixturePath string // ExpectFixturePath is the path to the JSON encoded MetricExpectFixture // (see fixtures.proto) that contains request messages the exporter is expected to send. ExpectFixturePath string // CompareFixturePath is a second output fixture that should be equal to this test's output fixture. // Used for cross-referencing multiple tests that should have the same output, without overwriting the same fixtures. CompareFixturePath string // When testing the SDK metrics exporter (not collector), this is the options to use. Optional. MetricSDKExporterOptions []metric.Option // Skip, if true, skips this test case Skip bool // SkipForSDK, if true, skips this test case when testing the SDK SkipForSDK bool // ExpectErr sets whether the test is expected to fail ExpectErr bool // ExpectRetries sets whether the test expects the server to report multiple attempts ExpectRetries bool }
func (*TestCase) CreateCollectorMetricConfig ¶
func (*TestCase) CreateLogConfig ¶
func (*TestCase) CreateTraceConfig ¶
func (*TestCase) LoadLogExpectFixture ¶
func (*TestCase) LoadMetricFixture ¶
func (*TestCase) LoadOTLPLogsInput ¶
func (*TestCase) LoadOTLPMetricsInput ¶
func (tc *TestCase) LoadOTLPMetricsInput( t testing.TB, startTime time.Time, endTime time.Time, ) pmetric.Metrics
Load OTLP metric fixture, test expectation fixtures and modify them so they're suitable for testing. Currently, this just updates the timestamps.
func (*TestCase) LoadOTLPTracesInput ¶
func (*TestCase) LoadTraceExpectFixture ¶
func (*TestCase) SaveRecordedLogFixtures ¶
func (tc *TestCase) SaveRecordedLogFixtures( t testing.TB, fixture *protos.LogExpectFixture, )
func (*TestCase) SaveRecordedMetricFixtures ¶
func (tc *TestCase) SaveRecordedMetricFixtures( t testing.TB, fixture *protos.MetricExpectFixture, )
func (*TestCase) SaveRecordedTraceFixtures ¶
func (tc *TestCase) SaveRecordedTraceFixtures( t testing.TB, fixture *protos.TraceExpectFixture, )
func (*TestCase) SkipIfNeeded ¶
func (*TestCase) SkipIfNeededForSDK ¶
Click to show internal directories.
Click to hide internal directories.