-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[chore][exporter/datadog] skip known data race (#35128)
**Description:** Skip `TestIntegrationInternalMetrics` in race detector **Link to tracking Issue:** #34836
- Loading branch information
Showing
2 changed files
with
98 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
exporter/datadogexporter/integrationtest/no_race_integration_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//go:build !race | ||
|
||
package integrationtest // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/datadogexporter/integrationtest" | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"runtime" | ||
"testing" | ||
"time" | ||
|
||
"github.com/DataDog/datadog-agent/comp/otelcol/otlp/testutil" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestIntegrationInternalMetrics(t *testing.T) { | ||
if runtime.GOOS == "windows" { | ||
t.Skip("flaky test on windows https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/34836") | ||
} | ||
|
||
// 1. Set up mock Datadog server | ||
seriesRec := &testutil.HTTPRequestRecorderWithChan{Pattern: testutil.MetricV2Endpoint, ReqChan: make(chan []byte, 100)} | ||
tracesRec := &testutil.HTTPRequestRecorderWithChan{Pattern: testutil.TraceEndpoint, ReqChan: make(chan []byte, 100)} | ||
server := testutil.DatadogServerMock(seriesRec.HandlerFunc, tracesRec.HandlerFunc) | ||
defer server.Close() | ||
t.Setenv("SERVER_URL", server.URL) | ||
|
||
// 2. Start in-process collector | ||
factories := getIntegrationTestComponents(t) | ||
app := getIntegrationTestCollector(t, "integration_test_internal_metrics_config.yaml", factories) | ||
go func() { | ||
assert.NoError(t, app.Run(context.Background())) | ||
}() | ||
defer app.Shutdown() | ||
|
||
waitForReadiness(app) | ||
|
||
// 3. Generate and send traces | ||
sendTraces(t) | ||
|
||
// 4. Validate Datadog trace agent & OTel internal metrics are sent to the mock server | ||
expectedMetrics := map[string]struct{}{ | ||
// Datadog internal metrics on trace and stats writers | ||
"otelcol_datadog_otlp_translator_resources_missing_source": {}, | ||
"otelcol_datadog_trace_agent_stats_writer_bytes": {}, | ||
"otelcol_datadog_trace_agent_stats_writer_retries": {}, | ||
"otelcol_datadog_trace_agent_stats_writer_stats_buckets": {}, | ||
"otelcol_datadog_trace_agent_stats_writer_stats_entries": {}, | ||
"otelcol_datadog_trace_agent_stats_writer_payloads": {}, | ||
"otelcol_datadog_trace_agent_stats_writer_client_payloads": {}, | ||
"otelcol_datadog_trace_agent_stats_writer_errors": {}, | ||
"otelcol_datadog_trace_agent_stats_writer_splits": {}, | ||
"otelcol_datadog_trace_agent_trace_writer_bytes": {}, | ||
"otelcol_datadog_trace_agent_trace_writer_retries": {}, | ||
"otelcol_datadog_trace_agent_trace_writer_spans": {}, | ||
"otelcol_datadog_trace_agent_trace_writer_traces": {}, | ||
"otelcol_datadog_trace_agent_trace_writer_payloads": {}, | ||
"otelcol_datadog_trace_agent_trace_writer_errors": {}, | ||
"otelcol_datadog_trace_agent_trace_writer_events": {}, | ||
|
||
// OTel collector internal metrics | ||
"otelcol_process_memory_rss": {}, | ||
"otelcol_process_runtime_total_sys_memory_bytes": {}, | ||
"otelcol_process_uptime": {}, | ||
"otelcol_process_cpu_seconds": {}, | ||
"otelcol_process_runtime_heap_alloc_bytes": {}, | ||
"otelcol_process_runtime_total_alloc_bytes": {}, | ||
"otelcol_receiver_accepted_metric_points": {}, | ||
"otelcol_receiver_accepted_spans": {}, | ||
"otelcol_exporter_queue_capacity": {}, | ||
"otelcol_exporter_queue_size": {}, | ||
"otelcol_exporter_sent_spans": {}, | ||
"otelcol_exporter_sent_metric_points": {}, | ||
} | ||
|
||
metricMap := make(map[string]series) | ||
for len(metricMap) < len(expectedMetrics) { | ||
select { | ||
case <-tracesRec.ReqChan: | ||
// Drain the channel, no need to look into the traces | ||
case metricsBytes := <-seriesRec.ReqChan: | ||
var metrics seriesSlice | ||
gz := getGzipReader(t, metricsBytes) | ||
dec := json.NewDecoder(gz) | ||
assert.NoError(t, dec.Decode(&metrics)) | ||
for _, s := range metrics.Series { | ||
if _, ok := expectedMetrics[s.Metric]; ok { | ||
metricMap[s.Metric] = s | ||
} | ||
} | ||
case <-time.After(60 * time.Second): | ||
t.Fail() | ||
} | ||
} | ||
} |