Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tracing] Update telemetry metrics for OpenTelemetry integration #6454

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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" }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" }),
Expand Down Expand Up @@ -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" }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" }),
Expand Down Expand Up @@ -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" }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" }),
Expand Down Expand Up @@ -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" }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" }),
Expand Down Expand Up @@ -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" }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" }),
Expand Down
2 changes: 1 addition & 1 deletion tracer/src/Datadog.Trace/Telemetry/Metrics/MetricTags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="TelemetryHelper.cs" company="Datadog">
// <copyright file="TelemetryHelper.cs" company="Datadog">
// 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.
// </copyright>
Expand Down Expand Up @@ -165,9 +165,45 @@ _ when data.TryGetPayload<AppIntegrationsChangedPayload>(TelemetryRequestTypes.A
}
}

var spansCreatedByIntegration = new ConcurrentDictionary<string, MetricData>();
var metricsPayloads =
allData
.Select(
data => data switch
{
_ when data.TryGetPayload<GenerateMetricsPayload>(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();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds a new check (for all our integration tests!) that when the integration is enabled we also receive a spans_created metric that corresponds to the enabled integration.

The "otel" check above shows how this is the only integration whose tag value differs from its corresponding IntegrationId.ToString() 😅

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)
Expand Down
Loading