|
11 | 11 | using Datadog.Trace.Configuration.ConfigurationSources.Telemetry;
|
12 | 12 | using Datadog.Trace.Configuration.Telemetry;
|
13 | 13 | using Datadog.Trace.Telemetry;
|
| 14 | +using Datadog.Trace.Telemetry.Metrics; |
14 | 15 | using Datadog.Trace.TestHelpers;
|
15 | 16 | using FluentAssertions;
|
16 | 17 | using FluentAssertions.Execution;
|
@@ -48,25 +49,35 @@ public TelemetryHelperTests(ITestOutputHelper output)
|
48 | 49 | public void AssertIntegration_HandlesMultipleTelemetryPushes()
|
49 | 50 | {
|
50 | 51 | var collector = new IntegrationTelemetryCollector();
|
| 52 | + var metricsCollector = new MetricsTelemetryCollector(); |
51 | 53 | var telemetryData = new List<TelemetryData>();
|
52 | 54 |
|
53 | 55 | collector.IntegrationRunning(IntegrationId.Aerospike);
|
54 | 56 |
|
55 |
| - telemetryData.Add(BuildTelemetryData(collector.GetData())); |
| 57 | + metricsCollector.AggregateMetrics(); |
| 58 | + telemetryData.Add(BuildTelemetryData(collector.GetData(), metrics: metricsCollector.GetMetrics())); |
56 | 59 |
|
| 60 | + // The updates to both the IntegrationTelemetryCollector and the MetricsTelemetryCollector |
| 61 | + // are typically handled by TelemetryController.IntegrationGeneratedSpan(IntegrationId), |
| 62 | + // so we simulate that here with the separate calls |
57 | 63 | collector.IntegrationGeneratedSpan(IntegrationId.Aerospike);
|
| 64 | + metricsCollector.RecordCountSpanCreated(IntegrationId.Aerospike.GetMetricTag()); |
| 65 | + |
58 | 66 | collector.IntegrationRunning(IntegrationId.Couchbase);
|
59 |
| - telemetryData.Add(BuildTelemetryData(collector.GetData(), sendAppStarted: false)); |
| 67 | + |
| 68 | + metricsCollector.AggregateMetrics(); |
| 69 | + telemetryData.Add(BuildTelemetryData(collector.GetData(), metrics: metricsCollector.GetMetrics(), sendAppStarted: false)); |
60 | 70 |
|
61 | 71 | collector.IntegrationRunning(IntegrationId.Kafka);
|
62 |
| - collector.IntegrationGeneratedSpan(IntegrationId.Msmq); |
| 72 | + collector.IntegrationRunning(IntegrationId.Msmq); |
63 | 73 | var tracerSettings = TracerSettings.Create(new()
|
64 | 74 | {
|
65 | 75 | { ConfigurationKeys.DisabledIntegrations, $"{nameof(IntegrationId.Kafka)};{nameof(IntegrationId.Msmq)}" }
|
66 | 76 | });
|
67 | 77 |
|
68 | 78 | collector.RecordTracerSettings(tracerSettings);
|
69 |
| - telemetryData.Add(BuildTelemetryData(collector.GetData(), sendAppClosing: true)); |
| 79 | + metricsCollector.AggregateMetrics(); |
| 80 | + telemetryData.Add(BuildTelemetryData(collector.GetData(), metrics: metricsCollector.GetMetrics(), sendAppClosing: true)); |
70 | 81 |
|
71 | 82 | using var s = new AssertionScope();
|
72 | 83 | TelemetryHelper.AssertIntegration(telemetryData, IntegrationId.Aerospike, enabled: true, autoEnabled: true);
|
@@ -150,12 +161,13 @@ public void AssertConfiguration_HandlesMultipleTelemetryPushes()
|
150 | 161 | private TelemetryData BuildTelemetryData(
|
151 | 162 | ICollection<IntegrationTelemetryData> integrations,
|
152 | 163 | ICollection<ConfigurationKeyValue> configuration = null,
|
| 164 | + MetricResults? metrics = null, |
153 | 165 | bool sendAppStarted = true,
|
154 | 166 | bool sendAppClosing = false)
|
155 | 167 | => _dataBuilder.BuildTelemetryData(
|
156 | 168 | _app,
|
157 | 169 | _host,
|
158 |
| - new TelemetryInput(configuration, null, integrations, null, null, sendAppStarted), |
| 170 | + new TelemetryInput(configuration, null, integrations, metrics, null, sendAppStarted), |
159 | 171 | namingSchemeVersion: "1",
|
160 | 172 | sendAppClosing);
|
161 | 173 | }
|
0 commit comments