Skip to content

Commit c38a5fe

Browse files
authored
[AAP] Add resource name to the collected endpoints (#7317)
## Summary of changes Added the ResourceName to the endpoints collected based on the last update of the [RFC](https://docs.google.com/document/d/1txwuurIiSUWjYX7Xa0let7e49XKW2uhm1djgqjl_gL0). ## Reason for change ## Implementation details - The resource name is defined as `method + path` except in the case of an endpoint detected as a wildcard, the resource name is set to the path. ## Test coverage Updated the tests. ## Other details #6733 <!-- Fixes #{issue} --> <!-- ⚠️ Note: where possible, please obtain 2 approvals prior to merging. Unless CODEOWNERS specifies otherwise, for external teams it is typically best to have one review from a team member, and one review from apm-dotnet. Trivial changes do not require 2 reviews. -->
1 parent 81034fa commit c38a5fe

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

tracer/src/Datadog.Trace/Telemetry/DTOs/AppEndpointData.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public AppEndpointData(string method, string path)
3535
Method = method;
3636
Path = path;
3737
OperationName = "http.request";
38+
ResourceName = method == "*" ? path : $"{method} {path}";
3839
}
3940

4041
/// <summary>
@@ -58,4 +59,9 @@ public AppEndpointData(string method, string path)
5859
/// Gets or sets the operation name for the endpoint.
5960
/// </summary>
6061
public string OperationName { get; set; }
62+
63+
/// <summary>
64+
/// Gets or sets the resource name for the endpoint.
65+
/// </summary>
66+
public string ResourceName { get; set; }
6167
}

tracer/test/Datadog.Trace.Security.IntegrationTests/ApiSecurity/AspNetCore5Endpoints.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ public override async Task TestEndpointsCollection()
2222
await base.TestEndpointsCollection();
2323

2424
// Tests for specific endpoints that should be collected
25-
Endpoints.Should().Contain(e => e.Path == "/iast/executecommand" && e.Method == "GET");
26-
Endpoints.Should().Contain(e => e.Path == "/map_endpoint/sub_level");
25+
Endpoints.Should().Contain(e => e.Path == "/iast/executecommand" && e.Method == "GET" && e.ResourceName == "GET /iast/executecommand");
26+
Endpoints.Should().Contain(e => e.Path == "/health/params/{id}" && e.Method == "GET" && e.ResourceName == "GET /health/params/{id}");
27+
Endpoints.Should().Contain(e => e.Path == "/map_endpoint/sub_level" && e.Method == "*" && e.ResourceName == "/map_endpoint/sub_level");
2728
}
2829
}
2930

tracer/test/Datadog.Trace.Security.IntegrationTests/ApiSecurity/AspNetCoreBareEndpoints.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public override async Task TestEndpointsCollection()
2222
await base.TestEndpointsCollection();
2323

2424
// Tests for specific endpoints that should be collected
25-
Endpoints.Should().Contain(e => e.Path == "/good" && e.Method == "GET");
26-
Endpoints.Should().Contain(e => e.Path == "/map_endpoint/sub_level");
25+
Endpoints.Should().Contain(e => e.Path == "/good" && e.Method == "GET" && e.ResourceName == "GET /good");
26+
Endpoints.Should().Contain(e => e.Path == "/map_endpoint/sub_level" && e.Method == "*" && e.ResourceName == "/map_endpoint/sub_level");
2727
}
2828
}
2929

tracer/test/Datadog.Trace.Tests/Telemetry/TelemetryControllerTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,8 @@ public async Task TelemetryControllerRecordsAppEndpoints()
309309

310310
var endpoints = payload.Endpoints;
311311

312-
endpoints.Should().Contain(x => x.Method == "GET" && x.Path == "/api/test" && x.Type == "REST" && x.OperationName == "http.request");
313-
endpoints.Should().Contain(x => x.Method == "POST" && x.Path == "/api/test" && x.Type == "REST" && x.OperationName == "http.request");
312+
endpoints.Should().Contain(x => x.Method == "GET" && x.Path == "/api/test" && x.Type == "REST" && x.OperationName == "http.request" && x.ResourceName == "GET /api/test");
313+
endpoints.Should().Contain(x => x.Method == "POST" && x.Path == "/api/test" && x.Type == "REST" && x.OperationName == "http.request" && x.ResourceName == "POST /api/test");
314314

315315
await controller.DisposeAsync();
316316
}

0 commit comments

Comments
 (0)