-
Notifications
You must be signed in to change notification settings - Fork 145
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
Changes from all commits
e4f92d8
68d194e
716ae47
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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> | ||
|
@@ -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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 The "otel" check above shows how this is the only integration whose tag value differs from its corresponding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have a mild concern that this will overall increase flakiness in the tests. Telemetry is one of the areas most likely to flake, because it is typically sent at shutdown in our small samples, and that's where there are known bugs in the runtime etc. If we do see flake around this, I'd suggest that most of this check is (or could be) checked with unit tests already 🙂 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Acknowledged, we can keep a close eye on it post-merge 👍🏼 |
||
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) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if you want to do this or not, because this grabs directly from the metric tag:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking of not doing this, so that we could write the assertion without invoking the exact product code. So this
"otel"
or convert from integration name seemed like a better test case