Skip to content

Commit 61231b7

Browse files
committed
Add support for deserializing sketches
Serializing or sending sketches is not supported yet, but as the data pipeline sends these, we want to not fail
1 parent 4ddd083 commit 61231b7

4 files changed

Lines changed: 86 additions & 0 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// <copyright file="SketchSeriesData.cs" company="Datadog">
2+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License.
3+
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc.
4+
// </copyright>
5+
6+
#nullable enable
7+
8+
namespace Datadog.Trace.Telemetry;
9+
10+
internal class SketchSeriesData
11+
{
12+
public SketchSeriesData(string metric, string sketchBase64, bool common)
13+
{
14+
Metric = metric;
15+
SketchBase64 = sketchBase64;
16+
Common = common;
17+
}
18+
19+
public SketchSeriesData(string metric, byte[] sketch, bool common)
20+
{
21+
Metric = metric;
22+
Sketch = sketch;
23+
Common = common;
24+
}
25+
26+
/// <summary>
27+
/// Gets or sets the Metric name. This value will be prefixed with dd.app_telemetry.{namespace}.*
28+
/// or dd.instrumentation_telemetry_data.{namespace}.{language}.*
29+
/// </summary>
30+
public string Metric { get; set; }
31+
32+
/// <summary>
33+
/// Gets or sets a Base64 encoded protobuf representation of a DDSketch. Ignored if <see cref="Sketch"/> is non-empty.
34+
/// </summary>
35+
public string? SketchBase64 { get; set; }
36+
37+
/// <summary>
38+
/// Gets or sets a binary protobuf representation of a DDSketch. If empty, <see cref="SketchBase64"/> must be non-empty
39+
/// </summary>
40+
public byte[]? Sketch { get; set; }
41+
42+
/// <summary>
43+
/// Gets or sets a list of tags that will be associated with the points
44+
/// </summary>
45+
public string[]? Tags { get; set; }
46+
47+
/// <summary>
48+
/// Gets or sets a value indicating whether indicates whether the metric is common or language specific
49+
/// This will affect the tags and prefix of the metric, as explained above.
50+
/// If this field is missing it defaults to true.
51+
/// </summary>
52+
public bool Common { get; set; }
53+
54+
/// <summary>
55+
/// Gets or sets one of the following values: “tracers”, “profilers”, “rum”, “appsec”. Per series override for the namespace field on the payload object
56+
/// </summary>
57+
public string? Namespace { get; set; }
58+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// <copyright file="SketchesPayload.cs" company="Datadog">
2+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License.
3+
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc.
4+
// </copyright>
5+
6+
#nullable enable
7+
using System.Collections.Generic;
8+
9+
namespace Datadog.Trace.Telemetry;
10+
11+
internal class SketchesPayload : IPayload
12+
{
13+
public SketchesPayload(ICollection<DistributionMetricData> series)
14+
{
15+
Series = series;
16+
}
17+
18+
/// <summary>
19+
/// Gets or sets the default namespace for the metrics.
20+
/// Default to assuming that all metrics are for the tracer.
21+
/// Can be overwritten on a per-metric basis
22+
/// </summary>
23+
public string Namespace { get; set; } = MetricNamespaceConstants.Tracer;
24+
25+
public ICollection<DistributionMetricData> Series { get; set; }
26+
}

tracer/src/Datadog.Trace/Telemetry/TelemetryRequestTypes.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ internal static class TelemetryRequestTypes
2020

2121
public const string GenerateMetrics = "generate-metrics";
2222
public const string Distributions = "distributions";
23+
public const string Sketches = "sketches";
2324

2425
public const string MessageBatch = "message-batch";
2526

tracer/test/Datadog.Trace.TestHelpers/MockTelemetryAgent.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ static TelemetryConverter()
233233
{ TelemetryRequestTypes.AppProductChanged, CreateSerializer<AppProductChangePayload>() },
234234
{ TelemetryRequestTypes.GenerateMetrics, CreateSerializer<GenerateMetricsPayload>() },
235235
{ TelemetryRequestTypes.Distributions, CreateSerializer<DistributionsPayload>() },
236+
{ TelemetryRequestTypes.Sketches, CreateSerializer<SketchesPayload>() },
236237
{ TelemetryRequestTypes.RedactedErrorLogs, CreateLogsSerializer() },
237238
{ TelemetryRequestTypes.AppExtendedHeartbeat, CreateSerializer<AppExtendedHeartbeatPayload>() },
238239
{ TelemetryRequestTypes.AppClosing, CreateNullPayloadSerializer() },

0 commit comments

Comments
 (0)