diff --git a/tracer/src/Datadog.Trace/Generated/net461/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/CiVisibilityMetricsTelemetryCollector_CountShared.g.cs b/tracer/src/Datadog.Trace/Generated/net461/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/CiVisibilityMetricsTelemetryCollector_CountShared.g.cs index fcfd1e38ed4a..a34c9bfd512b 100644 --- a/tracer/src/Datadog.Trace/Generated/net461/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/CiVisibilityMetricsTelemetryCollector_CountShared.g.cs +++ b/tracer/src/Datadog.Trace/Generated/net461/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/CiVisibilityMetricsTelemetryCollector_CountShared.g.cs @@ -176,9 +176,9 @@ private static AggregatedMetric[] GetCountSharedBuffer() new(new[] { "integration_name:symmetricalgorithm", "error_type:duck_typing" }), new(new[] { "integration_name:symmetricalgorithm", "error_type:invoker" }), new(new[] { "integration_name:symmetricalgorithm", "error_type:execution" }), - new(new[] { "integration_name:opentelemetry", "error_type:duck_typing" }), - new(new[] { "integration_name:opentelemetry", "error_type:invoker" }), - new(new[] { "integration_name:opentelemetry", "error_type:execution" }), + new(new[] { "integration_name:otel", "error_type:duck_typing" }), + new(new[] { "integration_name:otel", "error_type:invoker" }), + new(new[] { "integration_name:otel", "error_type:execution" }), new(new[] { "integration_name:pathtraversal", "error_type:duck_typing" }), new(new[] { "integration_name:pathtraversal", "error_type:invoker" }), new(new[] { "integration_name:pathtraversal", "error_type:execution" }), diff --git a/tracer/src/Datadog.Trace/Generated/net461/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_Count.g.cs b/tracer/src/Datadog.Trace/Generated/net461/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_Count.g.cs index b91aebc832be..7b20fa050a1d 100644 --- a/tracer/src/Datadog.Trace/Generated/net461/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_Count.g.cs +++ b/tracer/src/Datadog.Trace/Generated/net461/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_Count.g.cs @@ -77,7 +77,7 @@ private static AggregatedMetric[] GetCountBuffer() new(new[] { "integration_name:process" }), new(new[] { "integration_name:hashalgorithm" }), new(new[] { "integration_name:symmetricalgorithm" }), - new(new[] { "integration_name:opentelemetry" }), + new(new[] { "integration_name:otel" }), new(new[] { "integration_name:pathtraversal" }), new(new[] { "integration_name:ssrf" }), new(new[] { "integration_name:ldap" }), @@ -498,7 +498,7 @@ private static AggregatedMetric[] GetCountBuffer() new(new[] { "integration_name:process" }), new(new[] { "integration_name:hashalgorithm" }), new(new[] { "integration_name:symmetricalgorithm" }), - new(new[] { "integration_name:opentelemetry" }), + new(new[] { "integration_name:otel" }), new(new[] { "integration_name:pathtraversal" }), new(new[] { "integration_name:ssrf" }), new(new[] { "integration_name:ldap" }), diff --git a/tracer/src/Datadog.Trace/Generated/net461/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_CountShared.g.cs b/tracer/src/Datadog.Trace/Generated/net461/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_CountShared.g.cs index 2a54bea2390a..e94fcb451a68 100644 --- a/tracer/src/Datadog.Trace/Generated/net461/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_CountShared.g.cs +++ b/tracer/src/Datadog.Trace/Generated/net461/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_CountShared.g.cs @@ -176,9 +176,9 @@ private static AggregatedMetric[] GetCountSharedBuffer() new(new[] { "integration_name:symmetricalgorithm", "error_type:duck_typing" }), new(new[] { "integration_name:symmetricalgorithm", "error_type:invoker" }), new(new[] { "integration_name:symmetricalgorithm", "error_type:execution" }), - new(new[] { "integration_name:opentelemetry", "error_type:duck_typing" }), - new(new[] { "integration_name:opentelemetry", "error_type:invoker" }), - new(new[] { "integration_name:opentelemetry", "error_type:execution" }), + new(new[] { "integration_name:otel", "error_type:duck_typing" }), + new(new[] { "integration_name:otel", "error_type:invoker" }), + new(new[] { "integration_name:otel", "error_type:execution" }), new(new[] { "integration_name:pathtraversal", "error_type:duck_typing" }), new(new[] { "integration_name:pathtraversal", "error_type:invoker" }), new(new[] { "integration_name:pathtraversal", "error_type:execution" }), diff --git a/tracer/src/Datadog.Trace/Generated/net6.0/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/CiVisibilityMetricsTelemetryCollector_CountShared.g.cs b/tracer/src/Datadog.Trace/Generated/net6.0/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/CiVisibilityMetricsTelemetryCollector_CountShared.g.cs index fcfd1e38ed4a..a34c9bfd512b 100644 --- a/tracer/src/Datadog.Trace/Generated/net6.0/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/CiVisibilityMetricsTelemetryCollector_CountShared.g.cs +++ b/tracer/src/Datadog.Trace/Generated/net6.0/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/CiVisibilityMetricsTelemetryCollector_CountShared.g.cs @@ -176,9 +176,9 @@ private static AggregatedMetric[] GetCountSharedBuffer() new(new[] { "integration_name:symmetricalgorithm", "error_type:duck_typing" }), new(new[] { "integration_name:symmetricalgorithm", "error_type:invoker" }), new(new[] { "integration_name:symmetricalgorithm", "error_type:execution" }), - new(new[] { "integration_name:opentelemetry", "error_type:duck_typing" }), - new(new[] { "integration_name:opentelemetry", "error_type:invoker" }), - new(new[] { "integration_name:opentelemetry", "error_type:execution" }), + new(new[] { "integration_name:otel", "error_type:duck_typing" }), + new(new[] { "integration_name:otel", "error_type:invoker" }), + new(new[] { "integration_name:otel", "error_type:execution" }), new(new[] { "integration_name:pathtraversal", "error_type:duck_typing" }), new(new[] { "integration_name:pathtraversal", "error_type:invoker" }), new(new[] { "integration_name:pathtraversal", "error_type:execution" }), diff --git a/tracer/src/Datadog.Trace/Generated/net6.0/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_Count.g.cs b/tracer/src/Datadog.Trace/Generated/net6.0/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_Count.g.cs index b91aebc832be..7b20fa050a1d 100644 --- a/tracer/src/Datadog.Trace/Generated/net6.0/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_Count.g.cs +++ b/tracer/src/Datadog.Trace/Generated/net6.0/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_Count.g.cs @@ -77,7 +77,7 @@ private static AggregatedMetric[] GetCountBuffer() new(new[] { "integration_name:process" }), new(new[] { "integration_name:hashalgorithm" }), new(new[] { "integration_name:symmetricalgorithm" }), - new(new[] { "integration_name:opentelemetry" }), + new(new[] { "integration_name:otel" }), new(new[] { "integration_name:pathtraversal" }), new(new[] { "integration_name:ssrf" }), new(new[] { "integration_name:ldap" }), @@ -498,7 +498,7 @@ private static AggregatedMetric[] GetCountBuffer() new(new[] { "integration_name:process" }), new(new[] { "integration_name:hashalgorithm" }), new(new[] { "integration_name:symmetricalgorithm" }), - new(new[] { "integration_name:opentelemetry" }), + new(new[] { "integration_name:otel" }), new(new[] { "integration_name:pathtraversal" }), new(new[] { "integration_name:ssrf" }), new(new[] { "integration_name:ldap" }), diff --git a/tracer/src/Datadog.Trace/Generated/net6.0/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_CountShared.g.cs b/tracer/src/Datadog.Trace/Generated/net6.0/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_CountShared.g.cs index 2a54bea2390a..e94fcb451a68 100644 --- a/tracer/src/Datadog.Trace/Generated/net6.0/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_CountShared.g.cs +++ b/tracer/src/Datadog.Trace/Generated/net6.0/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_CountShared.g.cs @@ -176,9 +176,9 @@ private static AggregatedMetric[] GetCountSharedBuffer() new(new[] { "integration_name:symmetricalgorithm", "error_type:duck_typing" }), new(new[] { "integration_name:symmetricalgorithm", "error_type:invoker" }), new(new[] { "integration_name:symmetricalgorithm", "error_type:execution" }), - new(new[] { "integration_name:opentelemetry", "error_type:duck_typing" }), - new(new[] { "integration_name:opentelemetry", "error_type:invoker" }), - new(new[] { "integration_name:opentelemetry", "error_type:execution" }), + new(new[] { "integration_name:otel", "error_type:duck_typing" }), + new(new[] { "integration_name:otel", "error_type:invoker" }), + new(new[] { "integration_name:otel", "error_type:execution" }), new(new[] { "integration_name:pathtraversal", "error_type:duck_typing" }), new(new[] { "integration_name:pathtraversal", "error_type:invoker" }), new(new[] { "integration_name:pathtraversal", "error_type:execution" }), diff --git a/tracer/src/Datadog.Trace/Generated/netcoreapp3.1/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/CiVisibilityMetricsTelemetryCollector_CountShared.g.cs b/tracer/src/Datadog.Trace/Generated/netcoreapp3.1/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/CiVisibilityMetricsTelemetryCollector_CountShared.g.cs index fcfd1e38ed4a..a34c9bfd512b 100644 --- a/tracer/src/Datadog.Trace/Generated/netcoreapp3.1/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/CiVisibilityMetricsTelemetryCollector_CountShared.g.cs +++ b/tracer/src/Datadog.Trace/Generated/netcoreapp3.1/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/CiVisibilityMetricsTelemetryCollector_CountShared.g.cs @@ -176,9 +176,9 @@ private static AggregatedMetric[] GetCountSharedBuffer() new(new[] { "integration_name:symmetricalgorithm", "error_type:duck_typing" }), new(new[] { "integration_name:symmetricalgorithm", "error_type:invoker" }), new(new[] { "integration_name:symmetricalgorithm", "error_type:execution" }), - new(new[] { "integration_name:opentelemetry", "error_type:duck_typing" }), - new(new[] { "integration_name:opentelemetry", "error_type:invoker" }), - new(new[] { "integration_name:opentelemetry", "error_type:execution" }), + new(new[] { "integration_name:otel", "error_type:duck_typing" }), + new(new[] { "integration_name:otel", "error_type:invoker" }), + new(new[] { "integration_name:otel", "error_type:execution" }), new(new[] { "integration_name:pathtraversal", "error_type:duck_typing" }), new(new[] { "integration_name:pathtraversal", "error_type:invoker" }), new(new[] { "integration_name:pathtraversal", "error_type:execution" }), diff --git a/tracer/src/Datadog.Trace/Generated/netcoreapp3.1/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_Count.g.cs b/tracer/src/Datadog.Trace/Generated/netcoreapp3.1/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_Count.g.cs index b91aebc832be..7b20fa050a1d 100644 --- a/tracer/src/Datadog.Trace/Generated/netcoreapp3.1/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_Count.g.cs +++ b/tracer/src/Datadog.Trace/Generated/netcoreapp3.1/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_Count.g.cs @@ -77,7 +77,7 @@ private static AggregatedMetric[] GetCountBuffer() new(new[] { "integration_name:process" }), new(new[] { "integration_name:hashalgorithm" }), new(new[] { "integration_name:symmetricalgorithm" }), - new(new[] { "integration_name:opentelemetry" }), + new(new[] { "integration_name:otel" }), new(new[] { "integration_name:pathtraversal" }), new(new[] { "integration_name:ssrf" }), new(new[] { "integration_name:ldap" }), @@ -498,7 +498,7 @@ private static AggregatedMetric[] GetCountBuffer() new(new[] { "integration_name:process" }), new(new[] { "integration_name:hashalgorithm" }), new(new[] { "integration_name:symmetricalgorithm" }), - new(new[] { "integration_name:opentelemetry" }), + new(new[] { "integration_name:otel" }), new(new[] { "integration_name:pathtraversal" }), new(new[] { "integration_name:ssrf" }), new(new[] { "integration_name:ldap" }), diff --git a/tracer/src/Datadog.Trace/Generated/netcoreapp3.1/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_CountShared.g.cs b/tracer/src/Datadog.Trace/Generated/netcoreapp3.1/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_CountShared.g.cs index 2a54bea2390a..e94fcb451a68 100644 --- a/tracer/src/Datadog.Trace/Generated/netcoreapp3.1/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_CountShared.g.cs +++ b/tracer/src/Datadog.Trace/Generated/netcoreapp3.1/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_CountShared.g.cs @@ -176,9 +176,9 @@ private static AggregatedMetric[] GetCountSharedBuffer() new(new[] { "integration_name:symmetricalgorithm", "error_type:duck_typing" }), new(new[] { "integration_name:symmetricalgorithm", "error_type:invoker" }), new(new[] { "integration_name:symmetricalgorithm", "error_type:execution" }), - new(new[] { "integration_name:opentelemetry", "error_type:duck_typing" }), - new(new[] { "integration_name:opentelemetry", "error_type:invoker" }), - new(new[] { "integration_name:opentelemetry", "error_type:execution" }), + new(new[] { "integration_name:otel", "error_type:duck_typing" }), + new(new[] { "integration_name:otel", "error_type:invoker" }), + new(new[] { "integration_name:otel", "error_type:execution" }), new(new[] { "integration_name:pathtraversal", "error_type:duck_typing" }), new(new[] { "integration_name:pathtraversal", "error_type:invoker" }), new(new[] { "integration_name:pathtraversal", "error_type:execution" }), diff --git a/tracer/src/Datadog.Trace/Generated/netstandard2.0/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/CiVisibilityMetricsTelemetryCollector_CountShared.g.cs b/tracer/src/Datadog.Trace/Generated/netstandard2.0/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/CiVisibilityMetricsTelemetryCollector_CountShared.g.cs index fcfd1e38ed4a..a34c9bfd512b 100644 --- a/tracer/src/Datadog.Trace/Generated/netstandard2.0/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/CiVisibilityMetricsTelemetryCollector_CountShared.g.cs +++ b/tracer/src/Datadog.Trace/Generated/netstandard2.0/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/CiVisibilityMetricsTelemetryCollector_CountShared.g.cs @@ -176,9 +176,9 @@ private static AggregatedMetric[] GetCountSharedBuffer() new(new[] { "integration_name:symmetricalgorithm", "error_type:duck_typing" }), new(new[] { "integration_name:symmetricalgorithm", "error_type:invoker" }), new(new[] { "integration_name:symmetricalgorithm", "error_type:execution" }), - new(new[] { "integration_name:opentelemetry", "error_type:duck_typing" }), - new(new[] { "integration_name:opentelemetry", "error_type:invoker" }), - new(new[] { "integration_name:opentelemetry", "error_type:execution" }), + new(new[] { "integration_name:otel", "error_type:duck_typing" }), + new(new[] { "integration_name:otel", "error_type:invoker" }), + new(new[] { "integration_name:otel", "error_type:execution" }), new(new[] { "integration_name:pathtraversal", "error_type:duck_typing" }), new(new[] { "integration_name:pathtraversal", "error_type:invoker" }), new(new[] { "integration_name:pathtraversal", "error_type:execution" }), diff --git a/tracer/src/Datadog.Trace/Generated/netstandard2.0/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_Count.g.cs b/tracer/src/Datadog.Trace/Generated/netstandard2.0/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_Count.g.cs index b91aebc832be..7b20fa050a1d 100644 --- a/tracer/src/Datadog.Trace/Generated/netstandard2.0/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_Count.g.cs +++ b/tracer/src/Datadog.Trace/Generated/netstandard2.0/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_Count.g.cs @@ -77,7 +77,7 @@ private static AggregatedMetric[] GetCountBuffer() new(new[] { "integration_name:process" }), new(new[] { "integration_name:hashalgorithm" }), new(new[] { "integration_name:symmetricalgorithm" }), - new(new[] { "integration_name:opentelemetry" }), + new(new[] { "integration_name:otel" }), new(new[] { "integration_name:pathtraversal" }), new(new[] { "integration_name:ssrf" }), new(new[] { "integration_name:ldap" }), @@ -498,7 +498,7 @@ private static AggregatedMetric[] GetCountBuffer() new(new[] { "integration_name:process" }), new(new[] { "integration_name:hashalgorithm" }), new(new[] { "integration_name:symmetricalgorithm" }), - new(new[] { "integration_name:opentelemetry" }), + new(new[] { "integration_name:otel" }), new(new[] { "integration_name:pathtraversal" }), new(new[] { "integration_name:ssrf" }), new(new[] { "integration_name:ldap" }), diff --git a/tracer/src/Datadog.Trace/Generated/netstandard2.0/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_CountShared.g.cs b/tracer/src/Datadog.Trace/Generated/netstandard2.0/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_CountShared.g.cs index 2a54bea2390a..e94fcb451a68 100644 --- a/tracer/src/Datadog.Trace/Generated/netstandard2.0/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_CountShared.g.cs +++ b/tracer/src/Datadog.Trace/Generated/netstandard2.0/Datadog.Trace.SourceGenerators/TelemetryMetricGenerator/MetricsTelemetryCollector_CountShared.g.cs @@ -176,9 +176,9 @@ private static AggregatedMetric[] GetCountSharedBuffer() new(new[] { "integration_name:symmetricalgorithm", "error_type:duck_typing" }), new(new[] { "integration_name:symmetricalgorithm", "error_type:invoker" }), new(new[] { "integration_name:symmetricalgorithm", "error_type:execution" }), - new(new[] { "integration_name:opentelemetry", "error_type:duck_typing" }), - new(new[] { "integration_name:opentelemetry", "error_type:invoker" }), - new(new[] { "integration_name:opentelemetry", "error_type:execution" }), + new(new[] { "integration_name:otel", "error_type:duck_typing" }), + new(new[] { "integration_name:otel", "error_type:invoker" }), + new(new[] { "integration_name:otel", "error_type:execution" }), new(new[] { "integration_name:pathtraversal", "error_type:duck_typing" }), new(new[] { "integration_name:pathtraversal", "error_type:invoker" }), new(new[] { "integration_name:pathtraversal", "error_type:execution" }), diff --git a/tracer/src/Datadog.Trace/Telemetry/Metrics/MetricTags.cs b/tracer/src/Datadog.Trace/Telemetry/Metrics/MetricTags.cs index 0139c2b254ee..d488ed078893 100644 --- a/tracer/src/Datadog.Trace/Telemetry/Metrics/MetricTags.cs +++ b/tracer/src/Datadog.Trace/Telemetry/Metrics/MetricTags.cs @@ -239,7 +239,7 @@ internal enum IntegrationName [Description("integration_name:process")]Process, [Description("integration_name:hashalgorithm")]HashAlgorithm, [Description("integration_name:symmetricalgorithm")]SymmetricAlgorithm, - [Description("integration_name:opentelemetry")]OpenTelemetry, + [Description("integration_name:otel")]OpenTelemetry, // Note: The naming of this tag value breaks the convention of using the integration name to use a standardized value [Description("integration_name:pathtraversal")]PathTraversal, [Description("integration_name:ssrf")]Ssrf, [Description("integration_name:ldap")]Ldap, diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Helpers/TelemetryHelper.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Helpers/TelemetryHelper.cs index a6862a0c73e3..11bdaf6fd4d7 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Helpers/TelemetryHelper.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Helpers/TelemetryHelper.cs @@ -1,4 +1,4 @@ -// +// // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // @@ -165,9 +165,45 @@ _ when data.TryGetPayload(TelemetryRequestTypes.A } } + var spansCreatedByIntegration = new ConcurrentDictionary(); + var metricsPayloads = + allData + .Select( + data => data switch + { + _ when data.TryGetPayload(TelemetryRequestTypes.GenerateMetrics) is { } p => p.Series.Where(s => s.Metric == "spans_created"), + _ => null, + }) + .Where(x => x is not null); + + // Flatten the spans_created metrics + foreach (var metricPayload in metricsPayloads) + { + foreach (var metricEntry in metricPayload) + { + spansCreatedByIntegration.TryAdd(metricEntry.Tags.First(s => s.StartsWith("integration_name:")), metricEntry); + } + } + + var integrationName = integrationId.ToString(); + var integrationNameTagValue = integrationName switch + { + "OpenTelemetry" => "otel", + _ => integrationName.ToLowerInvariant(), + }; + + if (enabled) + { + spansCreatedByIntegration.Should().NotBeEmpty(); + + var spansCreated = spansCreatedByIntegration.Should().ContainKey($"integration_name:{integrationNameTagValue}").WhoseValue; + spansCreated.Points.Should().NotBeEmpty(); + spansCreated.Points.Sum(p => p.Value).Should().BeGreaterThanOrEqualTo(1); + } + latestIntegrations.Should().NotBeEmpty(); - var integration = latestIntegrations.Should().ContainKey(integrationId.ToString()).WhoseValue; + var integration = latestIntegrations.Should().ContainKey(integrationName).WhoseValue; integration.Enabled.Should().Be(enabled, $"{integration.Name} should only be enabled if we generate a span"); if (autoEnabled.HasValue) diff --git a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Helpers/TelemetryHelperTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Helpers/TelemetryHelperTests.cs index 62f52538bb35..e68ca22f2544 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Helpers/TelemetryHelperTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/Helpers/TelemetryHelperTests.cs @@ -11,6 +11,7 @@ using Datadog.Trace.Configuration.ConfigurationSources.Telemetry; using Datadog.Trace.Configuration.Telemetry; using Datadog.Trace.Telemetry; +using Datadog.Trace.Telemetry.Metrics; using Datadog.Trace.TestHelpers; using FluentAssertions; using FluentAssertions.Execution; @@ -48,25 +49,35 @@ public TelemetryHelperTests(ITestOutputHelper output) public void AssertIntegration_HandlesMultipleTelemetryPushes() { var collector = new IntegrationTelemetryCollector(); + var metricsCollector = new MetricsTelemetryCollector(); var telemetryData = new List(); collector.IntegrationRunning(IntegrationId.Aerospike); - telemetryData.Add(BuildTelemetryData(collector.GetData())); + metricsCollector.AggregateMetrics(); + telemetryData.Add(BuildTelemetryData(collector.GetData(), metrics: metricsCollector.GetMetrics())); + // The updates to both the IntegrationTelemetryCollector and the MetricsTelemetryCollector + // are typically handled by TelemetryController.IntegrationGeneratedSpan(IntegrationId), + // so we simulate that here with the separate calls collector.IntegrationGeneratedSpan(IntegrationId.Aerospike); + metricsCollector.RecordCountSpanCreated(IntegrationId.Aerospike.GetMetricTag()); + collector.IntegrationRunning(IntegrationId.Couchbase); - telemetryData.Add(BuildTelemetryData(collector.GetData(), sendAppStarted: false)); + + metricsCollector.AggregateMetrics(); + telemetryData.Add(BuildTelemetryData(collector.GetData(), metrics: metricsCollector.GetMetrics(), sendAppStarted: false)); collector.IntegrationRunning(IntegrationId.Kafka); - collector.IntegrationGeneratedSpan(IntegrationId.Msmq); + collector.IntegrationRunning(IntegrationId.Msmq); var tracerSettings = TracerSettings.Create(new() { { ConfigurationKeys.DisabledIntegrations, $"{nameof(IntegrationId.Kafka)};{nameof(IntegrationId.Msmq)}" } }); collector.RecordTracerSettings(tracerSettings); - telemetryData.Add(BuildTelemetryData(collector.GetData(), sendAppClosing: true)); + metricsCollector.AggregateMetrics(); + telemetryData.Add(BuildTelemetryData(collector.GetData(), metrics: metricsCollector.GetMetrics(), sendAppClosing: true)); using var s = new AssertionScope(); TelemetryHelper.AssertIntegration(telemetryData, IntegrationId.Aerospike, enabled: true, autoEnabled: true); @@ -150,12 +161,13 @@ public void AssertConfiguration_HandlesMultipleTelemetryPushes() private TelemetryData BuildTelemetryData( ICollection integrations, ICollection configuration = null, + MetricResults? metrics = null, bool sendAppStarted = true, bool sendAppClosing = false) => _dataBuilder.BuildTelemetryData( _app, _host, - new TelemetryInput(configuration, null, integrations, null, null, sendAppStarted), + new TelemetryInput(configuration, null, integrations, metrics, null, sendAppStarted), namingSchemeVersion: "1", sendAppClosing); }