mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
feat(xray): serve traces, summaries, the service graph and sampling (#7733)
X-Ray is the one AWS service local stacks ask for and Floci does not have: SQS
and SNS already carry AWSTraceHeader, and nothing on the other end accepts the
segments that header points at. This serves the ingest loop, the summaries that
read it back, the service graph a console draws from it, and the sampling the
X-Ray daemon polls on its own timers.
The API is REST JSON on literal paths (/TraceSegments, /Traces, /TraceSummaries,
/ServiceGraph, /TraceGraph, /GetSamplingRules, ...), which S3's path-style routes
would swallow as a bucket name, so a request signed for the xray credential scope
is rewritten onto an internal prefix and every other request keeps its path. Only
the paths Floci serves are claimed.
What Floci stores is the segment document as sent: BatchGetTraces has to answer
exactly what PutTraceSegments accepted, so re-serialising through a model would
change what the caller reads. The summaries and the graph parse those documents
on read, which keeps the stored bytes the caller's and costs nothing while a local
stack is idle.
A filter expression is parsed, not pattern-matched: service("name"), hasError,
hasFault, hasThrottle, duration, responsetime, http.status, annotation.key,
comparisons, AND, OR, NOT and parentheses. Anything outside that set is refused
with InvalidRequestException naming what it could not read, because accepting a
filter and ignoring half of it hands a caller a superset and looks like a pass. A
lone '!' is refused the same way rather than left as a delimiter no branch
consumes, and responsetime is compared in seconds, the unit AWS uses.
The graph collapses segments into services by name, derives edges from parent ids,
and reports AWS's SummaryStatistics and cumulative DurationHistogram per node and
per edge. A node is a service, not a document shape: the same service seen once
with an http block and once without is one node.
Sampling answers the Default rule AWS serves in every Region, so a daemon has
something to sample at before any rule exists, and five rules per Region on top of
it. It is answered, not adapted: the reservoir is reported as the quota and
renewed every 10 seconds rather than decremented per report, and the service page
says so.
A local emulator runs for days, so the store is bounded to 10000 traces per Region
with AWS's 30 day window, oldest evicted first. A bad document is reported under
UnprocessedTraceSegments with its reason instead of failing the whole call, and
100 documents per call is the AWS limit, enforced.
Co-authored-by: David Guardiola <davidguardiola@gmail.com>
This commit is contained in:
1 parent
54bc8fc563
commit
b144879127
32 files changed
+3571
-13
No files matched your search
@@ -664,6 +664,11 @@
|
||||
<groupId>software.amazon.awssdk</groupId>
|
||||
<artifactId>signer</artifactId>
|
||||
</dependency>
|
||||
<!-- X-Ray client -->
|
||||
<dependency>
|
||||
<groupId>software.amazon.awssdk</groupId>
|
||||
<artifactId>xray</artifactId>
|
||||
</dependency>
|
||||
<!-- DataSync client -->
|
||||
<dependency>
|
||||
<groupId>software.amazon.awssdk</groupId>
|
||||
|
||||
@@ -176,6 +176,7 @@ import software.amazon.awssdk.services.timestreaminfluxdb.TimestreamInfluxDbClie
|
||||
import software.amazon.awssdk.services.transfer.TransferClient;
|
||||
import software.amazon.awssdk.services.verifiedpermissions.VerifiedPermissionsClient;
|
||||
import software.amazon.awssdk.services.wafv2.Wafv2Client;
|
||||
import software.amazon.awssdk.services.xray.XRayClient;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManager;
|
||||
@@ -1630,6 +1631,14 @@ public final class TestFixtures {
|
||||
.build();
|
||||
}
|
||||
|
||||
public static XRayClient xrayClient() {
|
||||
return XRayClient.builder()
|
||||
.endpointOverride(ENDPOINT)
|
||||
.region(REGION)
|
||||
.credentialsProvider(CREDENTIALS)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static DlmClient dlmClient() {
|
||||
return DlmClient.builder()
|
||||
.endpointOverride(ENDPOINT)
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
package com.floci.test;
|
||||
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import software.amazon.awssdk.services.xray.XRayClient;
|
||||
import software.amazon.awssdk.services.xray.model.BatchGetTracesResponse;
|
||||
import software.amazon.awssdk.services.xray.model.GetSamplingTargetsResponse;
|
||||
import software.amazon.awssdk.services.xray.model.GetServiceGraphResponse;
|
||||
import software.amazon.awssdk.services.xray.model.GetTraceSummariesResponse;
|
||||
import software.amazon.awssdk.services.xray.model.SamplingRuleRecord;
|
||||
import software.amazon.awssdk.services.xray.model.SamplingStatisticsDocument;
|
||||
import software.amazon.awssdk.services.xray.model.Service;
|
||||
import software.amazon.awssdk.services.xray.model.ServiceId;
|
||||
import software.amazon.awssdk.services.xray.model.TraceSummary;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.within;
|
||||
|
||||
class XrayTest {
|
||||
|
||||
private static final String TRACE_ID = "1-0a1b2c3d-4e5f60718293a4b5c6d7e8f9";
|
||||
private static final Instant NOW = Instant.now();
|
||||
private static XRayClient xray;
|
||||
|
||||
@BeforeAll
|
||||
static void setup() {
|
||||
xray = TestFixtures.xrayClient();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
static void cleanup() {
|
||||
if (xray != null) {
|
||||
xray.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** A root segment that called a second service: one trace, one edge. */
|
||||
private static String segment() {
|
||||
double base = NOW.getEpochSecond();
|
||||
return String.format(Locale.ROOT,
|
||||
"{\"trace_id\":\"%s\",\"id\":\"0f1e2d3c4b5a6978\",\"name\":\"sdk-orders\","
|
||||
+ "\"start_time\":%.1f,\"end_time\":%.1f,"
|
||||
+ "\"http\":{\"request\":{\"method\":\"GET\",\"url\":\"http://sdk/\"},"
|
||||
+ "\"response\":{\"status\":200}},"
|
||||
+ "\"annotations\":{\"env\":\"sdk\"},"
|
||||
+ "\"subsegments\":[{\"id\":\"8a7b6c5d4e3f2019\",\"name\":\"sdk-payments\","
|
||||
+ "\"start_time\":%.1f,\"end_time\":%.1f}]}",
|
||||
TRACE_ID, base, base + 1.5, base + 0.2, base + 0.9);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("A segment put through the SDK is read back byte for byte")
|
||||
void putAndBatchGet() {
|
||||
String document = segment();
|
||||
|
||||
xray.putTraceSegments(r -> r.traceSegmentDocuments(document));
|
||||
|
||||
BatchGetTracesResponse batch = xray.batchGetTraces(r -> r.traceIds(TRACE_ID));
|
||||
assertThat(batch.traces()).hasSize(1);
|
||||
assertThat(batch.traces().get(0).id()).isEqualTo(TRACE_ID);
|
||||
assertThat(batch.traces().get(0).duration()).isEqualTo(1.5);
|
||||
assertThat(batch.traces().get(0).segments()).hasSize(1);
|
||||
assertThat(batch.traces().get(0).segments().get(0).document()).isEqualTo(document);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("GetTraceSummaries reports the trace with its services and annotations")
|
||||
void traceSummaries() {
|
||||
xray.putTraceSegments(r -> r.traceSegmentDocuments(segment()));
|
||||
|
||||
GetTraceSummariesResponse response = xray.getTraceSummaries(r -> r
|
||||
.startTime(NOW.minusSeconds(60))
|
||||
.endTime(NOW.plus(60, ChronoUnit.SECONDS)));
|
||||
|
||||
assertThat(response.traceSummaries()).isNotEmpty();
|
||||
Optional<TraceSummary> found = response.traceSummaries().stream()
|
||||
.filter(summary -> TRACE_ID.equals(summary.id()))
|
||||
.findFirst();
|
||||
assertThat(found).isPresent();
|
||||
TraceSummary summary = found.get();
|
||||
assertThat(summary.duration()).isCloseTo(1.5, within(0.001));
|
||||
assertThat(summary.hasError()).isFalse();
|
||||
assertThat(summary.hasFault()).isFalse();
|
||||
assertThat(summary.http().httpStatus()).isEqualTo(200);
|
||||
assertThat(summary.entryPoint().name()).isEqualTo("sdk-orders");
|
||||
assertThat(summary.serviceIds()).extracting(ServiceId::name)
|
||||
.contains("sdk-orders", "sdk-payments");
|
||||
assertThat(summary.annotations().get("env").get(0).annotationValue().stringValue())
|
||||
.isEqualTo("sdk");
|
||||
assertThat(response.tracesProcessedCount()).isGreaterThanOrEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("GetSamplingRules answers the Default rule AWS serves in every Region")
|
||||
void samplingRules() {
|
||||
List<SamplingRuleRecord> records = xray.getSamplingRules(r -> { }).samplingRuleRecords();
|
||||
|
||||
SamplingRuleRecord defaults = records.stream()
|
||||
.filter(record -> "Default".equals(record.samplingRule().ruleName()))
|
||||
.findFirst()
|
||||
.orElseThrow();
|
||||
assertThat(defaults.samplingRule().priority()).isEqualTo(10000);
|
||||
assertThat(defaults.samplingRule().fixedRate()).isEqualTo(0.05);
|
||||
assertThat(defaults.samplingRule().reservoirSize()).isEqualTo(1);
|
||||
assertThat(defaults.samplingRule().resourceARN())
|
||||
.startsWith("arn:aws:xray:us-east-1:")
|
||||
.endsWith(":sampling-rule/Default");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("GetSamplingTargets answers a rate and a reservoir quota for the rule")
|
||||
void samplingTargets() {
|
||||
SamplingStatisticsDocument statistics = SamplingStatisticsDocument.builder()
|
||||
.ruleName("Default")
|
||||
.clientID("sdk-client")
|
||||
.timestamp(Instant.now())
|
||||
.requestCount(10)
|
||||
.sampledCount(1)
|
||||
.build();
|
||||
|
||||
GetSamplingTargetsResponse response = xray.getSamplingTargets(
|
||||
r -> r.samplingStatisticsDocuments(statistics));
|
||||
|
||||
assertThat(response.samplingTargetDocuments()).hasSize(1);
|
||||
assertThat(response.samplingTargetDocuments().get(0).ruleName()).isEqualTo("Default");
|
||||
assertThat(response.samplingTargetDocuments().get(0).fixedRate()).isEqualTo(0.05);
|
||||
assertThat(response.samplingTargetDocuments().get(0).interval()).isEqualTo(10);
|
||||
assertThat(response.unprocessedStatistics()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("GetServiceGraph answers one node per service and the call between them")
|
||||
void serviceGraph() {
|
||||
xray.putTraceSegments(r -> r.traceSegmentDocuments(segment()));
|
||||
|
||||
GetServiceGraphResponse response = xray.getServiceGraph(r -> r
|
||||
.startTime(NOW.minusSeconds(60))
|
||||
.endTime(NOW.plus(60, ChronoUnit.SECONDS)));
|
||||
|
||||
Service orders = response.services().stream()
|
||||
.filter(service -> "sdk-orders".equals(service.name()))
|
||||
.findFirst()
|
||||
.orElseThrow();
|
||||
assertThat(orders.type()).isEqualTo("client");
|
||||
assertThat(orders.state()).isEqualTo("ok");
|
||||
assertThat(orders.summaryStatistics().okCount()).isGreaterThanOrEqualTo(1);
|
||||
assertThat(orders.edges()).hasSize(1);
|
||||
assertThat(orders.durationHistogram()).isNotEmpty();
|
||||
|
||||
Service payments = response.services().stream()
|
||||
.filter(service -> "sdk-payments".equals(service.name()))
|
||||
.findFirst()
|
||||
.orElseThrow();
|
||||
assertThat(orders.edges().get(0).referenceId()).isEqualTo(payments.referenceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("GetTraceGraph answers the same services for the named trace")
|
||||
void traceGraph() {
|
||||
xray.putTraceSegments(r -> r.traceSegmentDocuments(segment()));
|
||||
|
||||
List<Service> services = xray.getTraceGraph(r -> r.traceIds(TRACE_ID)).services();
|
||||
|
||||
assertThat(services).extracting(Service::name).contains("sdk-orders", "sdk-payments");
|
||||
}
|
||||
}
|
||||
@@ -49,6 +49,7 @@ Operation counts are exact. For dispatch-table services (Query and JSON 1.1) eac
|
||||
| [CloudWatch Logs](cloudwatch.md) | `POST /` + `X-Amz-Target: Logs.*` | JSON 1.1 | 17 |
|
||||
| [CloudWatch Metrics](cloudwatch.md#metrics) | `POST /` with `Action=` or JSON 1.1 | Query / JSON | 11 |
|
||||
| [CloudWatch RUM](rum.md) | `/appmonitor`, `/appmonitor/{name}`, `/appmonitors` | REST JSON | 5 |
|
||||
| [X-Ray](xray.md) | `/TraceSegments`, `/Traces`, `/TraceSummaries`, `/ServiceGraph`, `/TraceGraph`, `/GetSamplingRules`, `/CreateSamplingRule`, `/SamplingTargets`, `/TelemetryRecords` | REST JSON | 11 |
|
||||
| [GuardDuty](guardduty.md) | `/detector`, `/detector/{detectorId}`, `/detector/{detectorId}/admin`, `/admin/*`, `/tags/*` | REST JSON | 28 |
|
||||
| [AWS Account Management](account.md) | `/putAlternateContact`, `/getAlternateContact`, `/deleteAlternateContact` | REST JSON | 3 |
|
||||
| [IAM Access Analyzer](access-analyzer.md) | `/analyzer`, `/analyzer/{name}`, `/policy/validation` | REST JSON | 5 |
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
# AWS X-Ray
|
||||
|
||||
**Protocol:** REST JSON
|
||||
**Endpoint:** `http://localhost:4566/TraceSegments` (SigV4 service `xray`)
|
||||
|
||||
Floci emulates the X-Ray tracing API. A client, the X-Ray SDK or the X-Ray daemon sends
|
||||
segment documents and Floci stores them by trace, returning them exactly as they were
|
||||
sent. Traces are isolated by account and Region, and kept for the same 30 day window AWS
|
||||
uses.
|
||||
|
||||
Point any client at the emulator and the existing configuration works unchanged:
|
||||
|
||||
```bash
|
||||
export AWS_ENDPOINT_URL=http://localhost:4566
|
||||
aws xray put-trace-segments --trace-segment-documents file://segment.json
|
||||
aws xray batch-get-traces --trace-ids 1-5f3b8a0e-3c9d4d8e9b7a2c1d4e5f6a7b
|
||||
```
|
||||
|
||||
The X-Ray daemon reads the endpoint from the standard AWS environment, so the same
|
||||
variable points it at Floci. It is the real gate for this service: it fetches sampling
|
||||
rules, samples, sends segments and reports telemetry on its own timers.
|
||||
|
||||
```bash
|
||||
docker run -d --name xray-daemon -p 2000:2000/tcp -p 2000:2000/udp \
|
||||
-e AWS_ENDPOINT_URL=http://host.docker.internal:4566 \
|
||||
-e AWS_REGION=us-east-1 \
|
||||
-e AWS_ACCESS_KEY_ID=test -e AWS_SECRET_ACCESS_KEY=test \
|
||||
amazon/aws-xray-daemon -o -n us-east-1
|
||||
```
|
||||
|
||||
Send a segment to the daemon over UDP, the way an instrumented app does:
|
||||
|
||||
```bash
|
||||
printf '{"format": "json", "version": 1}\n%s\n' \
|
||||
'{"trace_id":"1-abcdef01-23456789abcdef0123456789","id":"0f1e2d3c4b5a6979",
|
||||
"name":"orders-api","start_time":1794038810.0,"end_time":1794038811.0}' \
|
||||
| nc -u -w1 127.0.0.1 2000
|
||||
```
|
||||
|
||||
## Supported Actions
|
||||
|
||||
<!-- floci:actions:start -->
|
||||
| Action | Description |
|
||||
| --- | --- |
|
||||
| `PutTraceSegments` | Stores segment documents grouped by trace and reports the ones it cannot index. |
|
||||
| `BatchGetTraces` | Returns the stored segments of up to five traces, exactly as they were sent. |
|
||||
| `GetTraceSummaries` | Lists the traces in a time window, filtered by the supported expression subset. |
|
||||
| `GetServiceGraph` | Aggregates every trace in a window into services, calls between them and their counts. |
|
||||
| `GetTraceGraph` | Answers the same graph for named traces, without a window. |
|
||||
| `GetSamplingRules` | Lists the sampling rules of a Region, always including the `Default` rule AWS serves. |
|
||||
| `CreateSamplingRule` | Creates a sampling rule, minting its ARN, up to five per Region. |
|
||||
| `UpdateSamplingRule` | Changes the members supplied for a rule and keeps the rest, as AWS does. |
|
||||
| `DeleteSamplingRule` | Deletes a rule by name or ARN; the `Default` rule cannot be deleted. |
|
||||
| `GetSamplingTargets` | Answers the fixed rate and reservoir quota the daemon should sample at. |
|
||||
| `PutTelemetryRecords` | Accepts the segment and connection counters the daemon reports. |
|
||||
<!-- floci:actions:end -->
|
||||
|
||||
`PutTraceSegments` accepts up to 100 documents per call and reports the ones it refuses
|
||||
under `UnprocessedTraceSegments`, per document, instead of failing the whole request.
|
||||
`BatchGetTraces` takes up to 5 trace ids and answers the stored documents verbatim.
|
||||
|
||||
`GetTraceSummaries` takes a `StartTime`/`EndTime` window and answers one summary per trace,
|
||||
with the duration, the outcome flags, the HTTP call, the services the trace touched and the
|
||||
root segment's annotations. `FilterExpression` supports `service("name")`, the `ok`, `error`,
|
||||
`fault` and `throttle` keywords, `duration`, `responsetime`, `http.status`, `annotation.key`,
|
||||
comparisons, `AND`, `OR`, `NOT`, `!` and parentheses; anything outside that set is refused with
|
||||
`InvalidRequestException` rather than ignored, so a filter never quietly returns a superset.
|
||||
|
||||
`GetServiceGraph` and `GetTraceGraph` answer the same shape: one node per service, one edge per
|
||||
call a segment made into another, `SummaryStatistics` with ok/error/fault/throttle counts and
|
||||
`DurationHistogram` in cumulative buckets. A node's `Type` is `client` when the segment has an
|
||||
`http` block and no `aws` block, and is omitted otherwise.
|
||||
|
||||
`GetSamplingRules` always answers the `Default` rule AWS serves in every Region (priority 10000,
|
||||
fixed rate 0.05, reservoir 1), so a daemon has something to sample at before any rule exists. A
|
||||
Region takes five rules, the `Default` one excluded and not editable, and `GetSamplingTargets`
|
||||
answers each rule's fixed rate with its reservoir size as the quota, renewed every 10 seconds.
|
||||
`LastRuleModification` moves when any rule of the Region changes, so a daemon that did not name the
|
||||
changed rule still refetches the set.
|
||||
|
||||
## Not emulated
|
||||
|
||||
Floci stores, serves and aggregates traces; it does not analyse them. Insights, trace retrieval
|
||||
jobs, indexing rules, groups and tags are not served: their paths are not claimed by this service, so
|
||||
a call to them reaches whatever else claims the path (S3's `/{bucket}` routes) rather than answering
|
||||
an AWS-shaped error.
|
||||
|
||||
The rest of Floci is not instrumented either: the segments are those a client, an SDK or the daemon
|
||||
sends. Lambda and API Gateway do not emit segments of their own, so a trace that crosses them shows
|
||||
only what the caller recorded.
|
||||
|
||||
Sampling is answered, not enforced: the daemon is given a fixed rate and a reservoir quota, but the
|
||||
quota is not decremented per report, so a client keeps sampling at the rule's rate for as long as it
|
||||
runs. That is enough to exercise a trace pipeline locally and is not AWS's adaptive sampling.
|
||||
|
||||
The store is bounded: at most 10 000 traces per Region, oldest evicted first, so a long
|
||||
running emulator does not grow without bound.
|
||||
@@ -166,6 +166,7 @@ nav:
|
||||
- CloudWatch Metric Filter Verification: services/cloudwatch-metric-filters-verification.md
|
||||
- CloudWatch OAM: services/oam.md
|
||||
- CloudWatch RUM: services/rum.md
|
||||
- X-Ray: services/xray.md
|
||||
- Managed Prometheus (AMP): services/managed-prometheus.md
|
||||
- GuardDuty: services/guardduty.md
|
||||
- Connect: services/connect.md
|
||||
|
||||
@@ -875,6 +875,7 @@ public interface EmulatorConfig {
|
||||
AppIntegrationsServiceConfig appintegrations();
|
||||
DlmServiceConfig dlm();
|
||||
SignerServiceConfig signer();
|
||||
XrayServiceConfig xray();
|
||||
CognitoIdentityServiceConfig cognitoidentity();
|
||||
GlobalAcceleratorServiceConfig globalaccelerator();
|
||||
DataSyncServiceConfig datasync();
|
||||
@@ -965,6 +966,11 @@ public interface EmulatorConfig {
|
||||
boolean mockSigningJobs();
|
||||
}
|
||||
|
||||
interface XrayServiceConfig {
|
||||
@WithDefault("true")
|
||||
boolean enabled();
|
||||
}
|
||||
|
||||
interface CognitoIdentityServiceConfig {
|
||||
@WithDefault("true")
|
||||
boolean enabled();
|
||||
|
||||
@@ -108,6 +108,7 @@ import io.floci.aws.services.signin.SigninController;
|
||||
import io.floci.aws.services.ssooidc.SsoOidcController;
|
||||
import io.floci.aws.services.ssoportal.SsoPortalController;
|
||||
import io.floci.aws.services.swf.model.SwfConstants;
|
||||
import io.floci.aws.services.xray.XrayController;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
|
||||
@@ -777,6 +778,10 @@ public class ResolvedServiceCatalog {
|
||||
protocols(ServiceProtocol.REST_JSON),
|
||||
Set.of(), Set.of("app-integrations"), Set.of(),
|
||||
Set.of(AppIntegrationsController.class)),
|
||||
descriptor("xray", "xray", config.services().xray().enabled(), true,
|
||||
"xray", config.storage().mode(), 5000L, null, ServiceProtocol.REST_JSON,
|
||||
protocols(ServiceProtocol.REST_JSON),
|
||||
Set.of(), Set.of("xray"), Set.of(), Set.of(XrayController.class)),
|
||||
descriptor("dlm", "dlm", config.services().dlm().enabled(), true,
|
||||
"dlm", config.storage().mode(), 5000L, null, ServiceProtocol.REST_JSON,
|
||||
protocols(ServiceProtocol.REST_JSON),
|
||||
|
||||
@@ -0,0 +1,393 @@
|
||||
package io.floci.aws.services.xray;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.floci.aws.core.common.JsonErrorResponseUtils;
|
||||
import io.floci.aws.core.common.RegionResolver;
|
||||
import io.floci.aws.services.xray.model.SamplingRule;
|
||||
import io.floci.aws.services.xray.model.Trace;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.WebApplicationException;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import jakarta.ws.rs.core.HttpHeaders;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* X-Ray's REST JSON routes, mounted under {@link XrayRouteFilter#INTERNAL_PREFIX}.
|
||||
*
|
||||
* <p>Each method is one AWS operation and is named for it, which is what the docs action table is
|
||||
* generated from. The paths are the ones AWS declares: {@code POST /TraceSegments} for
|
||||
* {@code PutTraceSegments} and {@code POST /Traces} for {@code BatchGetTraces}.
|
||||
*/
|
||||
@Path(XrayRouteFilter.INTERNAL_PREFIX)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public class XrayController {
|
||||
|
||||
private final XrayService xrayService;
|
||||
private final RegionResolver regionResolver;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
@Inject
|
||||
public XrayController(XrayService xrayService, RegionResolver regionResolver,
|
||||
ObjectMapper objectMapper) {
|
||||
this.xrayService = xrayService;
|
||||
this.regionResolver = regionResolver;
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/TraceSegments")
|
||||
public Response putTraceSegments(@Context HttpHeaders headers, String body) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
JsonNode request = readTree(body);
|
||||
List<String> documents = new ArrayList<>();
|
||||
for (JsonNode document : request.path("TraceSegmentDocuments")) {
|
||||
documents.add(document.isTextual() ? document.asText() : document.toString());
|
||||
}
|
||||
List<XrayService.UnprocessedSegment> unprocessed =
|
||||
xrayService.putTraceSegments(documents, region);
|
||||
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
ArrayNode rejected = response.putArray("UnprocessedTraceSegments");
|
||||
for (XrayService.UnprocessedSegment segment : unprocessed) {
|
||||
ObjectNode entry = rejected.addObject();
|
||||
entry.put("Id", segment.id());
|
||||
entry.put("ErrorCode", segment.errorCode());
|
||||
entry.put("Message", segment.message());
|
||||
}
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/Traces")
|
||||
public Response batchGetTraces(@Context HttpHeaders headers, String body) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
JsonNode request = readTree(body);
|
||||
List<String> traceIds = new ArrayList<>();
|
||||
for (JsonNode id : request.path("TraceIds")) {
|
||||
traceIds.add(id.asText());
|
||||
}
|
||||
XrayService.BatchGetResult result = xrayService.batchGetTraces(traceIds, region);
|
||||
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
ArrayNode traces = response.putArray("Traces");
|
||||
for (Trace trace : result.traces()) {
|
||||
ObjectNode entry = traces.addObject();
|
||||
entry.put("Id", trace.getId());
|
||||
entry.put("Duration", trace.getEndTime() - trace.getStartTime());
|
||||
ArrayNode segments = entry.putArray("Segments");
|
||||
for (String document : trace.getDocuments()) {
|
||||
ObjectNode segment = segments.addObject();
|
||||
segment.put("Id", segmentId(document));
|
||||
segment.put("Document", document);
|
||||
}
|
||||
}
|
||||
ArrayNode unprocessed = response.putArray("UnprocessedTraceIds");
|
||||
for (String id : result.unprocessedIds()) {
|
||||
unprocessed.add(id);
|
||||
}
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
|
||||
@POST
|
||||
@Path("/TraceSummaries")
|
||||
public Response getTraceSummaries(@Context HttpHeaders headers, String body) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
JsonNode request = readTree(body);
|
||||
double startTime = requiredNumber(request, "StartTime");
|
||||
double endTime = requiredNumber(request, "EndTime");
|
||||
XrayService.SummaryPage page = xrayService.traceSummaries(startTime, endTime,
|
||||
request.path("FilterExpression").asText(null), null,
|
||||
request.path("NextToken").asText(null), region);
|
||||
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
ArrayNode summaries = response.putArray("TraceSummaries");
|
||||
for (XrayService.TraceSummary summary : page.items()) {
|
||||
summaries.add(summaryNode(summary));
|
||||
}
|
||||
response.put("ApproximateTime", page.approximateTime());
|
||||
response.put("TracesProcessedCount", page.processedCount());
|
||||
if (page.nextToken() != null) {
|
||||
response.put("NextToken", page.nextToken());
|
||||
}
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/ServiceGraph")
|
||||
public Response getServiceGraph(@Context HttpHeaders headers, String body) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
JsonNode request = readTree(body);
|
||||
double startTime = requiredNumber(request, "StartTime");
|
||||
double endTime = requiredNumber(request, "EndTime");
|
||||
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
response.put("StartTime", startTime);
|
||||
response.put("EndTime", endTime);
|
||||
ArrayNode services = response.putArray("Services");
|
||||
for (XrayGraph.Node node : xrayService.serviceGraph(startTime, endTime, region)) {
|
||||
services.add(graphNode(node));
|
||||
}
|
||||
response.put("ContainsOldGroupVersions", false);
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/TraceGraph")
|
||||
public Response getTraceGraph(@Context HttpHeaders headers, String body) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
JsonNode request = readTree(body);
|
||||
List<String> traceIds = new ArrayList<>();
|
||||
for (JsonNode id : request.path("TraceIds")) {
|
||||
traceIds.add(id.asText());
|
||||
}
|
||||
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
ArrayNode services = response.putArray("Services");
|
||||
for (XrayGraph.Node node : xrayService.traceGraph(traceIds, region)) {
|
||||
services.add(graphNode(node));
|
||||
}
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
private ObjectNode summaryNode(XrayService.TraceSummary summary) {
|
||||
ObjectNode entry = objectMapper.createObjectNode();
|
||||
entry.put("Id", summary.id());
|
||||
entry.put("StartTime", summary.startTime());
|
||||
entry.put("Duration", summary.duration());
|
||||
entry.put("ResponseTime", summary.duration());
|
||||
entry.put("HasError", summary.hasError());
|
||||
entry.put("HasFault", summary.hasFault());
|
||||
entry.put("HasThrottle", summary.hasThrottle());
|
||||
if (summary.httpMethod() != null || summary.httpUrl() != null
|
||||
|| summary.httpStatus() != null) {
|
||||
ObjectNode http = entry.putObject("Http");
|
||||
if (summary.httpMethod() != null) {
|
||||
http.put("HttpMethod", summary.httpMethod());
|
||||
}
|
||||
if (summary.httpUrl() != null) {
|
||||
http.put("HttpURL", summary.httpUrl());
|
||||
}
|
||||
if (summary.httpStatus() != null) {
|
||||
http.put("HttpStatus", summary.httpStatus());
|
||||
}
|
||||
}
|
||||
if (summary.entryPoint() != null) {
|
||||
entry.putObject("EntryPoint").put("Name", summary.entryPoint());
|
||||
}
|
||||
ArrayNode serviceIds = entry.putArray("ServiceIds");
|
||||
for (String service : summary.services()) {
|
||||
serviceIds.addObject().put("Name", service);
|
||||
}
|
||||
if (!summary.annotations().isEmpty()) {
|
||||
ObjectNode annotations = entry.putObject("Annotations");
|
||||
summary.annotations().forEach((key, value) -> {
|
||||
ObjectNode annotationValue = annotations.putArray(key).addObject()
|
||||
.putObject("AnnotationValue");
|
||||
// AnnotationValue names the same three types the model does, so a number stays a
|
||||
// number: a client reading annotations by type gets what the segment carried.
|
||||
if (value instanceof Number number) {
|
||||
annotationValue.put("NumberValue", number.doubleValue());
|
||||
} else if (value instanceof Boolean flag) {
|
||||
annotationValue.put("BooleanValue", flag);
|
||||
} else {
|
||||
annotationValue.put("StringValue", String.valueOf(value));
|
||||
}
|
||||
});
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
private ObjectNode graphNode(XrayGraph.Node node) {
|
||||
ObjectNode entry = objectMapper.createObjectNode();
|
||||
entry.put("ReferenceId", node.referenceId());
|
||||
entry.put("Name", node.name());
|
||||
if (node.type() != null) {
|
||||
entry.put("Type", node.type());
|
||||
}
|
||||
entry.putArray("Names").add(node.name());
|
||||
entry.put("State", node.state());
|
||||
entry.put("StartTime", node.startTime());
|
||||
entry.put("EndTime", node.endTime());
|
||||
ObjectNode statistics = entry.putObject("SummaryStatistics");
|
||||
statistics.put("OkCount", node.okCount());
|
||||
ObjectNode errors = statistics.putObject("ErrorStatistics");
|
||||
errors.put("ThrottleCount", node.throttleCount());
|
||||
// OtherCount is the errors that are not throttles; TotalCount is every 4xx, throttles
|
||||
// included, or a throttled call would vanish from the error total.
|
||||
errors.put("OtherCount", node.errorCount());
|
||||
errors.put("TotalCount", node.errorCount() + node.throttleCount());
|
||||
ObjectNode faults = statistics.putObject("FaultStatistics");
|
||||
faults.put("OtherCount", node.faultCount());
|
||||
faults.put("TotalCount", node.faultCount());
|
||||
statistics.put("TotalCount", node.totalCount());
|
||||
statistics.put("TotalResponseTime", node.totalResponseTime());
|
||||
ArrayNode edges = entry.putArray("Edges");
|
||||
for (XrayGraph.Edge edge : node.edges()) {
|
||||
ObjectNode edgeNode = edges.addObject();
|
||||
edgeNode.put("ReferenceId", edge.referenceId());
|
||||
edgeNode.put("StartTime", edge.startTime());
|
||||
edgeNode.put("EndTime", edge.endTime());
|
||||
ObjectNode edgeStatistics = edgeNode.putObject("SummaryStatistics");
|
||||
edgeStatistics.put("OkCount", edge.okCount());
|
||||
ObjectNode edgeErrors = edgeStatistics.putObject("ErrorStatistics");
|
||||
edgeErrors.put("ThrottleCount", edge.throttleCount());
|
||||
edgeErrors.put("OtherCount", edge.errorCount());
|
||||
edgeErrors.put("TotalCount", edge.errorCount() + edge.throttleCount());
|
||||
ObjectNode edgeFaults = edgeStatistics.putObject("FaultStatistics");
|
||||
edgeFaults.put("OtherCount", edge.faultCount());
|
||||
edgeFaults.put("TotalCount", edge.faultCount());
|
||||
edgeStatistics.put("TotalCount", edge.totalCount());
|
||||
edgeStatistics.put("TotalResponseTime", edge.totalResponseTime());
|
||||
histogram(edgeNode.putArray("ResponseTimeHistogram"), edge.responseTimeHistogram());
|
||||
}
|
||||
histogram(entry.putArray("DurationHistogram"), node.durationHistogram());
|
||||
return entry;
|
||||
}
|
||||
|
||||
private static void histogram(ArrayNode target, List<XrayGraph.HistogramEntry> entries) {
|
||||
for (XrayGraph.HistogramEntry entry : entries) {
|
||||
ObjectNode bucket = target.addObject();
|
||||
bucket.put("Value", entry.value());
|
||||
bucket.put("Count", entry.count());
|
||||
}
|
||||
}
|
||||
|
||||
private static double requiredNumber(JsonNode request, String member) {
|
||||
JsonNode value = request.path(member);
|
||||
if (!value.isNumber()) {
|
||||
throw new WebApplicationException(JsonErrorResponseUtils.createSerializationErrorResponse());
|
||||
}
|
||||
return value.asDouble();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/GetSamplingRules")
|
||||
public Response getSamplingRules(@Context HttpHeaders headers, String body) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
ArrayNode records = response.putArray("SamplingRuleRecords");
|
||||
for (SamplingRule rule : xrayService.samplingRules(region)) {
|
||||
records.add(samplingRuleRecord(rule));
|
||||
}
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/CreateSamplingRule")
|
||||
public Response createSamplingRule(@Context HttpHeaders headers, String body) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
SamplingRule rule = xrayService.createSamplingRule(readTree(body), region);
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
response.set("SamplingRuleRecord", samplingRuleRecord(rule));
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/UpdateSamplingRule")
|
||||
public Response updateSamplingRule(@Context HttpHeaders headers, String body) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
SamplingRule rule = xrayService.updateSamplingRule(readTree(body), region);
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
response.set("SamplingRuleRecord", samplingRuleRecord(rule));
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/DeleteSamplingRule")
|
||||
public Response deleteSamplingRule(@Context HttpHeaders headers, String body) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
SamplingRule rule = xrayService.deleteSamplingRule(readTree(body), region);
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
response.set("SamplingRuleRecord", samplingRuleRecord(rule));
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/SamplingTargets")
|
||||
public Response getSamplingTargets(@Context HttpHeaders headers, String body) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
XrayService.Targets targets = xrayService.samplingTargets(readTree(body), region);
|
||||
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
ArrayNode documents = response.putArray("SamplingTargetDocuments");
|
||||
for (XrayService.Target target : targets.documents()) {
|
||||
ObjectNode document = documents.addObject();
|
||||
document.put("RuleName", target.ruleName());
|
||||
document.put("FixedRate", target.fixedRate());
|
||||
document.put("ReservoirQuota", target.reservoirQuota());
|
||||
document.put("ReservoirQuotaTTL", target.reservoirQuotaTtl());
|
||||
document.put("Interval", target.interval());
|
||||
}
|
||||
response.put("LastRuleModification", targets.lastRuleModification());
|
||||
ArrayNode unprocessed = response.putArray("UnprocessedStatistics");
|
||||
for (XrayService.UnprocessedTarget target : targets.unprocessed()) {
|
||||
ObjectNode entry = unprocessed.addObject();
|
||||
entry.put("RuleName", target.ruleName());
|
||||
entry.put("ErrorCode", target.errorCode());
|
||||
entry.put("Message", target.message());
|
||||
}
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/TelemetryRecords")
|
||||
public Response putTelemetryRecords(@Context HttpHeaders headers, String body) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
xrayService.putTelemetryRecords(readTree(body), region);
|
||||
return Response.ok(objectMapper.createObjectNode()).build();
|
||||
}
|
||||
|
||||
private ObjectNode samplingRuleRecord(SamplingRule rule) {
|
||||
ObjectNode record = objectMapper.createObjectNode();
|
||||
ObjectNode ruleNode = record.putObject("SamplingRule");
|
||||
ruleNode.put("RuleName", rule.getRuleName());
|
||||
ruleNode.put("RuleARN", rule.getRuleArn());
|
||||
ruleNode.put("ResourceARN", rule.getResourceArn());
|
||||
ruleNode.put("Priority", rule.getPriority());
|
||||
ruleNode.put("FixedRate", rule.getFixedRate());
|
||||
ruleNode.put("ReservoirSize", rule.getReservoirSize());
|
||||
ruleNode.put("ServiceName", rule.getServiceName());
|
||||
ruleNode.put("ServiceType", rule.getServiceType());
|
||||
ruleNode.put("Host", rule.getHost());
|
||||
ruleNode.put("HTTPMethod", rule.getHttpMethod());
|
||||
ruleNode.put("URLPath", rule.getUrlPath());
|
||||
ruleNode.put("Version", rule.getVersion());
|
||||
if (!rule.getAttributes().isEmpty()) {
|
||||
ObjectNode attributes = ruleNode.putObject("Attributes");
|
||||
rule.getAttributes().forEach(attributes::put);
|
||||
}
|
||||
record.put("CreatedAt", rule.getCreatedAt());
|
||||
record.put("ModifiedAt", rule.getModifiedAt());
|
||||
return record;
|
||||
}
|
||||
|
||||
/** The segment id a stored document carries, which the segment entry reports beside it. */
|
||||
private String segmentId(String document) {
|
||||
try {
|
||||
return objectMapper.readTree(document).path("id").asText("");
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private JsonNode readTree(String body) {
|
||||
try {
|
||||
return objectMapper.readTree(body == null || body.isBlank() ? "{}" : body);
|
||||
} catch (Exception e) {
|
||||
throw new WebApplicationException(JsonErrorResponseUtils.createSerializationErrorResponse());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,303 @@
|
||||
package io.floci.aws.services.xray;
|
||||
|
||||
import io.floci.aws.core.common.AwsException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.ToDoubleFunction;
|
||||
|
||||
/**
|
||||
* The subset of X-Ray's filter expression grammar that {@code GetTraceSummaries} honours.
|
||||
*
|
||||
* <p>AWS's grammar is large and much of it (insights, edge predicates over the service graph,
|
||||
* sampling) needs an index Floci does not keep. Rather than accept an expression and quietly ignore
|
||||
* the part it does not understand, Floci parses what it supports and refuses the rest with
|
||||
* {@code InvalidRequestException} naming the token it stopped at, which is the difference between a
|
||||
* caller trusting a filter and a caller getting a superset.
|
||||
*
|
||||
* <p>Supported: {@code service("name")}, the {@code ok}, {@code error}, {@code fault} and
|
||||
* {@code throttle} keywords,
|
||||
* {@code duration}, {@code responsetime}, {@code http.status}, {@code annotation.key},
|
||||
* comparisons ({@code = != < <= > >=}), {@code AND}, {@code OR}, {@code NOT} and parentheses.
|
||||
*/
|
||||
final class XrayFilterExpression {
|
||||
|
||||
/** What a filter is evaluated against: one trace, as the summaries see it. */
|
||||
record Facts(Set<String> services, boolean hasError, boolean hasFault, boolean hasThrottle,
|
||||
double duration, Integer httpStatus, Map<String, Object> annotations) {
|
||||
}
|
||||
|
||||
private final String source;
|
||||
private final List<String> tokens;
|
||||
private int position;
|
||||
|
||||
private XrayFilterExpression(String source, List<String> tokens) {
|
||||
this.source = source;
|
||||
this.tokens = tokens;
|
||||
}
|
||||
|
||||
static Predicate<Facts> compile(String expression) {
|
||||
if (expression == null || expression.isBlank()) {
|
||||
return facts -> true;
|
||||
}
|
||||
XrayFilterExpression parser = new XrayFilterExpression(expression, tokenize(expression));
|
||||
Predicate<Facts> predicate = parser.parseOr();
|
||||
if (parser.position < parser.tokens.size()) {
|
||||
throw parser.invalid("unexpected '" + parser.peek() + "'");
|
||||
}
|
||||
return predicate;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- grammar
|
||||
|
||||
private Predicate<Facts> parseOr() {
|
||||
Predicate<Facts> left = parseAnd();
|
||||
while (isKeyword("OR")) {
|
||||
position++;
|
||||
Predicate<Facts> right = parseAnd();
|
||||
Predicate<Facts> previous = left;
|
||||
left = facts -> previous.test(facts) || right.test(facts);
|
||||
}
|
||||
return left;
|
||||
}
|
||||
|
||||
private Predicate<Facts> parseAnd() {
|
||||
Predicate<Facts> left = parseUnary();
|
||||
while (isKeyword("AND")) {
|
||||
position++;
|
||||
Predicate<Facts> right = parseUnary();
|
||||
Predicate<Facts> previous = left;
|
||||
left = facts -> previous.test(facts) && right.test(facts);
|
||||
}
|
||||
return left;
|
||||
}
|
||||
|
||||
private Predicate<Facts> parseUnary() {
|
||||
if (isKeyword("NOT") || "!".equals(peek())) {
|
||||
position++;
|
||||
Predicate<Facts> inner = parseUnary();
|
||||
return facts -> !inner.test(facts);
|
||||
}
|
||||
if ("(".equals(peek())) {
|
||||
position++;
|
||||
Predicate<Facts> inner = parseOr();
|
||||
expect(")");
|
||||
return inner;
|
||||
}
|
||||
return parsePredicate();
|
||||
}
|
||||
|
||||
private Predicate<Facts> parsePredicate() {
|
||||
String name = next();
|
||||
if (name == null) {
|
||||
throw invalid("the expression ends where a predicate was expected");
|
||||
}
|
||||
switch (name) {
|
||||
// These four are the whole keyword set AWS documents. There are no has* spellings, so
|
||||
// accepting one here would let a filter pass locally and fail against AWS.
|
||||
case "error":
|
||||
return Facts::hasError;
|
||||
case "fault":
|
||||
return Facts::hasFault;
|
||||
case "throttle":
|
||||
return Facts::hasThrottle;
|
||||
case "ok":
|
||||
return facts -> !facts.hasError() && !facts.hasFault() && !facts.hasThrottle();
|
||||
case "service":
|
||||
expect("(");
|
||||
String service = literal();
|
||||
expect(")");
|
||||
return facts -> facts.services().contains(service);
|
||||
case "duration":
|
||||
return numberComparison(name, Facts::duration);
|
||||
case "responsetime":
|
||||
// AWS measures it in seconds, the same unit as duration; only the moment it
|
||||
// marks differs, and a trace summary carries one duration for both.
|
||||
return numberComparison(name, Facts::duration);
|
||||
case "http.status": {
|
||||
String operator = nextOperator();
|
||||
double expected = number();
|
||||
return facts -> compare(facts.httpStatus(), operator, expected);
|
||||
}
|
||||
default:
|
||||
if (name.startsWith("annotation.")) {
|
||||
String key = name.substring("annotation.".length());
|
||||
String operator = nextOperator();
|
||||
String expected = literalOrNumber();
|
||||
return facts -> {
|
||||
Object stored = facts.annotations().get(key);
|
||||
if (stored == null) {
|
||||
return false;
|
||||
}
|
||||
String actual = String.valueOf(stored);
|
||||
if ("=".equals(operator) || "!=".equals(operator)) {
|
||||
boolean equal = actual.equals(expected);
|
||||
return "=".equals(operator) == equal;
|
||||
}
|
||||
return compare(parseDouble(actual), operator, parseDouble(expected));
|
||||
};
|
||||
}
|
||||
throw invalid("'" + name + "' is not a predicate Floci evaluates");
|
||||
}
|
||||
}
|
||||
|
||||
private Predicate<Facts> numberComparison(String name, ToDoubleFunction<Facts> value) {
|
||||
String operator = nextOperator();
|
||||
double expected = number();
|
||||
return facts -> compare(value.applyAsDouble(facts), operator, expected);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- helpers
|
||||
|
||||
private static boolean compare(Integer actual, String operator, double expected) {
|
||||
return actual != null && compare(actual.doubleValue(), operator, expected);
|
||||
}
|
||||
|
||||
private static boolean compare(double actual, String operator, double expected) {
|
||||
return switch (operator) {
|
||||
case "=" -> actual == expected;
|
||||
case "!=" -> actual != expected;
|
||||
case "<" -> actual < expected;
|
||||
case "<=" -> actual <= expected;
|
||||
case ">" -> actual > expected;
|
||||
case ">=" -> actual >= expected;
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
|
||||
private String nextOperator() {
|
||||
String token = next();
|
||||
if (token == null || !Set.of("=", "!=", "<", "<=", ">", ">=").contains(token)) {
|
||||
throw invalid("expected a comparison after the field, found '" + token + "'");
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
private boolean isKeyword(String keyword) {
|
||||
return keyword.equalsIgnoreCase(peek());
|
||||
}
|
||||
|
||||
private String peek() {
|
||||
return position < tokens.size() ? tokens.get(position) : null;
|
||||
}
|
||||
|
||||
private String next() {
|
||||
if (position >= tokens.size()) {
|
||||
return null;
|
||||
}
|
||||
return tokens.get(position++);
|
||||
}
|
||||
|
||||
private void expect(String token) {
|
||||
String actual = next();
|
||||
if (!token.equals(actual)) {
|
||||
throw invalid("expected '" + token + "', found '" + actual + "'");
|
||||
}
|
||||
}
|
||||
|
||||
private String literal() {
|
||||
String token = next();
|
||||
if (token == null || token.length() < 2 || !token.startsWith("\"") || !token.endsWith("\"")) {
|
||||
throw invalid("expected a quoted string, found '" + token + "'");
|
||||
}
|
||||
return token.substring(1, token.length() - 1);
|
||||
}
|
||||
|
||||
private String literalOrNumber() {
|
||||
String token = peek();
|
||||
if (token == null) {
|
||||
throw invalid("expected a value");
|
||||
}
|
||||
return token.startsWith("\"") ? literal() : next();
|
||||
}
|
||||
|
||||
private double number() {
|
||||
String token = next();
|
||||
try {
|
||||
return Double.parseDouble(token);
|
||||
} catch (RuntimeException e) {
|
||||
throw invalid("expected a number, found '" + token + "'");
|
||||
}
|
||||
}
|
||||
|
||||
private static double parseDouble(String value) {
|
||||
try {
|
||||
return Double.parseDouble(value);
|
||||
} catch (RuntimeException e) {
|
||||
return Double.NaN;
|
||||
}
|
||||
}
|
||||
|
||||
private AwsException invalid(String reason) {
|
||||
return new AwsException("InvalidRequestException",
|
||||
"The filter expression '" + source + "' is not supported: " + reason + ".", 400);
|
||||
}
|
||||
|
||||
/** Splits an expression into identifiers, quoted strings, numbers and operators. */
|
||||
private static List<String> tokenize(String expression) {
|
||||
List<String> tokens = new ArrayList<>();
|
||||
int i = 0;
|
||||
while (i < expression.length()) {
|
||||
char c = expression.charAt(i);
|
||||
if (Character.isWhitespace(c)) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
if (c == '"') {
|
||||
int end = expression.indexOf('"', i + 1);
|
||||
if (end < 0) {
|
||||
throw new AwsException("InvalidRequestException",
|
||||
"The filter expression has an unterminated string.", 400);
|
||||
}
|
||||
tokens.add(expression.substring(i, end + 1));
|
||||
i = end + 1;
|
||||
continue;
|
||||
}
|
||||
if (c == '(' || c == ')' || c == ',') {
|
||||
tokens.add(String.valueOf(c));
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
if (c == '!') {
|
||||
if (i + 1 < expression.length() && expression.charAt(i + 1) == '=') {
|
||||
tokens.add("!=");
|
||||
i += 2;
|
||||
} else {
|
||||
// A lone '!' is the negation operator; parseUnary consumes it. It is emitted
|
||||
// as its own token rather than left as a delimiter with no branch, which would
|
||||
// spin here forever on no progress.
|
||||
tokens.add("!");
|
||||
i++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (c == '<' || c == '>' || c == '=') {
|
||||
if (i + 1 < expression.length() && expression.charAt(i + 1) == '=') {
|
||||
tokens.add(expression.substring(i, i + 2));
|
||||
i += 2;
|
||||
} else {
|
||||
tokens.add(String.valueOf(c));
|
||||
i++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
int start = i;
|
||||
while (i < expression.length()) {
|
||||
char current = expression.charAt(i);
|
||||
if (Character.isWhitespace(current) || "()\",<>=!".indexOf(current) >= 0) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (start == i) {
|
||||
throw new AwsException("InvalidRequestException",
|
||||
"The filter expression has an unexpected '" + c + "'.", 400);
|
||||
}
|
||||
tokens.add(expression.substring(start, i));
|
||||
}
|
||||
return tokens;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
package io.floci.aws.services.xray;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Builds the service graph X-Ray answers from traces: one node per service, one edge per call a
|
||||
* segment made into another service, with the counts and timings aggregated over the window.
|
||||
*
|
||||
* <p>A node is a segment's {@code name} plus the type a document can imply, so the same service
|
||||
* across many traces collapses into one node. An edge exists when a segment's {@code parent_id}
|
||||
* names another segment in the same trace, which is how the SDK records "A called B".
|
||||
*/
|
||||
final class XrayGraph {
|
||||
|
||||
/** One node of the graph, aggregated over every trace in the window. */
|
||||
record Node(int referenceId, String name, String type, String state, double startTime,
|
||||
double endTime, long okCount, long errorCount, long throttleCount, long faultCount,
|
||||
long totalCount, double totalResponseTime, List<Edge> edges,
|
||||
List<HistogramEntry> durationHistogram) {
|
||||
}
|
||||
|
||||
/** A call from one node into another. */
|
||||
record Edge(int referenceId, double startTime, double endTime, long okCount, long errorCount,
|
||||
long throttleCount, long faultCount, long totalCount, double totalResponseTime,
|
||||
List<HistogramEntry> responseTimeHistogram) {
|
||||
}
|
||||
|
||||
/** One bucket of a histogram: the upper bound in seconds and how many calls fell at or below. */
|
||||
record HistogramEntry(double value, long count) {
|
||||
}
|
||||
|
||||
/** AWS's fixed bucket edges, in seconds. */
|
||||
private static final double[] BUCKETS = {0.005, 0.01, 0.05, 0.1, 0.5, 1, 5, 10, 30};
|
||||
|
||||
private XrayGraph() {
|
||||
}
|
||||
|
||||
static List<Node> build(List<List<XraySegments.Node>> traces) {
|
||||
Map<String, Accumulator> nodes = new LinkedHashMap<>();
|
||||
Map<EdgeKey, EdgeAccumulator> edges = new LinkedHashMap<>();
|
||||
for (List<XraySegments.Node> nodesOfTrace : traces) {
|
||||
Map<String, XraySegments.Node> byId = new LinkedHashMap<>();
|
||||
for (XraySegments.Node node : nodesOfTrace) {
|
||||
byId.put(node.id(), node);
|
||||
}
|
||||
for (XraySegments.Node node : nodesOfTrace) {
|
||||
Accumulator accumulator = nodes.computeIfAbsent(key(node), ignored -> new Accumulator(node));
|
||||
accumulator.add(node);
|
||||
XraySegments.Node parent = byId.get(node.parentId());
|
||||
if (parent != null && !key(parent).equals(key(node))) {
|
||||
EdgeAccumulator edge = edges.computeIfAbsent(new EdgeKey(key(parent), key(node)),
|
||||
ignored -> new EdgeAccumulator(referenceId(key(node))));
|
||||
edge.add(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Map.Entry<EdgeKey, EdgeAccumulator> entry : edges.entrySet()) {
|
||||
Accumulator from = nodes.get(entry.getKey().from());
|
||||
Accumulator to = nodes.get(entry.getKey().to());
|
||||
if (from != null && to != null) {
|
||||
from.edges.add(entry.getValue().toEdge());
|
||||
}
|
||||
}
|
||||
List<Node> result = new ArrayList<>();
|
||||
for (Accumulator accumulator : nodes.values()) {
|
||||
result.add(accumulator.toNode());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* A node is a service, so its name alone identifies it: the same service seen once with an
|
||||
* {@code http} block and once without is one node, not two.
|
||||
*/
|
||||
private static String key(XraySegments.Node node) {
|
||||
return node.name();
|
||||
}
|
||||
|
||||
/** An edge's ends, kept as the two names: joining them into one string breaks on a name that
|
||||
* contains the separator, which a service name is free to do. */
|
||||
private record EdgeKey(String from, String to) {
|
||||
}
|
||||
|
||||
/** AWS's graph answers an integer reference per node, so a stable one is derived from its key. */
|
||||
private static int referenceId(String key) {
|
||||
try {
|
||||
byte[] digest = MessageDigest.getInstance("SHA-256").digest(key.getBytes(StandardCharsets.UTF_8));
|
||||
return ((digest[0] & 0xff) << 24 | (digest[1] & 0xff) << 16
|
||||
| (digest[2] & 0xff) << 8 | (digest[3] & 0xff)) & 0x7fffffff;
|
||||
} catch (Exception e) {
|
||||
return key.hashCode() & 0x7fffffff;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The four outcome counts, one per subsegment: fault, throttle, error or ok, in that order of
|
||||
* precedence. A subsegment is counted once, so the four add up to the number of calls, and a
|
||||
* 429 that also carries the error flag is a throttle because that is what it was.
|
||||
*/
|
||||
private static final class Counts {
|
||||
private long ok;
|
||||
private long error;
|
||||
private long throttle;
|
||||
private long fault;
|
||||
|
||||
void add(XraySegments.Node node) {
|
||||
if (node.fault()) {
|
||||
fault++;
|
||||
} else if (node.throttle()) {
|
||||
throttle++;
|
||||
} else if (node.error()) {
|
||||
error++;
|
||||
} else {
|
||||
ok++;
|
||||
}
|
||||
}
|
||||
|
||||
/** Every subsegment, counted once: the four columns partition the set rather than overlap. */
|
||||
long total() {
|
||||
return ok + error + throttle + fault;
|
||||
}
|
||||
}
|
||||
|
||||
private static class Accumulator {
|
||||
private final int referenceId;
|
||||
private final String name;
|
||||
private String type;
|
||||
private final List<Edge> edges = new ArrayList<>();
|
||||
private double startTime = Double.MAX_VALUE;
|
||||
private double endTime = -Double.MAX_VALUE;
|
||||
private final Counts counts = new Counts();
|
||||
private double totalResponseTime;
|
||||
private final List<Double> durations = new ArrayList<>();
|
||||
|
||||
Accumulator(XraySegments.Node node) {
|
||||
this.referenceId = referenceId(key(node));
|
||||
this.name = node.name();
|
||||
this.type = node.type();
|
||||
}
|
||||
|
||||
void add(XraySegments.Node node) {
|
||||
if (type == null) {
|
||||
type = node.type();
|
||||
}
|
||||
startTime = Math.min(startTime, node.startTime());
|
||||
endTime = Math.max(endTime, node.endTime());
|
||||
totalResponseTime += node.duration();
|
||||
durations.add(node.duration());
|
||||
counts.add(node);
|
||||
}
|
||||
|
||||
String state() {
|
||||
if (counts.fault > 0) {
|
||||
return "fault";
|
||||
}
|
||||
if (counts.throttle > 0) {
|
||||
return "throttle";
|
||||
}
|
||||
if (counts.error > 0) {
|
||||
return "error";
|
||||
}
|
||||
return "ok";
|
||||
}
|
||||
|
||||
Node toNode() {
|
||||
return new Node(referenceId, name, type, state(), startTime, endTime, counts.ok, counts.error,
|
||||
counts.throttle, counts.fault, counts.total(), totalResponseTime, List.copyOf(edges),
|
||||
histogram(durations));
|
||||
}
|
||||
}
|
||||
|
||||
private static class EdgeAccumulator {
|
||||
private final int toReferenceId;
|
||||
private double startTime = Double.MAX_VALUE;
|
||||
private double endTime = -Double.MAX_VALUE;
|
||||
private final Counts counts = new Counts();
|
||||
private double totalResponseTime;
|
||||
private final List<Double> durations = new ArrayList<>();
|
||||
|
||||
EdgeAccumulator(int toReferenceId) {
|
||||
this.toReferenceId = toReferenceId;
|
||||
}
|
||||
|
||||
void add(XraySegments.Node node) {
|
||||
startTime = Math.min(startTime, node.startTime());
|
||||
endTime = Math.max(endTime, node.endTime());
|
||||
totalResponseTime += node.duration();
|
||||
durations.add(node.duration());
|
||||
counts.add(node);
|
||||
}
|
||||
|
||||
Edge toEdge() {
|
||||
// AWS's Edge names the destination: that is the node the arrow lands on.
|
||||
return new Edge(toReferenceId, startTime, endTime, counts.ok, counts.error, counts.throttle,
|
||||
counts.fault, counts.total(), totalResponseTime, histogram(durations));
|
||||
}
|
||||
}
|
||||
|
||||
/** Cumulative buckets, so the last entry counts every call in the set. */
|
||||
static List<HistogramEntry> histogram(List<Double> durations) {
|
||||
List<HistogramEntry> entries = new ArrayList<>();
|
||||
for (double bucket : BUCKETS) {
|
||||
long count = durations.stream().filter(duration -> duration <= bucket).count();
|
||||
entries.add(new HistogramEntry(bucket, count));
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package io.floci.aws.services.xray;
|
||||
|
||||
import io.floci.aws.core.common.ResolvedServiceCatalog;
|
||||
import io.floci.aws.core.common.SignedServiceRoute;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.container.ContainerRequestContext;
|
||||
import jakarta.ws.rs.container.ContainerRequestFilter;
|
||||
import jakarta.ws.rs.container.PreMatching;
|
||||
import jakarta.ws.rs.ext.Provider;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Rewrites X-Ray requests to an internal prefix before JAX-RS route matching.
|
||||
*
|
||||
* <p>Every X-Ray operation is a {@code POST} on a literal path ({@code /TraceSegments},
|
||||
* {@code /Traces}, {@code /ServiceGraph}), which S3's path-style routes would read as a bucket,
|
||||
* so a request signed for {@code xray} is moved onto {@link #INTERNAL_PREFIX} and any other request
|
||||
* keeps its path. Only the paths this service serves are claimed, so an X-Ray route it does not
|
||||
* answer yet still reaches whatever else claims it.
|
||||
*/
|
||||
@Provider
|
||||
@PreMatching
|
||||
public class XrayRouteFilter implements ContainerRequestFilter {
|
||||
|
||||
static final String INTERNAL_PREFIX = "/_xray";
|
||||
|
||||
/** The literal paths this service serves, as AWS declares them for each operation. */
|
||||
private static final Set<String> SERVED_PATHS = Set.of("/TraceSegments", "/Traces",
|
||||
"/TraceSummaries", "/ServiceGraph", "/TraceGraph", "/GetSamplingRules",
|
||||
"/CreateSamplingRule", "/UpdateSamplingRule", "/DeleteSamplingRule",
|
||||
"/SamplingTargets", "/TelemetryRecords");
|
||||
|
||||
private static final Predicate<String> PUBLIC_PATHS = SERVED_PATHS::contains;
|
||||
|
||||
private final SignedServiceRoute route;
|
||||
|
||||
@Inject
|
||||
public XrayRouteFilter(ResolvedServiceCatalog catalog) {
|
||||
this.route = new SignedServiceRoute(catalog, "xray", INTERNAL_PREFIX, PUBLIC_PATHS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void filter(ContainerRequestContext ctx) {
|
||||
route.apply(ctx);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package io.floci.aws.services.xray;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The parts of a segment document Floci indexes: one entry per segment and subsegment, flattened,
|
||||
* with the identifiers, timing, outcome flags and annotations the summaries and the service graph
|
||||
* are built from.
|
||||
*
|
||||
* <p>A document holds a root segment and, nested under {@code subsegments}, the calls it made.
|
||||
* Floci keeps the documents verbatim, so every reader walks them here rather than parsing twice.
|
||||
*/
|
||||
final class XraySegments {
|
||||
|
||||
/** One segment or subsegment, as far as X-Ray's own readers need it. */
|
||||
record Node(String traceId, String id, String parentId, String name, double startTime,
|
||||
double endTime, boolean fault, boolean error, boolean throttle, Integer httpStatus,
|
||||
String httpMethod, String httpUrl, boolean hasAws, Map<String, Object> annotations) {
|
||||
|
||||
double duration() {
|
||||
return endTime - startTime;
|
||||
}
|
||||
|
||||
/** What the service graph calls this node's type, as far as a document can tell. */
|
||||
String type() {
|
||||
if (hasAws) {
|
||||
return null;
|
||||
}
|
||||
return httpStatus != null || httpUrl != null ? "client" : null;
|
||||
}
|
||||
}
|
||||
|
||||
private XraySegments() {
|
||||
}
|
||||
|
||||
/** Every segment and subsegment a document holds, parents before children. */
|
||||
static List<Node> flatten(String document, ObjectMapperHolder mapper) {
|
||||
List<Node> nodes = new ArrayList<>();
|
||||
JsonNode root;
|
||||
try {
|
||||
root = mapper.read(document);
|
||||
} catch (Exception e) {
|
||||
return nodes;
|
||||
}
|
||||
collect(root, null, null, nodes);
|
||||
return nodes;
|
||||
}
|
||||
|
||||
private static void collect(JsonNode node, String traceId, String parentId, List<Node> out) {
|
||||
if (!node.isObject()) {
|
||||
return;
|
||||
}
|
||||
String resolvedTraceId = node.path("trace_id").asText(traceId == null ? "" : traceId);
|
||||
String id = node.path("id").asText("");
|
||||
double start = node.path("start_time").asDouble(Double.NaN);
|
||||
double end = node.path("end_time").asDouble(Double.NaN);
|
||||
if (!id.isEmpty() && !Double.isNaN(start) && !Double.isNaN(end) && end >= start) {
|
||||
JsonNode http = node.path("http");
|
||||
JsonNode response = http.path("response");
|
||||
JsonNode request = http.path("request");
|
||||
out.add(new Node(resolvedTraceId, id,
|
||||
node.path("parent_id").asText(parentId == null ? "" : parentId),
|
||||
node.path("name").asText(""), start, end,
|
||||
node.path("fault").asBoolean(false), node.path("error").asBoolean(false),
|
||||
node.path("throttle").asBoolean(false),
|
||||
response.has("status") ? Integer.valueOf(response.path("status").asInt()) : null,
|
||||
request.path("method").asText(null), request.path("url").asText(null),
|
||||
node.has("aws"), annotations(node.path("annotations"))));
|
||||
}
|
||||
for (JsonNode child : node.path("subsegments")) {
|
||||
collect(child, resolvedTraceId, id, out);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An annotation keeps the JSON type a segment gave it, because {@code AnnotationValue} answers
|
||||
* a number as {@code NumberValue} and a boolean as {@code BooleanValue}. A list or an object
|
||||
* is not an annotation AWS accepts, so it is dropped rather than flattened into text.
|
||||
*/
|
||||
private static Map<String, Object> annotations(JsonNode node) {
|
||||
Map<String, Object> annotations = new LinkedHashMap<>();
|
||||
if (node.isObject()) {
|
||||
node.fields().forEachRemaining(entry -> {
|
||||
JsonNode value = entry.getValue();
|
||||
if (value.isTextual()) {
|
||||
annotations.put(entry.getKey(), value.asText());
|
||||
} else if (value.isNumber()) {
|
||||
annotations.put(entry.getKey(), value.numberValue());
|
||||
} else if (value.isBoolean()) {
|
||||
annotations.put(entry.getKey(), value.booleanValue());
|
||||
}
|
||||
});
|
||||
}
|
||||
return annotations;
|
||||
}
|
||||
|
||||
/** Reads a document's JSON; kept behind an interface so this class stays free of Jackson wiring. */
|
||||
interface ObjectMapperHolder {
|
||||
JsonNode read(String document);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,712 @@
|
||||
package io.floci.aws.services.xray;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.floci.aws.core.common.AwsArnUtils;
|
||||
import io.floci.aws.core.common.AwsException;
|
||||
import io.floci.aws.core.common.PaginatedResult;
|
||||
import io.floci.aws.core.common.Pagination;
|
||||
import io.floci.aws.core.common.Resettable;
|
||||
import io.floci.aws.core.storage.AccountAwareStorageBackend;
|
||||
import io.floci.aws.core.storage.StorageFactory;
|
||||
import io.floci.aws.services.xray.model.SamplingRule;
|
||||
import io.floci.aws.services.xray.model.Trace;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* The X-Ray trace store: the segments a client sent, grouped by trace, read back as they were sent.
|
||||
*
|
||||
* <p>A segment document is AWS's own JSON and Floci keeps it verbatim, because {@code BatchGetTraces}
|
||||
* must answer exactly what {@code PutTraceSegments} accepted. Only the identifiers and timing are
|
||||
* parsed, for retention and for the summaries and service graph computed from the documents.
|
||||
*
|
||||
* <p>A local emulator runs for days, so the store is bounded: at most {@link #MAX_TRACES} traces and
|
||||
* nothing older than {@link #RETENTION_SECONDS}, the same 30 day window AWS keeps, with the oldest
|
||||
* trace evicted first.
|
||||
*/
|
||||
@ApplicationScoped
|
||||
public class XrayService implements Resettable {
|
||||
|
||||
static final String SERVICE = "xray";
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(XrayService.class);
|
||||
private static final Pattern TRACE_ID = Pattern.compile("(1-)?[0-9a-f]{8}-[0-9a-f]{24}|[0-9a-f]{32}");
|
||||
private static final Pattern SEGMENT_ID = Pattern.compile("[0-9a-f]{16}");
|
||||
private static final int MAX_TRACES = 10_000;
|
||||
private static final long RETENTION_SECONDS = 30L * 24 * 60 * 60;
|
||||
private static final int MAX_DOCUMENTS_PER_CALL = 100;
|
||||
private static final int MAX_TRACE_IDS_PER_CALL = 5;
|
||||
/** AWS caps a summaries page at 100 trace summaries. */
|
||||
private static final int MAX_SUMMARIES_PAGE = 100;
|
||||
|
||||
private final AccountAwareStorageBackend<Trace> traces;
|
||||
private final AccountAwareStorageBackend<SamplingRule> rules;
|
||||
/**
|
||||
* A monitor per Region. The stores are read-modify-write over a documented-heap backend, so two
|
||||
* services posting segments of the same trace would otherwise drop one, and two creates of the
|
||||
* same rule would both pass the duplicate check. Keyed by Region because that is the scope both
|
||||
* operations are counted in.
|
||||
*/
|
||||
private final ConcurrentHashMap<String, Object> regionLocks = new ConcurrentHashMap<>();
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
@Inject
|
||||
public XrayService(StorageFactory storageFactory) {
|
||||
this(storageFactory.create(SERVICE, "xray-traces.json",
|
||||
new TypeReference<Map<String, Trace>>() {}),
|
||||
storageFactory.create(SERVICE, "xray-sampling-rules.json",
|
||||
new TypeReference<Map<String, SamplingRule>>() {}));
|
||||
}
|
||||
|
||||
XrayService(AccountAwareStorageBackend<Trace> traces, AccountAwareStorageBackend<SamplingRule> rules) {
|
||||
this.traces = traces;
|
||||
this.rules = rules;
|
||||
}
|
||||
|
||||
/** One document X-Ray refused, with the code and message it reports for it. */
|
||||
public record UnprocessedSegment(String id, String errorCode, String message) {
|
||||
}
|
||||
|
||||
/** The traces a caller asked for, and the ids that named nothing. */
|
||||
public record BatchGetResult(List<Trace> traces, List<String> unprocessedIds) {
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ ingest
|
||||
|
||||
public List<UnprocessedSegment> putTraceSegments(List<String> documents, String region) {
|
||||
if (documents == null || documents.isEmpty()) {
|
||||
throw validation("TraceSegmentDocuments is required.");
|
||||
}
|
||||
if (documents.size() > MAX_DOCUMENTS_PER_CALL) {
|
||||
throw validation("A PutTraceSegments request carries at most " + MAX_DOCUMENTS_PER_CALL
|
||||
+ " segments, got " + documents.size() + ".");
|
||||
}
|
||||
List<UnprocessedSegment> unprocessed = new ArrayList<>();
|
||||
synchronized (lockFor(region)) {
|
||||
storeDocuments(documents, region, unprocessed);
|
||||
}
|
||||
LOG.debugv("Stored {0} of {1} segments", documents.size() - unprocessed.size(), documents.size());
|
||||
return unprocessed;
|
||||
}
|
||||
|
||||
private void storeDocuments(List<String> documents, String region, List<UnprocessedSegment> unprocessed) {
|
||||
for (String document : documents) {
|
||||
JsonNode node;
|
||||
try {
|
||||
node = objectMapper.readTree(document);
|
||||
} catch (Exception e) {
|
||||
unprocessed.add(new UnprocessedSegment("", "InvalidSegment",
|
||||
"The segment document is not valid JSON."));
|
||||
continue;
|
||||
}
|
||||
String problem = validationProblem(node);
|
||||
if (problem != null) {
|
||||
unprocessed.add(new UnprocessedSegment(node.path("id").asText(""), "InvalidSegment", problem));
|
||||
continue;
|
||||
}
|
||||
store(node, document, region);
|
||||
}
|
||||
evict(region);
|
||||
}
|
||||
|
||||
private static String validationProblem(JsonNode node) {
|
||||
if (!node.isObject()) {
|
||||
return "The segment document must be a JSON object.";
|
||||
}
|
||||
String traceId = node.path("trace_id").asText("");
|
||||
if (!TRACE_ID.matcher(traceId).matches()) {
|
||||
return "trace_id must be a 96 bit hex identifier, got " + traceId + ".";
|
||||
}
|
||||
String id = node.path("id").asText("");
|
||||
if (!SEGMENT_ID.matcher(id).matches()) {
|
||||
return "id must be a 64 bit hex identifier, got " + id + ".";
|
||||
}
|
||||
if (node.path("name").asText("").isEmpty()) {
|
||||
return "name is required.";
|
||||
}
|
||||
if (!node.path("start_time").isNumber()) {
|
||||
return "start_time must be a number of epoch seconds.";
|
||||
}
|
||||
// A segment still in flight has no end_time yet, which AWS accepts: refusing it would make
|
||||
// every long-running subsegment unrecordable.
|
||||
if (node.has("end_time")) {
|
||||
if (!node.path("end_time").isNumber()) {
|
||||
return "end_time must be a number of epoch seconds.";
|
||||
}
|
||||
if (node.path("end_time").asDouble() < node.path("start_time").asDouble()) {
|
||||
return "end_time is before start_time.";
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void store(JsonNode document, String raw, String region) {
|
||||
String traceId = document.path("trace_id").asText();
|
||||
double start = document.path("start_time").asDouble();
|
||||
double end = document.has("end_time") ? document.path("end_time").asDouble() : start;
|
||||
Trace trace = traces.get(storageKey(region, traceId)).orElse(null);
|
||||
if (trace == null) {
|
||||
trace = new Trace();
|
||||
trace.setId(traceId);
|
||||
trace.setStartTime(start);
|
||||
trace.setEndTime(end);
|
||||
} else {
|
||||
trace.setStartTime(Math.min(trace.getStartTime(), start));
|
||||
trace.setEndTime(Math.max(trace.getEndTime(), end));
|
||||
}
|
||||
// The list a reader holds must not change under it: summaries and BatchGetTraces walk the
|
||||
// documents of a stored trace while segments keep arriving, so this builds the new list
|
||||
// and swaps it in rather than editing the one already published.
|
||||
String segmentId = document.path("id").asText();
|
||||
List<String> documents = new ArrayList<>();
|
||||
for (String stored : trace.getDocuments()) {
|
||||
if (!segmentId.equals(segmentIdOf(stored))) {
|
||||
documents.add(stored);
|
||||
}
|
||||
}
|
||||
documents.add(raw);
|
||||
trace.setDocuments(documents);
|
||||
if (document.path("fault").asBoolean(false)) {
|
||||
trace.setFault(true);
|
||||
}
|
||||
if (document.path("error").asBoolean(false)) {
|
||||
trace.setError(true);
|
||||
}
|
||||
if (document.path("throttle").asBoolean(false)) {
|
||||
trace.setThrottle(true);
|
||||
}
|
||||
traces.put(storageKey(region, traceId), trace);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------- read
|
||||
|
||||
public BatchGetResult batchGetTraces(List<String> traceIds, String region) {
|
||||
if (traceIds == null || traceIds.isEmpty()) {
|
||||
throw validation("TraceIds is required.");
|
||||
}
|
||||
if (traceIds.size() > MAX_TRACE_IDS_PER_CALL) {
|
||||
throw validation("A BatchGetTraces request carries at most " + MAX_TRACE_IDS_PER_CALL
|
||||
+ " trace ids, got " + traceIds.size() + ".");
|
||||
}
|
||||
long oldest = Instant.now().getEpochSecond() - RETENTION_SECONDS;
|
||||
List<Trace> found = new ArrayList<>();
|
||||
List<String> missing = new ArrayList<>();
|
||||
for (String traceId : traceIds) {
|
||||
Trace trace = traces.get(storageKey(region, traceId)).orElse(null);
|
||||
if (trace == null || trace.getEndTime() < oldest) {
|
||||
missing.add(traceId);
|
||||
continue;
|
||||
}
|
||||
found.add(trace);
|
||||
}
|
||||
return new BatchGetResult(found, missing);
|
||||
}
|
||||
|
||||
/** The traces a service holds in a region, newest first, for the summaries and the graph. */
|
||||
public List<Trace> traces(String region) {
|
||||
long oldest = Instant.now().getEpochSecond() - RETENTION_SECONDS;
|
||||
List<Trace> kept = new ArrayList<>();
|
||||
for (Trace trace : traces.scan(key -> key.startsWith(region + "::"))) {
|
||||
if (trace.getEndTime() >= oldest) {
|
||||
kept.add(trace);
|
||||
}
|
||||
}
|
||||
kept.sort(Comparator.comparingDouble(Trace::getStartTime).reversed());
|
||||
return kept;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
traces.clear();
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------- summaries
|
||||
|
||||
/** One trace as {@code GetTraceSummaries} reports it. */
|
||||
public record TraceSummary(String id, double startTime, double endTime, double duration,
|
||||
boolean hasError, boolean hasFault, boolean hasThrottle,
|
||||
Integer httpStatus, String httpMethod, String httpUrl,
|
||||
List<String> services, Map<String, Object> annotations,
|
||||
String entryPoint) {
|
||||
}
|
||||
|
||||
/** A page of summaries, with the counts AWS reports beside them. */
|
||||
public record SummaryPage(List<TraceSummary> items, String nextToken, long approximateTime,
|
||||
int processedCount) {
|
||||
}
|
||||
|
||||
public SummaryPage traceSummaries(double startTime, double endTime, String filterExpression,
|
||||
Integer maxResults, String nextToken, String region) {
|
||||
requireWindow(startTime, endTime);
|
||||
Predicate<XrayFilterExpression.Facts> filter = XrayFilterExpression.compile(filterExpression);
|
||||
List<TraceSummary> matching = new ArrayList<>();
|
||||
int processed = 0;
|
||||
for (Trace trace : traces(region)) {
|
||||
if (trace.getEndTime() < startTime || trace.getStartTime() > endTime) {
|
||||
continue;
|
||||
}
|
||||
processed++;
|
||||
TraceSummary summary = summarize(trace);
|
||||
if (filter.test(factsOf(summary))) {
|
||||
matching.add(summary);
|
||||
}
|
||||
}
|
||||
PaginatedResult<TraceSummary> page = Pagination.paginate(matching, TraceSummary::id,
|
||||
maxResults, nextToken, MAX_SUMMARIES_PAGE, "InvalidRequestException");
|
||||
return new SummaryPage(page.items(), page.nextToken(),
|
||||
Instant.now().getEpochSecond(), processed);
|
||||
}
|
||||
|
||||
/** The service graph over a window, the operation a console draws. */
|
||||
public List<XrayGraph.Node> serviceGraph(double startTime, double endTime, String region) {
|
||||
requireWindow(startTime, endTime);
|
||||
List<List<XraySegments.Node>> perTrace = new ArrayList<>();
|
||||
for (Trace trace : traces(region)) {
|
||||
if (trace.getEndTime() < startTime || trace.getStartTime() > endTime) {
|
||||
continue;
|
||||
}
|
||||
perTrace.add(nodesOf(trace));
|
||||
}
|
||||
return XrayGraph.build(perTrace);
|
||||
}
|
||||
|
||||
/** The same graph, for named traces: AWS answers a window-free view of those traces. */
|
||||
public List<XrayGraph.Node> traceGraph(List<String> traceIds, String region) {
|
||||
if (traceIds == null || traceIds.isEmpty()) {
|
||||
throw validation("TraceIds is required.");
|
||||
}
|
||||
long oldest = Instant.now().getEpochSecond() - RETENTION_SECONDS;
|
||||
List<List<XraySegments.Node>> perTrace = new ArrayList<>();
|
||||
for (String traceId : traceIds) {
|
||||
traces.get(storageKey(region, traceId))
|
||||
.filter(trace -> trace.getEndTime() >= oldest)
|
||||
.ifPresent(trace -> perTrace.add(nodesOf(trace)));
|
||||
}
|
||||
return XrayGraph.build(perTrace);
|
||||
}
|
||||
|
||||
private TraceSummary summarize(Trace trace) {
|
||||
List<XraySegments.Node> nodes = nodesOf(trace);
|
||||
Set<String> services = new LinkedHashSet<>();
|
||||
Integer httpStatus = null;
|
||||
String httpMethod = null;
|
||||
String httpUrl = null;
|
||||
String entryPoint = null;
|
||||
Map<String, Object> annotations = Map.of();
|
||||
for (XraySegments.Node node : nodes) {
|
||||
if (!node.name().isEmpty()) {
|
||||
services.add(node.name());
|
||||
}
|
||||
if (httpStatus == null && node.httpStatus() != null) {
|
||||
httpStatus = node.httpStatus();
|
||||
httpMethod = node.httpMethod();
|
||||
httpUrl = node.httpUrl();
|
||||
}
|
||||
if (entryPoint == null && node.parentId().isEmpty()) {
|
||||
entryPoint = node.name();
|
||||
annotations = node.annotations();
|
||||
}
|
||||
}
|
||||
return new TraceSummary(trace.getId(), trace.getStartTime(), trace.getEndTime(),
|
||||
trace.getEndTime() - trace.getStartTime(), trace.isError(), trace.isFault(),
|
||||
trace.isThrottle(), httpStatus, httpMethod, httpUrl, List.copyOf(services),
|
||||
annotations, entryPoint);
|
||||
}
|
||||
|
||||
private static XrayFilterExpression.Facts factsOf(TraceSummary summary) {
|
||||
return new XrayFilterExpression.Facts(Set.copyOf(summary.services()), summary.hasError(),
|
||||
summary.hasFault(), summary.hasThrottle(), summary.duration(), summary.httpStatus(),
|
||||
summary.annotations());
|
||||
}
|
||||
|
||||
private List<XraySegments.Node> nodesOf(Trace trace) {
|
||||
List<XraySegments.Node> nodes = new ArrayList<>();
|
||||
for (String document : trace.getDocuments()) {
|
||||
nodes.addAll(XraySegments.flatten(document, this::readNode));
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
|
||||
/** The id a stored document carries, so a client retrying a segment replaces it instead of adding it. */
|
||||
private String segmentIdOf(String document) {
|
||||
try {
|
||||
return objectMapper.readTree(document).path("id").asText("");
|
||||
} catch (Exception expected) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private JsonNode readNode(String document) {
|
||||
try {
|
||||
return objectMapper.readTree(document);
|
||||
} catch (Exception e) {
|
||||
return objectMapper.createObjectNode();
|
||||
}
|
||||
}
|
||||
|
||||
private static void requireWindow(double startTime, double endTime) {
|
||||
if (endTime <= startTime) {
|
||||
throw validation("EndTime must be later than StartTime.");
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- sampling
|
||||
|
||||
/** The rule AWS always serves, and the one a daemon samples at until a rule matches. */
|
||||
static final String DEFAULT_RULE_NAME = "Default";
|
||||
/** AWS allows twenty-five sampling rules per Region, the default one excluded. */
|
||||
private static final int MAX_SAMPLING_RULES = 25;
|
||||
/** The daemon asks for targets every 10 seconds, so that is the quota's lifetime. */
|
||||
private static final int SAMPLING_INTERVAL_SECONDS = 10;
|
||||
|
||||
/** One target the daemon should sample at, for a client and a rule. */
|
||||
public record Target(String ruleName, Double fixedRate, Integer reservoirQuota,
|
||||
long reservoirQuotaTtl, int interval) {
|
||||
}
|
||||
|
||||
/** A statistics document the daemon sent for a rule Floci does not have. */
|
||||
public record UnprocessedTarget(String ruleName, String errorCode, String message) {
|
||||
}
|
||||
|
||||
/** The answer to {@code GetSamplingTargets}. */
|
||||
public record Targets(List<Target> documents, List<UnprocessedTarget> unprocessed,
|
||||
long lastRuleModification) {
|
||||
}
|
||||
|
||||
public List<SamplingRule> samplingRules(String region) {
|
||||
List<SamplingRule> all = new ArrayList<>(rules.scan(key -> key.startsWith(region + "::")));
|
||||
all.add(defaultRule(region));
|
||||
all.sort(Comparator.comparing(SamplingRule::getPriority)
|
||||
.thenComparing(SamplingRule::getRuleName));
|
||||
return all;
|
||||
}
|
||||
|
||||
public SamplingRule createSamplingRule(JsonNode request, String region) {
|
||||
requireObject(request, "Request payload");
|
||||
synchronized (lockFor(region)) {
|
||||
return createSamplingRuleLocked(request, region);
|
||||
}
|
||||
}
|
||||
|
||||
private SamplingRule createSamplingRuleLocked(JsonNode request, String region) {
|
||||
SamplingRule requested = parseRule(requireObject(request.path("SamplingRule"), "SamplingRule"));
|
||||
String key = storageKey(region, requested.getRuleName());
|
||||
if (DEFAULT_RULE_NAME.equals(requested.getRuleName())) {
|
||||
throw validation("Sampling rule name " + DEFAULT_RULE_NAME + " is reserved.");
|
||||
}
|
||||
if (rules.get(key).isPresent()) {
|
||||
throw validation("Sampling rule " + requested.getRuleName() + " already exists.");
|
||||
}
|
||||
if (rules.scan(stored -> stored.startsWith(region + "::")).size() >= MAX_SAMPLING_RULES) {
|
||||
throw new AwsException("RuleLimitExceededException",
|
||||
"A Region supports at most " + MAX_SAMPLING_RULES + " sampling rules, and this one"
|
||||
+ " already has that many.", 400);
|
||||
}
|
||||
long now = Instant.now().getEpochSecond();
|
||||
String arn = samplingRuleArn(requested.getRuleName(), region);
|
||||
requested.setRuleArn(arn);
|
||||
if (requested.getResourceArn() == null) {
|
||||
requested.setResourceArn(arn);
|
||||
}
|
||||
requested.setCreatedAt(now);
|
||||
requested.setModifiedAt(now);
|
||||
rules.put(key, requested);
|
||||
LOG.debugv("Created sampling rule {0}", requested.getRuleName());
|
||||
return requested;
|
||||
}
|
||||
|
||||
public SamplingRule updateSamplingRule(JsonNode request, String region) {
|
||||
requireObject(request, "Request payload");
|
||||
synchronized (lockFor(region)) {
|
||||
return updateSamplingRuleLocked(request, region);
|
||||
}
|
||||
}
|
||||
|
||||
private SamplingRule updateSamplingRuleLocked(JsonNode request, String region) {
|
||||
JsonNode update = requireObject(request.path("SamplingRuleUpdate"), "SamplingRuleUpdate");
|
||||
SamplingRule rule = loadRuleForUpdate(update, region);
|
||||
|
||||
// Every supplied member is validated before any is applied: a rejected update must leave
|
||||
// the rule exactly as it was, not halfway between the old and the new values.
|
||||
Integer priority = update.has("Priority") ? requiredInt(update, "Priority") : null;
|
||||
Double fixedRate = update.has("FixedRate") ? requiredRate(update, "FixedRate") : null;
|
||||
Integer reservoirSize = update.has("ReservoirSize") ? requiredInt(update, "ReservoirSize") : null;
|
||||
Map<String, String> attributes =
|
||||
update.has("Attributes") ? optionalStringMap(update, "Attributes") : null;
|
||||
Map<String, String> matchers = new LinkedHashMap<>();
|
||||
for (String member : new String[] {"ServiceName", "ServiceType", "Host", "HTTPMethod", "URLPath"}) {
|
||||
if (update.has(member)) {
|
||||
matchers.put(member, requiredText(update, member));
|
||||
}
|
||||
}
|
||||
|
||||
SamplingRule updated = rule.copy();
|
||||
if (priority != null) {
|
||||
updated.setPriority(priority);
|
||||
}
|
||||
if (fixedRate != null) {
|
||||
updated.setFixedRate(fixedRate);
|
||||
}
|
||||
if (reservoirSize != null) {
|
||||
updated.setReservoirSize(reservoirSize);
|
||||
}
|
||||
matchers.forEach((member, value) -> setMatcher(updated, member, value));
|
||||
if (attributes != null) {
|
||||
updated.setAttributes(attributes);
|
||||
}
|
||||
updated.setModifiedAt(Instant.now().getEpochSecond());
|
||||
rules.put(storageKey(region, updated.getRuleName()), updated);
|
||||
return updated;
|
||||
}
|
||||
|
||||
/** The stored rule an update names, refusing the synthesised Default one it cannot change. */
|
||||
private SamplingRule loadRuleForUpdate(JsonNode update, String region) {
|
||||
String name = ruleName(update);
|
||||
if (DEFAULT_RULE_NAME.equals(name)) {
|
||||
throw validation("The " + DEFAULT_RULE_NAME + " sampling rule cannot be updated.");
|
||||
}
|
||||
return rules.get(storageKey(region, name)).orElseThrow(
|
||||
() -> validation("Sampling rule " + name + " does not exist."));
|
||||
}
|
||||
|
||||
private static String ruleName(JsonNode request) {
|
||||
String name = request.path("RuleName").asText("");
|
||||
if (!name.isEmpty()) {
|
||||
return name;
|
||||
}
|
||||
String arn = request.path("RuleARN").asText("");
|
||||
if (arn.isEmpty()) {
|
||||
throw validation("RuleName or RuleARN is required.");
|
||||
}
|
||||
return arn.substring(arn.lastIndexOf('/') + 1);
|
||||
}
|
||||
|
||||
public SamplingRule deleteSamplingRule(JsonNode request, String region) {
|
||||
requireObject(request, "Request payload");
|
||||
synchronized (lockFor(region)) {
|
||||
return deleteSamplingRuleLocked(request, region);
|
||||
}
|
||||
}
|
||||
|
||||
private SamplingRule deleteSamplingRuleLocked(JsonNode request, String region) {
|
||||
SamplingRule rule = requireRule(request, region);
|
||||
if (DEFAULT_RULE_NAME.equals(rule.getRuleName())) {
|
||||
throw validation("The " + DEFAULT_RULE_NAME + " sampling rule cannot be deleted.");
|
||||
}
|
||||
rules.delete(storageKey(region, rule.getRuleName()));
|
||||
LOG.debugv("Deleted sampling rule {0}", rule.getRuleName());
|
||||
return rule;
|
||||
}
|
||||
|
||||
public Targets samplingTargets(JsonNode request, String region) {
|
||||
requireObject(request, "Request payload");
|
||||
JsonNode documents = request.path("SamplingStatisticsDocuments");
|
||||
if (!documents.isArray()) {
|
||||
throw validation("SamplingStatisticsDocuments is required.");
|
||||
}
|
||||
long now = Instant.now().getEpochSecond();
|
||||
List<Target> targets = new ArrayList<>();
|
||||
List<UnprocessedTarget> unprocessed = new ArrayList<>();
|
||||
// The timestamp covers every rule of the Region: it tells the daemon whether to refetch
|
||||
// the whole set, so a rule it did not name changing still has to move it.
|
||||
long lastModification = rules.scan(key -> key.startsWith(region + "::")).stream()
|
||||
.mapToLong(SamplingRule::getModifiedAt).max().orElse(0L);
|
||||
for (JsonNode document : documents) {
|
||||
String ruleName = document.path("RuleName").asText("");
|
||||
if (ruleName.isEmpty()) {
|
||||
throw validation("SamplingStatisticsDocuments entries need a RuleName.");
|
||||
}
|
||||
SamplingRule rule = rules.get(storageKey(region, ruleName)).orElse(null);
|
||||
if (rule == null && DEFAULT_RULE_NAME.equals(ruleName)) {
|
||||
rule = defaultRule(region);
|
||||
}
|
||||
if (rule == null) {
|
||||
unprocessed.add(new UnprocessedTarget(ruleName, "RuleNotFound",
|
||||
"Sampling rule " + ruleName + " does not exist."));
|
||||
continue;
|
||||
}
|
||||
targets.add(new Target(ruleName, rule.getFixedRate(),
|
||||
Math.max(0, rule.getReservoirSize()), now + SAMPLING_INTERVAL_SECONDS,
|
||||
SAMPLING_INTERVAL_SECONDS));
|
||||
}
|
||||
return new Targets(targets, unprocessed, lastModification);
|
||||
}
|
||||
|
||||
public int putTelemetryRecords(JsonNode request, String region) {
|
||||
requireObject(request, "Request payload");
|
||||
JsonNode records = request.path("TelemetryRecords");
|
||||
if (!records.isArray()) {
|
||||
throw validation("TelemetryRecords is required.");
|
||||
}
|
||||
LOG.debugv("Accepted {0} telemetry records from {1}", records.size(),
|
||||
request.path("Hostname").asText("an unnamed host"));
|
||||
return records.size();
|
||||
}
|
||||
|
||||
/** The rule AWS serves in every Region, so a daemon always has something to sample at. */
|
||||
private SamplingRule defaultRule(String region) {
|
||||
long now = Instant.now().getEpochSecond();
|
||||
SamplingRule rule = new SamplingRule();
|
||||
rule.setRuleName(DEFAULT_RULE_NAME);
|
||||
rule.setRuleArn(samplingRuleArn(DEFAULT_RULE_NAME, region));
|
||||
rule.setResourceArn(rule.getRuleArn());
|
||||
rule.setPriority(10000);
|
||||
rule.setFixedRate(0.05);
|
||||
rule.setReservoirSize(1);
|
||||
rule.setServiceName("*");
|
||||
rule.setServiceType("*");
|
||||
rule.setHost("*");
|
||||
rule.setHttpMethod("*");
|
||||
rule.setUrlPath("*");
|
||||
rule.setVersion(1);
|
||||
rule.setCreatedAt(now);
|
||||
rule.setModifiedAt(now);
|
||||
return rule;
|
||||
}
|
||||
|
||||
private String samplingRuleArn(String ruleName, String region) {
|
||||
return AwsArnUtils.Arn.of(SERVICE, region, rules.accountId(),
|
||||
"sampling-rule/" + ruleName).toString();
|
||||
}
|
||||
|
||||
private SamplingRule parseRule(JsonNode rule) {
|
||||
SamplingRule parsed = new SamplingRule();
|
||||
parsed.setRuleName(requiredText(rule, "RuleName"));
|
||||
parsed.setPriority(requiredInt(rule, "Priority"));
|
||||
parsed.setFixedRate(requiredRate(rule, "FixedRate"));
|
||||
parsed.setReservoirSize(requiredInt(rule, "ReservoirSize"));
|
||||
parsed.setServiceName(requiredText(rule, "ServiceName"));
|
||||
parsed.setServiceType(requiredText(rule, "ServiceType"));
|
||||
parsed.setHost(requiredText(rule, "Host"));
|
||||
parsed.setHttpMethod(requiredText(rule, "HTTPMethod"));
|
||||
parsed.setUrlPath(requiredText(rule, "URLPath"));
|
||||
parsed.setVersion(requiredInt(rule, "Version"));
|
||||
parsed.setAttributes(optionalStringMap(rule, "Attributes"));
|
||||
if (rule.has("ResourceARN")) {
|
||||
parsed.setResourceArn(requiredText(rule, "ResourceARN"));
|
||||
}
|
||||
return parsed;
|
||||
}
|
||||
|
||||
private SamplingRule requireRule(JsonNode request, String region) {
|
||||
String ruleName = ruleName(request);
|
||||
if (DEFAULT_RULE_NAME.equals(ruleName)) {
|
||||
return defaultRule(region);
|
||||
}
|
||||
return rules.get(storageKey(region, ruleName)).orElseThrow(
|
||||
() -> validation("Sampling rule " + ruleName + " does not exist."));
|
||||
}
|
||||
|
||||
private static void setMatcher(SamplingRule rule, String member, String value) {
|
||||
switch (member) {
|
||||
case "ServiceName" -> rule.setServiceName(value);
|
||||
case "ServiceType" -> rule.setServiceType(value);
|
||||
case "Host" -> rule.setHost(value);
|
||||
case "HTTPMethod" -> rule.setHttpMethod(value);
|
||||
case "URLPath" -> rule.setUrlPath(value);
|
||||
default -> throw new IllegalArgumentException("not a matcher: " + member);
|
||||
}
|
||||
}
|
||||
|
||||
private static int requiredInt(JsonNode node, String member) {
|
||||
JsonNode value = node.path(member);
|
||||
if (!value.isNumber()) {
|
||||
throw validation(member + " must be a number.");
|
||||
}
|
||||
return value.asInt();
|
||||
}
|
||||
|
||||
private static double requiredRate(JsonNode node, String member) {
|
||||
JsonNode value = node.path(member);
|
||||
if (!value.isNumber() || value.asDouble() < 0.0 || value.asDouble() > 1.0) {
|
||||
throw validation(member + " must be a number between 0 and 1.");
|
||||
}
|
||||
return value.asDouble();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- helpers
|
||||
|
||||
private void evict(String region) {
|
||||
List<Trace> all = new ArrayList<>(traces.scan(key -> key.startsWith(region + "::")));
|
||||
long oldest = Instant.now().getEpochSecond() - RETENTION_SECONDS;
|
||||
List<Trace> expired = all.stream().filter(trace -> trace.getEndTime() < oldest).toList();
|
||||
expired.forEach(trace -> traces.delete(storageKey(region, trace.getId())));
|
||||
all.removeAll(expired);
|
||||
if (all.size() <= MAX_TRACES) {
|
||||
return;
|
||||
}
|
||||
all.sort(Comparator.comparingDouble(Trace::getStartTime));
|
||||
int excess = all.size() - MAX_TRACES;
|
||||
for (int i = 0; i < excess; i++) {
|
||||
traces.delete(storageKey(region, all.get(i).getId()));
|
||||
}
|
||||
LOG.debugv("Evicted {0} traces to stay under {1}", excess, MAX_TRACES);
|
||||
}
|
||||
|
||||
private Object lockFor(String region) {
|
||||
return regionLocks.computeIfAbsent(region, ignored -> new Object());
|
||||
}
|
||||
|
||||
private static String storageKey(String region, String traceId) {
|
||||
return region + "::" + traceId;
|
||||
}
|
||||
|
||||
/** A segment document as a node, for the readers that need to walk it. */
|
||||
JsonNode parse(String document) {
|
||||
try {
|
||||
return objectMapper.readTree(document);
|
||||
} catch (Exception e) {
|
||||
throw validation("The stored segment document is not valid JSON.");
|
||||
}
|
||||
}
|
||||
|
||||
static ObjectNode objectNode() {
|
||||
return new ObjectMapper().createObjectNode();
|
||||
}
|
||||
|
||||
private static JsonNode requireObject(JsonNode node, String member) {
|
||||
if (!node.isObject()) {
|
||||
throw validation(member + " is required.");
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
private static String requiredText(JsonNode node, String member) {
|
||||
String value = node.path(member).asText("");
|
||||
if (value.isEmpty()) {
|
||||
throw validation(member + " is required.");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private static Map<String, String> optionalStringMap(JsonNode node, String member) {
|
||||
Map<String, String> values = new LinkedHashMap<>();
|
||||
JsonNode object = node.path(member);
|
||||
if (object.isObject()) {
|
||||
object.fields().forEachRemaining(entry -> values.put(entry.getKey(),
|
||||
entry.getValue().asText()));
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
private static AwsException validation(String message) {
|
||||
return new AwsException("InvalidRequestException", message, 400);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
package io.floci.aws.services.xray.model;
|
||||
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A sampling rule as X-Ray stores it: the match criteria, the rate the daemon samples at and the
|
||||
* reservoir it may borrow from.
|
||||
*
|
||||
* <p>The rule AWS always serves, {@code Default}, is not stored here: it is synthesised per Region
|
||||
* so deleting it and never creating it both answer the same rule.
|
||||
*/
|
||||
@RegisterForReflection
|
||||
public class SamplingRule {
|
||||
|
||||
private String ruleName;
|
||||
private String ruleArn;
|
||||
private String resourceArn;
|
||||
private Integer priority;
|
||||
private Double fixedRate;
|
||||
private Integer reservoirSize;
|
||||
private String serviceName;
|
||||
private String serviceType;
|
||||
private String host;
|
||||
private String httpMethod;
|
||||
private String urlPath;
|
||||
private Integer version;
|
||||
private Map<String, String> attributes = new LinkedHashMap<>();
|
||||
private long createdAt;
|
||||
private long modifiedAt;
|
||||
|
||||
/**
|
||||
* A copy, so an update validates against a value that is not the stored one: a rejected update
|
||||
* must leave the rule exactly as it was, and in memory mode the stored object is a live reference.
|
||||
*/
|
||||
public SamplingRule copy() {
|
||||
SamplingRule copy = new SamplingRule();
|
||||
copy.ruleName = ruleName;
|
||||
copy.ruleArn = ruleArn;
|
||||
copy.resourceArn = resourceArn;
|
||||
copy.priority = priority;
|
||||
copy.fixedRate = fixedRate;
|
||||
copy.reservoirSize = reservoirSize;
|
||||
copy.serviceName = serviceName;
|
||||
copy.serviceType = serviceType;
|
||||
copy.host = host;
|
||||
copy.httpMethod = httpMethod;
|
||||
copy.urlPath = urlPath;
|
||||
copy.version = version;
|
||||
copy.attributes = new LinkedHashMap<>(attributes);
|
||||
copy.createdAt = createdAt;
|
||||
copy.modifiedAt = modifiedAt;
|
||||
return copy;
|
||||
}
|
||||
|
||||
public String getRuleName() {
|
||||
return ruleName;
|
||||
}
|
||||
|
||||
public void setRuleName(String ruleName) {
|
||||
this.ruleName = ruleName;
|
||||
}
|
||||
|
||||
public String getRuleArn() {
|
||||
return ruleArn;
|
||||
}
|
||||
|
||||
public void setRuleArn(String ruleArn) {
|
||||
this.ruleArn = ruleArn;
|
||||
}
|
||||
|
||||
public String getResourceArn() {
|
||||
return resourceArn;
|
||||
}
|
||||
|
||||
public void setResourceArn(String resourceArn) {
|
||||
this.resourceArn = resourceArn;
|
||||
}
|
||||
|
||||
public Integer getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
public void setPriority(Integer priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
public Double getFixedRate() {
|
||||
return fixedRate;
|
||||
}
|
||||
|
||||
public void setFixedRate(Double fixedRate) {
|
||||
this.fixedRate = fixedRate;
|
||||
}
|
||||
|
||||
public Integer getReservoirSize() {
|
||||
return reservoirSize;
|
||||
}
|
||||
|
||||
public void setReservoirSize(Integer reservoirSize) {
|
||||
this.reservoirSize = reservoirSize;
|
||||
}
|
||||
|
||||
public String getServiceName() {
|
||||
return serviceName;
|
||||
}
|
||||
|
||||
public void setServiceName(String serviceName) {
|
||||
this.serviceName = serviceName;
|
||||
}
|
||||
|
||||
public String getServiceType() {
|
||||
return serviceType;
|
||||
}
|
||||
|
||||
public void setServiceType(String serviceType) {
|
||||
this.serviceType = serviceType;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public String getHttpMethod() {
|
||||
return httpMethod;
|
||||
}
|
||||
|
||||
public void setHttpMethod(String httpMethod) {
|
||||
this.httpMethod = httpMethod;
|
||||
}
|
||||
|
||||
public String getUrlPath() {
|
||||
return urlPath;
|
||||
}
|
||||
|
||||
public void setUrlPath(String urlPath) {
|
||||
this.urlPath = urlPath;
|
||||
}
|
||||
|
||||
public Integer getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Integer version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public Map<String, String> getAttributes() {
|
||||
return attributes;
|
||||
}
|
||||
|
||||
public void setAttributes(Map<String, String> attributes) {
|
||||
this.attributes = attributes == null ? new LinkedHashMap<>() : attributes;
|
||||
}
|
||||
|
||||
public long getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(long createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public long getModifiedAt() {
|
||||
return modifiedAt;
|
||||
}
|
||||
|
||||
public void setModifiedAt(long modifiedAt) {
|
||||
this.modifiedAt = modifiedAt;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package io.floci.aws.services.xray.model;
|
||||
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* One trace, as the segments a client sent for it.
|
||||
*
|
||||
* <p>The documents are kept verbatim: X-Ray's API hands a segment back exactly as it was put, and
|
||||
* the SDK parses it, so re-serialising through a model here would change what the caller reads.
|
||||
* What Floci parses out of them is only what it has to index, which lives on {@link SegmentSummary}.
|
||||
*/
|
||||
@RegisterForReflection
|
||||
public class Trace {
|
||||
|
||||
private String id;
|
||||
private List<String> documents = new ArrayList<>();
|
||||
/** Epoch seconds, from the documents, for the retention window and the summaries. */
|
||||
private double startTime;
|
||||
private double endTime;
|
||||
private boolean fault;
|
||||
private boolean error;
|
||||
private boolean throttle;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public List<String> getDocuments() {
|
||||
return documents;
|
||||
}
|
||||
|
||||
public void setDocuments(List<String> documents) {
|
||||
this.documents = documents == null ? new ArrayList<>() : documents;
|
||||
}
|
||||
|
||||
public double getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(double startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public double getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(double endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public boolean isFault() {
|
||||
return fault;
|
||||
}
|
||||
|
||||
public void setFault(boolean fault) {
|
||||
this.fault = fault;
|
||||
}
|
||||
|
||||
public boolean isError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public void setError(boolean error) {
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
public boolean isThrottle() {
|
||||
return throttle;
|
||||
}
|
||||
|
||||
public void setThrottle(boolean throttle) {
|
||||
this.throttle = throttle;
|
||||
}
|
||||
}
|
||||
@@ -1084,6 +1084,8 @@ floci:
|
||||
enabled: true
|
||||
signer:
|
||||
enabled: true
|
||||
xray:
|
||||
enabled: true
|
||||
cognitoidentity:
|
||||
enabled: true
|
||||
globalaccelerator:
|
||||
|
||||
@@ -800,6 +800,42 @@
|
||||
"ListSigningPlatforms",
|
||||
"ListSigningProfiles",
|
||||
"PutSigningProfile"
|
||||
],
|
||||
"xray": [
|
||||
"BatchGetTraceSummaryById",
|
||||
"BatchGetTraces",
|
||||
"CallWithBearerToken",
|
||||
"CancelTraceRetrieval",
|
||||
"DeleteResourcePolicy",
|
||||
"GetDistinctTraceGraphs",
|
||||
"GetEncryptionConfig",
|
||||
"GetGroups",
|
||||
"GetIndexingRules",
|
||||
"GetInsight",
|
||||
"GetInsightEvents",
|
||||
"GetInsightImpactGraph",
|
||||
"GetInsightSummaries",
|
||||
"GetRetrievedTracesGraph",
|
||||
"GetSamplingRules",
|
||||
"GetSamplingStatisticSummaries",
|
||||
"GetSamplingTargets",
|
||||
"GetServiceGraph",
|
||||
"GetTimeSeriesServiceStatistics",
|
||||
"GetTraceGraph",
|
||||
"GetTraceSegmentDestination",
|
||||
"GetTraceSummaries",
|
||||
"Link",
|
||||
"ListResourcePolicies",
|
||||
"ListRetrievedTraces",
|
||||
"PutEncryptionConfig",
|
||||
"PutResourcePolicy",
|
||||
"PutSpans",
|
||||
"PutSpansForIndexing",
|
||||
"PutTelemetryRecords",
|
||||
"PutTraceSegments",
|
||||
"StartTraceRetrieval",
|
||||
"UpdateIndexingRule",
|
||||
"UpdateTraceSegmentDestination"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"_source": {"generator": "tools/aws/regen_iam_request_resources.py", "reference": "https://servicereference.us-east-1.amazonaws.com/", "botocore": "botocore 1.43.118 (installed package)", "retrieved": "2026-11-10", "note": "make iam-request-resources-check re-derives every operation's resources from botocore; make iam-request-resources-verify checks every action, type and format against AWS."},
|
||||
"namespaces": {"access-analyzer": ["accessanalyzer"], "acm": ["acm"], "application-autoscaling": ["application-autoscaling"], "athena": ["athena"], "bcm-data-exports": ["bcm-data-exports"], "bcm-pricing-calculator": ["bcm-pricing-calculator"], "budgets": ["budgets"], "ce": ["ce"], "cloudtrail": ["cloudtrail"], "codebuild": ["codebuild"], "codepipeline": ["codepipeline"], "cognito-identity": ["cognito-identity"], "cognito-idp": ["cognito-idp"], "controltower": ["controltower"], "cur": ["cur"], "datasync": ["datasync"], "dynamodb": ["dynamodb"], "ec2": ["ec2"], "ecr": ["ecr"], "elasticloadbalancing": ["elb", "elbv2"], "elasticmapreduce": ["emr"], "es": ["es", "opensearch"], "events": ["eventbridgev2", "events"], "firehose": ["firehose"], "globalaccelerator": ["globalaccelerator"], "inspector2": ["inspector2"], "kinesisanalytics": ["kinesisanalyticsv2"], "logs": ["logs"], "macie2": ["macie2"], "payment-cryptography": ["payment-cryptography", "payment-cryptography-data"], "quicksight": ["quicksight"], "redshift": ["redshift"], "redshift-data": ["redshift-data"], "rekognition": ["rekognition"], "servicediscovery": ["servicediscovery"], "servicequotas": ["service-quotas"], "signer": ["signer", "signer-data"], "sso": ["sso", "sso-admin"], "states": ["stepfunctions"], "textract": ["textract"], "timestream-influxdb": ["timestream-influxdb"], "translate": ["translate"]},
|
||||
"_source": {"generator": "tools/aws/regen_iam_request_resources.py", "reference": "https://servicereference.us-east-1.amazonaws.com/", "botocore": "botocore 1.43.118 (installed package)", "retrieved": "2026-11-11", "note": "make iam-request-resources-check re-derives every operation's resources from botocore; make iam-request-resources-verify checks every action, type and format against AWS."},
|
||||
"namespaces": {"access-analyzer": ["accessanalyzer"], "acm": ["acm"], "application-autoscaling": ["application-autoscaling"], "athena": ["athena"], "bcm-data-exports": ["bcm-data-exports"], "bcm-pricing-calculator": ["bcm-pricing-calculator"], "budgets": ["budgets"], "ce": ["ce"], "cloudtrail": ["cloudtrail"], "codebuild": ["codebuild"], "codepipeline": ["codepipeline"], "cognito-identity": ["cognito-identity"], "cognito-idp": ["cognito-idp"], "controltower": ["controltower"], "cur": ["cur"], "datasync": ["datasync"], "dynamodb": ["dynamodb"], "ec2": ["ec2"], "ecr": ["ecr"], "elasticloadbalancing": ["elb", "elbv2"], "elasticmapreduce": ["emr"], "es": ["es", "opensearch"], "events": ["eventbridgev2", "events"], "firehose": ["firehose"], "globalaccelerator": ["globalaccelerator"], "inspector2": ["inspector2"], "kinesisanalytics": ["kinesisanalyticsv2"], "logs": ["logs"], "macie2": ["macie2"], "payment-cryptography": ["payment-cryptography", "payment-cryptography-data"], "quicksight": ["quicksight"], "redshift": ["redshift"], "redshift-data": ["redshift-data"], "rekognition": ["rekognition"], "servicediscovery": ["servicediscovery"], "servicequotas": ["service-quotas"], "signer": ["signer", "signer-data"], "sso": ["sso", "sso-admin"], "states": ["stepfunctions"], "textract": ["textract"], "timestream-influxdb": ["timestream-influxdb"], "translate": ["translate"], "xray": ["xray"]},
|
||||
"clientsNotRead": {"kinesisanalytics": "Kinesis Data Analytics v1, SQL applications on the KinesisAnalytics_20150814 target, which Floci does not serve (it serves v2, kinesisanalyticsv2); its operations share v2's names and name their resources by other members"},
|
||||
"handBuilt": ["apigateway", "bedrock", "dsql", "dynamodb", "eks", "iam", "kinesis", "kms", "lambda", "logs", "pipes", "resource-groups", "s3", "scheduler", "secretsmanager", "sns", "sqs", "ssm", "sts"],
|
||||
"notCovered": {"account": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "airflow": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "app-integrations": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "appconfig": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "appsync": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "aps": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "autoscaling": "not read yet: AWS's group and launch configuration ARNs carry an id the service mints, `autoScalingGroup:<id>:autoScalingGroupName/<name>`, while Floci mints `autoScalingGroup:<name>`, which other services (ECS capacity providers) read back; the mint is fixed first", "aws-marketplace": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "backup": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "batch": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "bedrock-agentcore": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "cloudformation": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "cloudfront": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "cloudhsm": "not read yet: its ARN formats end in ${CloudHsmClusterInstanceName} and ${CloudHsmBackupInstanceName}, names, while its requests give ClusterId and BackupId, ids, which the rule does not fill a name from, so nearly every operation needs a correction", "cloudwatch": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "codeartifact": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "codedeploy": "not read yet: the Service Reference gives an on-premises instance's ARN as `instance:${InstanceName}`, while the CodeDeploy permissions reference gives arn:aws:codedeploy:region:account-id:instance/instance-ID and AWS's GetOnPremisesInstance example answers instance/<name>_<id>, an id the service mints after the name; reading it needs that format corrected", "codeguru-reviewer": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "comprehend": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "config": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "connect": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "controlcatalog": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "detective": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "dlm": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its Line truncated
|
||||
"otherNamespaces": ["a4b", "account-access", "acm-pca", "aco-automation", "agent-registry", "aidevops", "aiops", "airflow-serverless", "amplify", "amplifybackend", "amplifyuibuilder", "aoss", "appfabric", "appflow", "application-signals", "application-signals-mcp", "appmesh", "appmesh-preview", "apprunner", "appstream", "apptest", "arc-region-switch", "arc-zonal-shift", "artifact", "assurance", "auditmanager", "aws-external-anthropic", "b2bi", "backup-gateway", "backup-search", "bedrock-mantle", "bedrock-websearch", "billing", "billingconductor", "braket", "bugbust", "cases", "cassandra", "chatbot", "chime", "cleanrooms", "cleanrooms-ml", "cloud9", "clouddirectory", "cloudfront-keyvaluestore", "cloudsearch", "cloudshell", "cloudtrail-data", "codecatalyst", "codecommit", "codeconnections", "codeguru-profiler", "codeguru-security", "codestar-connections", "codestar-notifications", "codewhisperer", "cognito-sync", "connect-campaigns", "consoleapp", "continuum", "databrew", "dataexchange", "datapipeline", "datazone", "dax", "deadline", "devicefarm", "devops-guru", "directconnect", "docdb-elastic", "drs", "ds", "ds-data", "ebs", "ecr-public", "eks-auth", "elastictranscoder", "elemental-appliances-software", "elemental-inference", "elemental-support-cases", "emr-containers", "end-user-messaging", "entityresolution", "evs", "finspace", "finspace-api", "fms", "forecast", "frauddetector", "freertos", "fsx", "gamelift", "gameliftstreams", "geo", "geo-maps", "geo-places", "geo-routes", "glacier", "grafana", "greengrass", "groundstation", "health", "health-agent", "healthlake", "honeycode", "identity-sync", "imagebuilder", "interconnect", "internetmonitor", "invoicing", "iotanalytics", "iotdeviceadvisor", "iotfleethub", "iotfleetwise", "iotjobsdata", "iotmanagedintegrations", "iotsitewise", "iottwinmaker", "iotwireless", "iq", "iq-permission", "ivs", "ivschat", "kafka-cluster", "kafkaconnect", "kendra", "kendra-ranking", "kinesisvideo", "launchwizard", "lex", "license-manager", "license-manager-linux-subscriptions", "license-manager-user-subscriptions", "lookoutequipment", "lookoutmetrics", "lookoutvision", "m2", "machinelearning", "managedblockchain", "mapcredits", "mediaconnect", "mediaconvert", "medialive", "mediapackage", "mediapackage-vod", "mediapackagev2", "mediastore", "mediatailor", "medical-imaging", "mgh", "mgn", "migrationhub-orchestrator", "mobiletargeting", "monitron", "mpa", "neptune-db", "neptune-graph", "network-security-manager", "networkflowmonitor", "networkmanager", "networkmonitor", "nimble", "notifications", "notifications-contacts", "nova-act", "observabilityadmin", "odb", "omics", "one", "opensearch", "opsworks", "osis", "outposts", "panorama", "partnercentral", "payments", "pca-connector-ad", "pca-connector-scep", "pcs", "personalize", "pi", "polly", "private-networks", "profile", "proton", "purchase-orders", "q", "qapps", "qbusiness", "qdeveloper", "qldb", "rbin", "rds-db", "refactor-spaces", "repostspace", "resiliencehub", "robomaker", "rolesanywhere", "route53-recovery-cluster", "route53-recovery-control-config", "route53-recovery-readiness", "route53globalresolver", "route53profiles", "rtbfabric", "s3-object-lambda", "s3-outposts", "s3express", "s3files", "sagemaker-geospatial", "sagemaker-mlflow", "savingsplans", "schemas", "scn", "sdb", "security-ir", "securityagent", "securitylake", "serverlessrepo", "shield", "simspaceweaver", "sms-voice", "snow-device-management", "social-messaging", "sqlworkbench", "ssm-contacts", "ssm-incidents", "ssm-quicksetup", "ssm-sap", "ssmmessages", "storagegateway", "supportauthz", "synthetics", "thinclient", "timestream", "tnb", "transform", "transform-custom", "trustedadvisor", "ts", "vendor-insights", "voiceid", "vpc-lattice", "vpc-lattice-svcs", "vpce", "waf", "waf-regional", "wellarchitected", "wickr", "wisdom", "workdocs", "worklink", "workmail", "workmailmessageflow", "workspaces", "workspaces-instances", "workspaces-web", "xray"],
|
||||
"arnFormats": {"access-analyzer": {"Analyzer": "arn:${Partition}:access-analyzer:${Region}:${Account}:analyzer/${AnalyzerName}", "ArchiveRule": "arn:${Partition}:access-analyzer:${Region}:${Account}:analyzer/${AnalyzerName}/archive-rule/${RuleName}"}, "acm": {"acme-domain-validation": "arn:${Partition}:acm:${Region}:${Account}:acme-endpoint/${AcmeEndpointId}/acme-domain-validation/${AcmeDomainValidationId}", "acme-endpoint": "arn:${Partition}:acm:${Region}:${Account}:acme-endpoint/${AcmeEndpointId}", "acme-external-account-binding": "arn:${Partition}:acm:${Region}:${Account}:acme-endpoint/${AcmeEndpointId}/acme-external-account-binding/${ExternalAccountBindingId}", "certificate": "arn:${Partition}:acm:${Region}:${Account}:certificate/${CertificateId}"}, "application-autoscaling": {"ScalableTarget": "arn:${Partition}:application-autoscaling:${Region}:${Account}:scalable-target/${ResourceId}"}, "athena": {"capacity-reservation": "arn:${Partition}:athena:${Region}:${Account}:capacity-reservation/${CapacityReservationName}", "datacatalog": "arn:${Partition}:athena:${Region}:${Account}:datacatalog/${DataCatalogName}", "session": "arn:${Partition}:athena:${Region}:${Account}:workgroup/${WorkGroupName}/session/${SessionId}", "system-table": "arn:${Partition}:athena:${Region}:${Account}:system-table/${TableName}", "workgroup": "arn:${Partition}:athena:${Region}:${Account}:workgroup/${WorkGroupName}"}, "bcm-data-exports": {"billingview": "arn:${Partition}:billing::${Account}:billingview/${ResourceId}", "export": "arn:${Partition}:bcm-data-exports:${Region}:${Account}:export/${Identifier}", "table": "arn:${Partition}:bcm-data-exports:${Region}:${Account}:table/${Identifier}"}, "bcm-pricing-calculator": {"bill-estimate": "arn:${Partition}:bcm-pricing-calculator::${Account}:bill-estimate/${BillEstimateId}", "bill-scenario": "arn:${Partition}:bcm-pricing-calculator::${Account}:bill-scenario/${BillScenarioId}", "workload-estimate": "arn:${Partition}:bcm-pricing-calculator::${Account}:workload-estimate/${WorkloadEstimateId}"}, "budgets": {"budget": "arn:${Partition}:budgets::${Account}:budget/${BudgetName}", "budgetAction": "arn:${Partition}:budgets::${Account}:budget/${BudgetName}/action/${ActionId}"}, "ce": {"anomalymonitor": "arn:${Partition}:ce::${Account}:anomalymonitor/${Identifier}", "anomalysubscription": "arn:${Partition}:ce::${Account}:anomalysubscription/${Identifier}", "billingview": "arn:${Partition}:billing::${Account}:billingview/${ResourceId}", "costcategory": "arn:${Partition}:ce::${Account}:costcategory/${Identifier}"}, "cloudtrail": {"channel": "arn:${Partition}:cloudtrail:${Region}:${Account}:channel/${ChannelId}", "dashboard": "arn:${Partition}:cloudtrail:${Region}:${Account}:dashboard/${DashboardName}", "eventdatastore": "arn:${Partition}:cloudtrail:${Region}:${Account}:eventdatastore/${EventDataStoreId}", "trail": "arn:${Partition}:cloudtrail:${Region}:${Account}:trail/${TrailName}"}, "codebuild": {"build": "arn:${Partition}:codebuild:${Region}:${Account}:build/${BuildId}", "build-batch": "arn:${Partition}:codebuild:${Region}:${Account}:build-batch/${BuildBatchId}", "fleet": "arn:${Partition}:codebuild:${Region}:${Account}:fleet/${FleetName}:${FleetId}", "project": "arn:${Partition}:codebuild:${Region}:${Account}:project/${ProjectName}", "report": "arn:${Partition}:codebuild:${Region}:${Account}:report/${ReportGroupName}:${ReportId}", "report-group": "arn:${Partition}:codebuild:${Region}:${Account}:report-group/${ReportGroupName}", "sandbox": "arn:${Partition}:codebuild:${Region}:${Account}:sandbox/${SandboxId}"}, "codepipeline": {"action": "arn:${Partition}:codepipeline:${Region}:${Account}:${PipelineName}/${StageName}/${ActionName}", "actiontype": "arn:${Partition}:codepipeline:${Region}:${Account}:actiontype:${Owner}/${Category}/${Provider}/${Version}", "pipeline": "arn:${Partition}:codepipeline:${Region}:${Account}:${PipelineName}", "stage": "arn:${Partition}:codepipeline:${Region}:${Account}:${PipelineName}/${StageName}", "webhook": "arn:${Partition}:codepipeline:${Region}:${Account}:webhook:${WebhookName}"}, "cognito-identity": {"identitypool": "arn:${Partition}:cognito-identity:${Region}:${Account}:identitypool/${IdentityPoolId}"}, "cognito-idp": {"userpool": "arn:${Partition}:cognito-idp:${Region}:${Account}:userpool/${UserPoolId}", "webacl": "arn:${Partition}:wafv2:${Region}:${Account}:${Scope}/webacl/${Name}/${Id}"}, "controltower": {"Baseline": "arn:${Partition}:controltower:${Region}::baseline/${BaselineId}", "EnabledBaseline": "arn:${Partition}:controltower:${Region}:${Account}:enabledbaseline/${EnabledBaselineId}", "EnabledControl": "arn:${Partition}:controltower:${Region}:${Account}:enabledcontrol/${EnabledControlId}", "LandingZone": "arn:${Partition}:controltower:${Region}:${Account}:landingzone/${LandingZoneId}"}, "cur": {"cur": "arn:${Partition}:cur:${Region}:${Account}:definition/${ReportName}"}, "datasync": {"agent": "arn:${Partition}:datasync:${Region}:${Account}:agent/${AgenLine truncated
|
||||
"otherNamespaces": ["a4b", "account-access", "acm-pca", "aco-automation", "agent-registry", "aidevops", "aiops", "airflow-serverless", "amplify", "amplifybackend", "amplifyuibuilder", "aoss", "appfabric", "appflow", "application-signals", "application-signals-mcp", "appmesh", "appmesh-preview", "apprunner", "appstream", "apptest", "arc-region-switch", "arc-zonal-shift", "artifact", "assurance", "auditmanager", "aws-external-anthropic", "b2bi", "backup-gateway", "backup-search", "bedrock-mantle", "bedrock-websearch", "billing", "billingconductor", "braket", "bugbust", "cases", "cassandra", "chatbot", "chime", "cleanrooms", "cleanrooms-ml", "cloud9", "clouddirectory", "cloudfront-keyvaluestore", "cloudsearch", "cloudshell", "cloudtrail-data", "codecatalyst", "codecommit", "codeconnections", "codeguru-profiler", "codeguru-security", "codestar-connections", "codestar-notifications", "codewhisperer", "cognito-sync", "connect-campaigns", "consoleapp", "continuum", "databrew", "dataexchange", "datapipeline", "datazone", "dax", "deadline", "devicefarm", "devops-guru", "directconnect", "docdb-elastic", "drs", "ds", "ds-data", "ebs", "ecr-public", "eks-auth", "elastictranscoder", "elemental-appliances-software", "elemental-inference", "elemental-support-cases", "emr-containers", "end-user-messaging", "entityresolution", "evs", "finspace", "finspace-api", "fms", "forecast", "frauddetector", "freertos", "fsx", "gamelift", "gameliftstreams", "geo", "geo-maps", "geo-places", "geo-routes", "glacier", "grafana", "greengrass", "groundstation", "health", "health-agent", "healthlake", "honeycode", "identity-sync", "imagebuilder", "interconnect", "internetmonitor", "invoicing", "iotanalytics", "iotdeviceadvisor", "iotfleethub", "iotfleetwise", "iotjobsdata", "iotmanagedintegrations", "iotsitewise", "iottwinmaker", "iotwireless", "iq", "iq-permission", "ivs", "ivschat", "kafka-cluster", "kafkaconnect", "kendra", "kendra-ranking", "kinesisvideo", "launchwizard", "lex", "license-manager", "license-manager-linux-subscriptions", "license-manager-user-subscriptions", "lookoutequipment", "lookoutmetrics", "lookoutvision", "m2", "machinelearning", "managedblockchain", "mapcredits", "mediaconnect", "mediaconvert", "medialive", "mediapackage", "mediapackage-vod", "mediapackagev2", "mediastore", "mediatailor", "medical-imaging", "mgh", "mgn", "migrationhub-orchestrator", "mobiletargeting", "monitron", "mpa", "neptune-db", "neptune-graph", "network-security-manager", "networkflowmonitor", "networkmanager", "networkmonitor", "nimble", "notifications", "notifications-contacts", "nova-act", "observabilityadmin", "odb", "omics", "one", "opensearch", "opsworks", "osis", "outposts", "panorama", "partnercentral", "payments", "pca-connector-ad", "pca-connector-scep", "pcs", "personalize", "pi", "polly", "private-networks", "profile", "proton", "purchase-orders", "q", "qapps", "qbusiness", "qdeveloper", "qldb", "rbin", "rds-db", "refactor-spaces", "repostspace", "resiliencehub", "robomaker", "rolesanywhere", "route53-recovery-cluster", "route53-recovery-control-config", "route53-recovery-readiness", "route53globalresolver", "route53profiles", "rtbfabric", "s3-object-lambda", "s3-outposts", "s3express", "s3files", "sagemaker-geospatial", "sagemaker-mlflow", "savingsplans", "schemas", "scn", "sdb", "security-ir", "securityagent", "securitylake", "serverlessrepo", "shield", "simspaceweaver", "sms-voice", "snow-device-management", "social-messaging", "sqlworkbench", "ssm-contacts", "ssm-incidents", "ssm-quicksetup", "ssm-sap", "ssmmessages", "storagegateway", "supportauthz", "synthetics", "thinclient", "timestream", "tnb", "transform", "transform-custom", "trustedadvisor", "ts", "vendor-insights", "voiceid", "vpc-lattice", "vpc-lattice-svcs", "vpce", "waf", "waf-regional", "wellarchitected", "wickr", "wisdom", "workdocs", "worklink", "workmail", "workmailmessageflow", "workspaces", "workspaces-instances", "workspaces-web"],
|
||||
"arnFormats": {"access-analyzer": {"Analyzer": "arn:${Partition}:access-analyzer:${Region}:${Account}:analyzer/${AnalyzerName}", "ArchiveRule": "arn:${Partition}:access-analyzer:${Region}:${Account}:analyzer/${AnalyzerName}/archive-rule/${RuleName}"}, "acm": {"acme-domain-validation": "arn:${Partition}:acm:${Region}:${Account}:acme-endpoint/${AcmeEndpointId}/acme-domain-validation/${AcmeDomainValidationId}", "acme-endpoint": "arn:${Partition}:acm:${Region}:${Account}:acme-endpoint/${AcmeEndpointId}", "acme-external-account-binding": "arn:${Partition}:acm:${Region}:${Account}:acme-endpoint/${AcmeEndpointId}/acme-external-account-binding/${ExternalAccountBindingId}", "certificate": "arn:${Partition}:acm:${Region}:${Account}:certificate/${CertificateId}"}, "application-autoscaling": {"ScalableTarget": "arn:${Partition}:application-autoscaling:${Region}:${Account}:scalable-target/${ResourceId}"}, "athena": {"capacity-reservation": "arn:${Partition}:athena:${Region}:${Account}:capacity-reservation/${CapacityReservationName}", "datacatalog": "arn:${Partition}:athena:${Region}:${Account}:datacatalog/${DataCatalogName}", "session": "arn:${Partition}:athena:${Region}:${Account}:workgroup/${WorkGroupName}/session/${SessionId}", "system-table": "arn:${Partition}:athena:${Region}:${Account}:system-table/${TableName}", "workgroup": "arn:${Partition}:athena:${Region}:${Account}:workgroup/${WorkGroupName}"}, "bcm-data-exports": {"billingview": "arn:${Partition}:billing::${Account}:billingview/${ResourceId}", "export": "arn:${Partition}:bcm-data-exports:${Region}:${Account}:export/${Identifier}", "table": "arn:${Partition}:bcm-data-exports:${Region}:${Account}:table/${Identifier}"}, "bcm-pricing-calculator": {"bill-estimate": "arn:${Partition}:bcm-pricing-calculator::${Account}:bill-estimate/${BillEstimateId}", "bill-scenario": "arn:${Partition}:bcm-pricing-calculator::${Account}:bill-scenario/${BillScenarioId}", "workload-estimate": "arn:${Partition}:bcm-pricing-calculator::${Account}:workload-estimate/${WorkloadEstimateId}"}, "budgets": {"budget": "arn:${Partition}:budgets::${Account}:budget/${BudgetName}", "budgetAction": "arn:${Partition}:budgets::${Account}:budget/${BudgetName}/action/${ActionId}"}, "ce": {"anomalymonitor": "arn:${Partition}:ce::${Account}:anomalymonitor/${Identifier}", "anomalysubscription": "arn:${Partition}:ce::${Account}:anomalysubscription/${Identifier}", "billingview": "arn:${Partition}:billing::${Account}:billingview/${ResourceId}", "costcategory": "arn:${Partition}:ce::${Account}:costcategory/${Identifier}"}, "cloudtrail": {"channel": "arn:${Partition}:cloudtrail:${Region}:${Account}:channel/${ChannelId}", "dashboard": "arn:${Partition}:cloudtrail:${Region}:${Account}:dashboard/${DashboardName}", "eventdatastore": "arn:${Partition}:cloudtrail:${Region}:${Account}:eventdatastore/${EventDataStoreId}", "trail": "arn:${Partition}:cloudtrail:${Region}:${Account}:trail/${TrailName}"}, "codebuild": {"build": "arn:${Partition}:codebuild:${Region}:${Account}:build/${BuildId}", "build-batch": "arn:${Partition}:codebuild:${Region}:${Account}:build-batch/${BuildBatchId}", "fleet": "arn:${Partition}:codebuild:${Region}:${Account}:fleet/${FleetName}:${FleetId}", "project": "arn:${Partition}:codebuild:${Region}:${Account}:project/${ProjectName}", "report": "arn:${Partition}:codebuild:${Region}:${Account}:report/${ReportGroupName}:${ReportId}", "report-group": "arn:${Partition}:codebuild:${Region}:${Account}:report-group/${ReportGroupName}", "sandbox": "arn:${Partition}:codebuild:${Region}:${Account}:sandbox/${SandboxId}"}, "codepipeline": {"action": "arn:${Partition}:codepipeline:${Region}:${Account}:${PipelineName}/${StageName}/${ActionName}", "actiontype": "arn:${Partition}:codepipeline:${Region}:${Account}:actiontype:${Owner}/${Category}/${Provider}/${Version}", "pipeline": "arn:${Partition}:codepipeline:${Region}:${Account}:${PipelineName}", "stage": "arn:${Partition}:codepipeline:${Region}:${Account}:${PipelineName}/${StageName}", "webhook": "arn:${Partition}:codepipeline:${Region}:${Account}:webhook:${WebhookName}"}, "cognito-identity": {"identitypool": "arn:${Partition}:cognito-identity:${Region}:${Account}:identitypool/${IdentityPoolId}"}, "cognito-idp": {"userpool": "arn:${Partition}:cognito-idp:${Region}:${Account}:userpool/${UserPoolId}", "webacl": "arn:${Partition}:wafv2:${Region}:${Account}:${Scope}/webacl/${Name}/${Id}"}, "controltower": {"Baseline": "arn:${Partition}:controltower:${Region}::baseline/${BaselineId}", "EnabledBaseline": "arn:${Partition}:controltower:${Region}:${Account}:enabledbaseline/${EnabledBaselineId}", "EnabledControl": "arn:${Partition}:controltower:${Region}:${Account}:enabledcontrol/${EnabledControlId}", "LandingZone": "arn:${Partition}:controltower:${Region}:${Account}:landingzone/${LandingZoneId}"}, "cur": {"cur": "arn:${Partition}:cur:${Region}:${Account}:definition/${ReportName}"}, "datasync": {"agent": "arn:${Partition}:datasync:${Region}:${Account}:agent/${AgenLine truncated
|
||||
"unqualified": {"states": ["statemachine"]},
|
||||
"mintedIds": {"events": ["api-destination", "connection"]},
|
||||
"operations": {
|
||||
@@ -3027,6 +3027,44 @@
|
||||
"translate:TranslateDocument": {"action": "translate:TranslateDocument", "types": ["terminology"], "resources": [{"type": "terminology", "fill": {"ResourceName": "TerminologyNames[]"}}]},
|
||||
"translate:TranslateText": {"action": "translate:TranslateText", "types": ["parallel-data", "terminology"], "resources": [{"type": "terminology", "fill": {"ResourceName": "TerminologyNames[]"}}]},
|
||||
"translate:UntagResource": {"action": "translate:UntagResource", "types": ["parallel-data", "terminology"], "resources": [{"types": ["parallel-data", "terminology"], "arn": "ResourceArn"}]},
|
||||
"translate:UpdateParallelData": {"action": "translate:UpdateParallelData", "types": ["parallel-data"], "resources": [{"type": "parallel-data", "fill": {"ResourceName": "Name"}}]}
|
||||
"translate:UpdateParallelData": {"action": "translate:UpdateParallelData", "types": ["parallel-data"], "resources": [{"type": "parallel-data", "fill": {"ResourceName": "Name"}}]},
|
||||
"xray:BatchGetTraces": {"action": "xray:BatchGetTraces", "types": [], "resources": []},
|
||||
"xray:CancelTraceRetrieval": {"action": "xray:CancelTraceRetrieval", "types": [], "resources": []},
|
||||
"xray:CreateGroup": {"action": "xray:CreateGroup", "types": ["group"], "resources": [{"type": "group", "fill": {"GroupName": "GroupName"}}]},
|
||||
"xray:CreateSamplingRule": {"action": "xray:CreateSamplingRule", "types": ["sampling-rule"], "resources": [{"types": ["sampling-rule"], "arn": "SamplingRule.ResourceARN"}, {"types": ["sampling-rule"], "arn": "SamplingRule.RuleARN"}, {"type": "sampling-rule", "fill": {}}]},
|
||||
"xray:DeleteGroup": {"action": "xray:DeleteGroup", "types": ["group"], "resources": [{"types": ["group"], "arn": "GroupARN"}, {"type": "group", "fill": {"GroupName": "GroupName"}}]},
|
||||
"xray:DeleteResourcePolicy": {"action": "xray:DeleteResourcePolicy", "types": [], "resources": []},
|
||||
"xray:DeleteSamplingRule": {"action": "xray:DeleteSamplingRule", "types": ["sampling-rule"], "resources": [{"types": ["sampling-rule"], "arn": "RuleARN"}, {"type": "sampling-rule", "fill": {"SamplingRuleName": "RuleName"}}]},
|
||||
"xray:GetEncryptionConfig": {"action": "xray:GetEncryptionConfig", "types": [], "resources": []},
|
||||
"xray:GetGroup": {"action": "xray:GetGroup", "types": ["group"], "resources": [{"types": ["group"], "arn": "GroupARN"}, {"type": "group", "fill": {"GroupName": "GroupName"}}]},
|
||||
"xray:GetGroups": {"action": "xray:GetGroups", "types": [], "resources": []},
|
||||
"xray:GetIndexingRules": {"action": "xray:GetIndexingRules", "types": [], "resources": []},
|
||||
"xray:GetInsight": {"action": "xray:GetInsight", "types": [], "resources": []},
|
||||
"xray:GetInsightEvents": {"action": "xray:GetInsightEvents", "types": [], "resources": []},
|
||||
"xray:GetInsightImpactGraph": {"action": "xray:GetInsightImpactGraph", "types": [], "resources": []},
|
||||
"xray:GetInsightSummaries": {"action": "xray:GetInsightSummaries", "types": [], "resources": []},
|
||||
"xray:GetRetrievedTracesGraph": {"action": "xray:GetRetrievedTracesGraph", "types": [], "resources": []},
|
||||
"xray:GetSamplingRules": {"action": "xray:GetSamplingRules", "types": [], "resources": []},
|
||||
"xray:GetSamplingStatisticSummaries": {"action": "xray:GetSamplingStatisticSummaries", "types": [], "resources": []},
|
||||
"xray:GetSamplingTargets": {"action": "xray:GetSamplingTargets", "types": [], "resources": []},
|
||||
"xray:GetServiceGraph": {"action": "xray:GetServiceGraph", "types": [], "resources": []},
|
||||
"xray:GetTimeSeriesServiceStatistics": {"action": "xray:GetTimeSeriesServiceStatistics", "types": [], "resources": []},
|
||||
"xray:GetTraceGraph": {"action": "xray:GetTraceGraph", "types": [], "resources": []},
|
||||
"xray:GetTraceSegmentDestination": {"action": "xray:GetTraceSegmentDestination", "types": [], "resources": []},
|
||||
"xray:GetTraceSummaries": {"action": "xray:GetTraceSummaries", "types": [], "resources": []},
|
||||
"xray:ListResourcePolicies": {"action": "xray:ListResourcePolicies", "types": [], "resources": []},
|
||||
"xray:ListRetrievedTraces": {"action": "xray:ListRetrievedTraces", "types": [], "resources": []},
|
||||
"xray:ListTagsForResource": {"action": "xray:ListTagsForResource", "types": ["group", "sampling-rule"], "resources": [{"types": ["group", "sampling-rule"], "arn": "ResourceARN"}]},
|
||||
"xray:PutEncryptionConfig": {"action": "xray:PutEncryptionConfig", "types": [], "resources": []},
|
||||
"xray:PutResourcePolicy": {"action": "xray:PutResourcePolicy", "types": [], "resources": []},
|
||||
"xray:PutTelemetryRecords": {"action": "xray:PutTelemetryRecords", "types": [], "resources": []},
|
||||
"xray:PutTraceSegments": {"action": "xray:PutTraceSegments", "types": [], "resources": []},
|
||||
"xray:StartTraceRetrieval": {"action": "xray:StartTraceRetrieval", "types": [], "resources": []},
|
||||
"xray:TagResource": {"action": "xray:TagResource", "types": ["group", "sampling-rule"], "resources": [{"types": ["group", "sampling-rule"], "arn": "ResourceARN"}]},
|
||||
"xray:UntagResource": {"action": "xray:UntagResource", "types": ["group", "sampling-rule"], "resources": [{"types": ["group", "sampling-rule"], "arn": "ResourceARN"}]},
|
||||
"xray:UpdateGroup": {"action": "xray:UpdateGroup", "types": ["group"], "resources": [{"types": ["group"], "arn": "GroupARN"}, {"type": "group", "fill": {"GroupName": "GroupName"}}]},
|
||||
"xray:UpdateIndexingRule": {"action": "xray:UpdateIndexingRule", "types": [], "resources": []},
|
||||
"xray:UpdateSamplingRule": {"action": "xray:UpdateSamplingRule", "types": ["sampling-rule"], "resources": [{"types": ["sampling-rule"], "arn": "SamplingRuleUpdate.ResourceARN"}, {"types": ["sampling-rule"], "arn": "SamplingRuleUpdate.RuleARN"}]},
|
||||
"xray:UpdateTraceSegmentDestination": {"action": "xray:UpdateTraceSegmentDestination", "types": [], "resources": []}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"_source": {"generator": "tools/aws/regen_iam_tag_on_create.py", "reference": "https://servicereference.us-east-1.amazonaws.com/", "botocore": "botocore 1.43.118 (installed package)", "retrieved": "2026-11-10", "note": "make iam-tag-on-create-check re-derives every member from botocore; make iam-tag-on-create-verify checks every operation against AWS."},
|
||||
"namespaces": {"access-analyzer": ["accessanalyzer"], "acm": ["acm"], "application-autoscaling": ["application-autoscaling"], "athena": ["athena"], "autoscaling": ["autoscaling"], "bcm-data-exports": ["bcm-data-exports"], "bcm-pricing-calculator": ["bcm-pricing-calculator"], "budgets": ["budgets"], "ce": ["ce"], "cloudformation": ["cloudformation"], "cloudhsm": ["cloudhsmv2"], "cloudtrail": ["cloudtrail"], "cloudwatch": ["cloudwatch", "cloudwatchomni"], "codedeploy": ["codedeploy"], "codepipeline": ["codepipeline"], "cognito-identity": ["cognito-identity"], "cognito-idp": ["cognito-idp"], "comprehend": ["comprehend"], "config": ["config"], "controltower": ["controltower"], "cur": ["cur"], "datasync": ["datasync"], "dms": ["dms"], "dsql": ["dsql"], "dynamodb": ["dynamodb"], "ec2": ["ec2"], "ecr": ["ecr"], "ecs": ["ecs"], "eks": ["eks"], "elasticache": ["elasticache"], "elasticloadbalancing": ["elb", "elbv2"], "elasticmapreduce": ["emr"], "es": ["es", "opensearch"], "events": ["eventbridgev2", "events"], "firehose": ["firehose"], "globalaccelerator": ["globalaccelerator"], "glue": ["glue"], "iam": ["iam"], "kinesis": ["kinesis"], "kinesisanalytics": ["kinesisanalytics", "kinesisanalyticsv2"], "kms": ["kms"], "lambda": ["lambda", "lambda-core", "lambda-microvms", "lambda-web"], "lightsail": ["lightsail"], "logs": ["logs"], "macie2": ["macie2"], "memorydb": ["memorydb"], "network-firewall": ["network-firewall"], "organizations": ["organizations"], "payment-cryptography": ["payment-cryptography"], "pipes": ["pipes"], "rds": ["docdb", "neptune", "rds"], "redshift": ["redshift"], "redshift-serverless": ["redshift-serverless"], "rekognition": ["rekognition"], "resource-groups": ["resource-groups"], "route53resolver": ["route53resolver"], "sagemaker": ["sagemaker"], "scheduler": ["scheduler"], "secretsmanager": ["secretsmanager"], "servicediscovery": ["servicediscovery"], "ses": ["mailmanager", "pinpoint-email", "ses", "sesv2"], "signer": ["signer"], "sns": ["sns"], "sqs": ["sqs"], "ssm": ["ssm"], "sso": ["sso-admin"], "states": ["stepfunctions"], "sts": ["sts"], "swf": ["swf"], "textract": ["textract"], "timestream-influxdb": ["timestream-influxdb"], "transcribe": ["transcribe"], "transfer": ["transfer"], "translate": ["translate"], "wafv2": ["wafv2"]},
|
||||
"_source": {"generator": "tools/aws/regen_iam_tag_on_create.py", "reference": "https://servicereference.us-east-1.amazonaws.com/", "botocore": "botocore 1.43.118 (installed package)", "retrieved": "2026-11-11", "note": "make iam-tag-on-create-check re-derives every member from botocore; make iam-tag-on-create-verify checks every operation against AWS."},
|
||||
"namespaces": {"access-analyzer": ["accessanalyzer"], "acm": ["acm"], "application-autoscaling": ["application-autoscaling"], "athena": ["athena"], "autoscaling": ["autoscaling"], "bcm-data-exports": ["bcm-data-exports"], "bcm-pricing-calculator": ["bcm-pricing-calculator"], "budgets": ["budgets"], "ce": ["ce"], "cloudformation": ["cloudformation"], "cloudhsm": ["cloudhsmv2"], "cloudtrail": ["cloudtrail"], "cloudwatch": ["cloudwatch", "cloudwatchomni"], "codedeploy": ["codedeploy"], "codepipeline": ["codepipeline"], "cognito-identity": ["cognito-identity"], "cognito-idp": ["cognito-idp"], "comprehend": ["comprehend"], "config": ["config"], "controltower": ["controltower"], "cur": ["cur"], "datasync": ["datasync"], "dms": ["dms"], "dsql": ["dsql"], "dynamodb": ["dynamodb"], "ec2": ["ec2"], "ecr": ["ecr"], "ecs": ["ecs"], "eks": ["eks"], "elasticache": ["elasticache"], "elasticloadbalancing": ["elb", "elbv2"], "elasticmapreduce": ["emr"], "es": ["es", "opensearch"], "events": ["eventbridgev2", "events"], "firehose": ["firehose"], "globalaccelerator": ["globalaccelerator"], "glue": ["glue"], "iam": ["iam"], "kinesis": ["kinesis"], "kinesisanalytics": ["kinesisanalytics", "kinesisanalyticsv2"], "kms": ["kms"], "lambda": ["lambda", "lambda-core", "lambda-microvms", "lambda-web"], "lightsail": ["lightsail"], "logs": ["logs"], "macie2": ["macie2"], "memorydb": ["memorydb"], "network-firewall": ["network-firewall"], "organizations": ["organizations"], "payment-cryptography": ["payment-cryptography"], "pipes": ["pipes"], "rds": ["docdb", "neptune", "rds"], "redshift": ["redshift"], "redshift-serverless": ["redshift-serverless"], "rekognition": ["rekognition"], "resource-groups": ["resource-groups"], "route53resolver": ["route53resolver"], "sagemaker": ["sagemaker"], "scheduler": ["scheduler"], "secretsmanager": ["secretsmanager"], "servicediscovery": ["servicediscovery"], "ses": ["mailmanager", "pinpoint-email", "ses", "sesv2"], "signer": ["signer"], "sns": ["sns"], "sqs": ["sqs"], "ssm": ["ssm"], "sso": ["sso-admin"], "states": ["stepfunctions"], "sts": ["sts"], "swf": ["swf"], "textract": ["textract"], "timestream-influxdb": ["timestream-influxdb"], "transcribe": ["transcribe"], "transfer": ["transfer"], "translate": ["translate"], "wafv2": ["wafv2"], "xray": ["xray"]},
|
||||
"notCovered": {"airflow": "REST routes no rule maps yet", "app-integrations": "REST routes no rule maps yet", "appconfig": "REST routes no rule maps yet", "appsync": "REST routes no rule maps yet", "aps": "REST routes no rule maps yet", "aws-marketplace": "REST routes no rule maps yet", "backup": "REST routes no rule maps yet", "batch": "REST routes no rule maps yet", "bedrock": "REST routes no rule maps yet", "bedrock-agentcore": "REST routes no rule maps yet", "cloudfront": "REST routes no rule maps yet", "codeguru-reviewer": "REST routes no rule maps yet", "connect": "REST routes no rule maps yet", "detective": "REST routes no rule maps yet", "dlm": "REST routes no rule maps yet", "elasticfilesystem": "REST routes no rule maps yet", "emr-serverless": "REST routes no rule maps yet", "fis": "REST routes no rule maps yet", "guardduty": "REST routes no rule maps yet", "inspector2": "REST routes no rule maps yet", "iot": "REST routes no rule maps yet", "kafka": "REST routes no rule maps yet", "mq": "REST routes no rule maps yet", "oam": "REST routes no rule maps yet", "quicksight": "metadata-only REST subset; creation-tag IAM authorization is not implemented", "ram": "REST routes no rule maps yet", "resource-explorer-2": "REST routes no rule maps yet", "rum": "REST routes no rule maps yet", "s3": "authorized by route; S3 checks s3:PutObjectTagging for an object it creates with tags itself", "s3tables": "REST routes no rule maps yet", "securityhub": "REST routes no rule maps yet", "servicecatalog": "its operations that tag are AppRegistry's, whose REST routes no rule maps yet"},
|
||||
"otherNamespaces": ["account-access", "acm-pca", "aco-automation", "agent-registry", "aidevops", "aiops", "airflow-serverless", "amplify", "amplifyuibuilder", "aoss", "appfabric", "appflow", "application-signals", "applicationinsights", "appmesh", "apprunner", "appstream", "arc-region-switch", "artifact", "auditmanager", "b2bi", "backup-gateway", "backup-search", "bcm-dashboards", "billing", "billingconductor", "braket", "cases", "cassandra", "chatbot", "chime", "cleanrooms", "cleanrooms-ml", "cloud9", "codecommit", "codeconnections", "codeguru-profiler", "codeguru-security", "codestar-connections", "codestar-notifications", "connect-campaigns", "databrew", "dataexchange", "datapipeline", "datazone", "dax", "deadline", "directconnect", "docdb-elastic", "drs", "ds", "ebs", "ecr-public", "elemental-inference", "emr-containers", "entityresolution", "evs", "fms", "forecast", "frauddetector", "fsx", "gamelift", "gameliftstreams", "geo", "grafana", "greengrass", "groundstation", "health-agent", "healthlake", "imagebuilder", "interconnect", "internetmonitor", "invoicing", "iotdeviceadvisor", "iotfleetwise", "iotmanagedintegrations", "iotsitewise", "iottwinmaker", "iotwireless", "ivs", "ivschat", "kafkaconnect", "kendra", "kendra-ranking", "kinesisvideo", "launchwizard", "lex", "license-manager", "license-manager-linux-subscriptions", "license-manager-user-subscriptions", "lookoutequipment", "m2", "managedblockchain", "mediaconnect", "mediaconvert", "medialive", "mediapackage", "mediapackage-vod", "mediapackagev2", "mediastore", "mediatailor", "medical-imaging", "mgn", "migrationhub-orchestrator", "mobiletargeting", "mpa", "neptune-graph", "network-security-manager", "networkflowmonitor", "networkmanager", "networkmonitor", "notifications", "notifications-contacts", "observabilityadmin", "odb", "omics", "opensearch", "osis", "outposts", "partnercentral", "pca-connector-ad", "pca-connector-scep", "pcs", "personalize", "pi", "polly", "profile", "proton", "qbusiness", "rbin", "refactor-spaces", "repostspace", "resiliencehub", "rolesanywhere", "route53-recovery-control-config", "route53-recovery-readiness", "route53globalresolver", "route53profiles", "rtbfabric", "s3files", "sagemaker-geospatial", "savingsplans", "schemas", "scn", "security-ir", "securityagent", "securitylake", "shield", "sms-voice", "snow-device-management", "social-messaging", "ssm-contacts", "ssm-incidents", "ssm-quicksetup", "ssm-sap", "storagegateway", "supportauthz", "synthetics", "thinclient", "timestream", "voiceid", "vpc-lattice", "waf", "waf-regional", "wellarchitected", "wickr", "wisdom", "workspaces", "workspaces-instances", "workspaces-web", "xray"],
|
||||
"otherNamespaces": ["account-access", "acm-pca", "aco-automation", "agent-registry", "aidevops", "aiops", "airflow-serverless", "amplify", "amplifyuibuilder", "aoss", "appfabric", "appflow", "application-signals", "applicationinsights", "appmesh", "apprunner", "appstream", "arc-region-switch", "artifact", "auditmanager", "b2bi", "backup-gateway", "backup-search", "bcm-dashboards", "billing", "billingconductor", "braket", "cases", "cassandra", "chatbot", "chime", "cleanrooms", "cleanrooms-ml", "cloud9", "codecommit", "codeconnections", "codeguru-profiler", "codeguru-security", "codestar-connections", "codestar-notifications", "connect-campaigns", "databrew", "dataexchange", "datapipeline", "datazone", "dax", "deadline", "directconnect", "docdb-elastic", "drs", "ds", "ebs", "ecr-public", "elemental-inference", "emr-containers", "entityresolution", "evs", "fms", "forecast", "frauddetector", "fsx", "gamelift", "gameliftstreams", "geo", "grafana", "greengrass", "groundstation", "health-agent", "healthlake", "imagebuilder", "interconnect", "internetmonitor", "invoicing", "iotdeviceadvisor", "iotfleetwise", "iotmanagedintegrations", "iotsitewise", "iottwinmaker", "iotwireless", "ivs", "ivschat", "kafkaconnect", "kendra", "kendra-ranking", "kinesisvideo", "launchwizard", "lex", "license-manager", "license-manager-linux-subscriptions", "license-manager-user-subscriptions", "lookoutequipment", "m2", "managedblockchain", "mediaconnect", "mediaconvert", "medialive", "mediapackage", "mediapackage-vod", "mediapackagev2", "mediastore", "mediatailor", "medical-imaging", "mgn", "migrationhub-orchestrator", "mobiletargeting", "mpa", "neptune-graph", "network-security-manager", "networkflowmonitor", "networkmanager", "networkmonitor", "notifications", "notifications-contacts", "observabilityadmin", "odb", "omics", "opensearch", "osis", "outposts", "partnercentral", "pca-connector-ad", "pca-connector-scep", "pcs", "personalize", "pi", "polly", "profile", "proton", "qbusiness", "rbin", "refactor-spaces", "repostspace", "resiliencehub", "rolesanywhere", "route53-recovery-control-config", "route53-recovery-readiness", "route53globalresolver", "route53profiles", "rtbfabric", "s3files", "sagemaker-geospatial", "savingsplans", "schemas", "scn", "security-ir", "securityagent", "securitylake", "shield", "sms-voice", "snow-device-management", "social-messaging", "ssm-contacts", "ssm-incidents", "ssm-quicksetup", "ssm-sap", "storagegateway", "supportauthz", "synthetics", "thinclient", "timestream", "voiceid", "vpc-lattice", "waf", "waf-regional", "wellarchitected", "wickr", "wisdom", "workspaces", "workspaces-instances", "workspaces-web"],
|
||||
"resourceArns": {"ec2": {"application-status-check": "arn:${Partition}:ec2:${Region}:${Account}:application-status-check/*", "capacity-block": "arn:${Partition}:ec2:${Region}:${Account}:capacity-block/*", "capacity-manager-data-export": "arn:${Partition}:ec2:${Region}:${Account}:capacity-manager-data-export/*", "capacity-reservation": "arn:${Partition}:ec2:${Region}:${Account}:capacity-reservation/*", "capacity-reservation-cancellation-quote": "arn:${Partition}:ec2:${Region}:${Account}:capacity-reservation-cancellation-quote/*", "capacity-reservation-fleet": "arn:${Partition}:ec2:${Region}:${Account}:capacity-reservation-fleet/*", "capacity-reservation-modification-quote": "arn:${Partition}:ec2:${Region}:${Account}:capacity-reservation-modification-quote/*", "carrier-gateway": "arn:${Partition}:ec2:${Region}:${Account}:carrier-gateway/*", "certificate": "arn:${Partition}:acm:${Region}:${Account}:certificate/*", "client-vpn-endpoint": "arn:${Partition}:ec2:${Region}:${Account}:client-vpn-endpoint/*", "coip-pool": "arn:${Partition}:ec2:${Region}:${Account}:coip-pool/*", "customer-gateway": "arn:${Partition}:ec2:${Region}:${Account}:customer-gateway/*", "declarative-policies-report": "arn:${Partition}:ec2:${Region}:${Account}:declarative-policies-report/*", "dedicated-host": "arn:${Partition}:ec2:${Region}:${Account}:dedicated-host/*", "dhcp-options": "arn:${Partition}:ec2:${Region}:${Account}:dhcp-options/*", "egress-only-internet-gateway": "arn:${Partition}:ec2:${Region}:${Account}:egress-only-internet-gateway/*", "elastic-gpu": "arn:${Partition}:ec2:${Region}:${Account}:elastic-gpu/*", "elastic-inference": "arn:${Partition}:elastic-inference:${Region}:${Account}:elastic-inference-accelerator/*", "elastic-ip": "arn:${Partition}:ec2:${Region}:${Account}:elastic-ip/*", "export-image-task": "arn:${Partition}:ec2:${Region}:${Account}:export-image-task/*", "export-instance-task": "arn:${Partition}:ec2:${Region}:${Account}:export-instance-task/*", "fleet": "arn:${Partition}:ec2:${Region}:${Account}:fleet/*", "fpga-image": "arn:${Partition}:ec2:${Region}:${Account}:fpga-image/*", "group": "arn:${Partition}:resource-groups:${Region}:${Account}:group/*", "host-reservation": "arn:${Partition}:ec2:${Region}:${Account}:host-reservation/*", "image": "arn:${Partition}:ec2:${Region}::image/*", "image-usage-report": "arn:${Partition}:ec2:${Region}:${Account}:image-usage-report/*", "import-image-task": "arn:${Partition}:ec2:${Region}:${Account}:import-image-task/*", "import-snapshot-task": "arn:${Partition}:ec2:${Region}:${Account}:import-snapshot-task/*", "instance": "arn:${Partition}:ec2:${Region}:${Account}:instance/*", "instance-connect-endpoint": "arn:${Partition}:ec2:${Region}:${Account}:instance-connect-endpoint/*", "instance-event-window": "arn:${Partition}:ec2:${Region}:${Account}:instance-event-window/*", "internet-gateway": "arn:${Partition}:ec2:${Region}:${Account}:internet-gateway/*", "ipam": "arn:${Partition}:ec2::${Account}:ipam/*", "ipam-external-resource-verification-token": "arn:${Partition}:ec2::${Account}:ipam-external-resource-verification-token/*", "ipam-internet-registry-association": "arn:${Partition}:ec2::${Account}:ipam-internet-registry-association/*", "ipam-policy": "arn:${Partition}:ec2::${Account}:ipam-policy/*", "ipam-pool": "arn:${Partition}:ec2::${Account}:ipam-pool/*", "ipam-pool-allocation": "arn:${Partition}:ec2:${Region}:${Account}:ipam-pool-allocation/*", "ipam-prefix-list-resolver": "arn:${Partition}:ec2::${Account}:ipam-prefix-list-resolver/*", "ipam-prefix-list-resolver-target": "arn:${Partition}:ec2::${Account}:ipam-prefix-list-resolver-target/*", "ipam-resource-discovery": "arn:${Partition}:ec2::${Account}:ipam-resource-discovery/*", "ipam-resource-discovery-association": "arn:${Partition}:ec2::${Account}:ipam-resource-discovery-association/*", "ipam-scope": "arn:${Partition}:ec2::${Account}:ipam-scope/*", "ipv4pool-ec2": "arn:${Partition}:ec2:${Region}:${Account}:ipv4pool-ec2/*", "ipv6pool-ec2": "arn:${Partition}:ec2:${Region}:${Account}:ipv6pool-ec2/*", "key-pair": "arn:${Partition}:ec2:${Region}:${Account}:key-pair/*", "launch-template": "arn:${Partition}:ec2:${Region}:${Account}:launch-template/*", "license-configuration": "arn:${Partition}:license-manager:${Region}:${Account}:license-configuration:*", "local-gateway": "arn:${Partition}:ec2:${Region}:${Account}:local-gateway/*", "local-gateway-route-table": "arn:${Partition}:ec2:${Region}:${Account}:local-gateway-route-table/*", "local-gateway-route-table-virtual-interface-group-association": "arn:${Partition}:ec2:${Region}:${Account}:local-gateway-route-table-virtual-interface-group-association/*", "local-gateway-route-table-vpc-association": "arn:${Partition}:ec2:${Region}:${Account}:local-gateway-route-table-vpc-association/*", "local-gateway-virtual-interface": "arn:${Partition}:ec2:${Region}:${Account}:local-gateway-virtual-interface/*", "local-gateway-virtual-interface-group": "arn:${Partition}:ec2:${Region}:${Account}:Line truncated
|
||||
"operations": {
|
||||
"access-analyzer:CreateAnalyzer": {"tagging": ["access-analyzer:TagResource"], "requestTags": true, "tags": [{"member": "tags{}"}]},
|
||||
@@ -287,6 +287,7 @@
|
||||
"events:CreateEventSource": {"tagging": ["events:TagResource"], "requestTags": true, "tags": [{"member": "Tags{}"}]},
|
||||
"events:CreateSubscriber": {"tagging": ["events:TagResource"], "requestTags": true, "tags": [{"member": "Tags{}"}]},
|
||||
"events:PutRule": {"tagging": ["events:TagResource"], "requestTags": true, "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]},
|
||||
"events:StartReplay": {"tagging": ["events:TagResource"], "notRead": "no member of the request carries tags"},
|
||||
"firehose:CreateDeliveryStream": {"tagging": ["firehose:TagDeliveryStream"], "requestTags": true, "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]},
|
||||
"globalaccelerator:CreateAccelerator": {"tagging": ["globalaccelerator:TagResource"], "requestTags": true, "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]},
|
||||
"globalaccelerator:CreateCrossAccountAttachment": {"tagging": ["globalaccelerator:TagResource"], "requestTags": true, "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]},
|
||||
@@ -373,6 +374,7 @@
|
||||
"network-firewall:CreateContainerAssociation": {"tagging": ["network-firewall:TagResource"], "requestTags": true, "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]},
|
||||
"network-firewall:CreateFirewall": {"tagging": ["network-firewall:TagResource"], "requestTags": true, "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]},
|
||||
"network-firewall:CreateFirewallPolicy": {"tagging": ["network-firewall:TagResource"], "requestTags": true, "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]},
|
||||
"network-firewall:CreateFirewallPolicyV2": {"tagging": ["network-firewall:TagResource"], "requestTags": true, "notRead": "no member of the request carries tags"},
|
||||
"network-firewall:CreateProxy": {"tagging": ["network-firewall:TagResource"], "requestTags": true, "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]},
|
||||
"network-firewall:CreateProxyConfiguration": {"tagging": ["network-firewall:TagResource"], "requestTags": true, "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]},
|
||||
"network-firewall:CreateProxyRuleGroup": {"tagging": ["network-firewall:TagResource"], "requestTags": true, "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]},
|
||||
@@ -603,6 +605,8 @@
|
||||
"wafv2:CreateIPSet": {"tagging": ["wafv2:TagResource"], "requestTags": true, "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]},
|
||||
"wafv2:CreateRegexPatternSet": {"tagging": ["wafv2:TagResource"], "requestTags": true, "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]},
|
||||
"wafv2:CreateRuleGroup": {"tagging": ["wafv2:TagResource"], "requestTags": true, "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]},
|
||||
"wafv2:CreateWebACL": {"tagging": ["wafv2:TagResource"], "requestTags": true, "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]}
|
||||
"wafv2:CreateWebACL": {"tagging": ["wafv2:TagResource"], "requestTags": true, "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]},
|
||||
"xray:CreateGroup": {"tagging": ["xray:TagResource"], "requestTags": true, "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]},
|
||||
"xray:CreateSamplingRule": {"tagging": ["xray:TagResource"], "requestTags": true, "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]}
|
||||
}
|
||||
}
|
||||
@@ -1589,6 +1589,50 @@
|
||||
"TagResource": {"method": "POST", "requestUri": "/tags/{resourceArn+}", "alternatives": [{"requestUri": "/tags", "located": {"resourceArn": "body"}}]},
|
||||
"UntagResource": {"method": "DELETE", "requestUri": "/tags/{resourceArn+}", "alternatives": [{"requestUri": "/tags", "located": {"resourceArn": "?resourceArn"}}]}
|
||||
}
|
||||
},
|
||||
"xray": {
|
||||
"credentialScope": "xray",
|
||||
"apiVersion": "2016-04-12",
|
||||
"operations": {
|
||||
"BatchGetTraces": {"method": "POST", "requestUri": "/_xray/Traces"},
|
||||
"CancelTraceRetrieval": {"method": "POST", "requestUri": "/_xray/CancelTraceRetrieval"},
|
||||
"CreateGroup": {"method": "POST", "requestUri": "/_xray/CreateGroup"},
|
||||
"CreateSamplingRule": {"method": "POST", "requestUri": "/_xray/CreateSamplingRule"},
|
||||
"DeleteGroup": {"method": "POST", "requestUri": "/_xray/DeleteGroup"},
|
||||
"DeleteResourcePolicy": {"method": "POST", "requestUri": "/_xray/DeleteResourcePolicy"},
|
||||
"DeleteSamplingRule": {"method": "POST", "requestUri": "/_xray/DeleteSamplingRule"},
|
||||
"GetEncryptionConfig": {"method": "POST", "requestUri": "/_xray/EncryptionConfig"},
|
||||
"GetGroup": {"method": "POST", "requestUri": "/_xray/GetGroup"},
|
||||
"GetGroups": {"method": "POST", "requestUri": "/_xray/Groups"},
|
||||
"GetIndexingRules": {"method": "POST", "requestUri": "/_xray/GetIndexingRules"},
|
||||
"GetInsight": {"method": "POST", "requestUri": "/_xray/Insight"},
|
||||
"GetInsightEvents": {"method": "POST", "requestUri": "/_xray/InsightEvents"},
|
||||
"GetInsightImpactGraph": {"method": "POST", "requestUri": "/_xray/InsightImpactGraph"},
|
||||
"GetInsightSummaries": {"method": "POST", "requestUri": "/_xray/InsightSummaries"},
|
||||
"GetRetrievedTracesGraph": {"method": "POST", "requestUri": "/_xray/GetRetrievedTracesGraph"},
|
||||
"GetSamplingRules": {"method": "POST", "requestUri": "/_xray/GetSamplingRules"},
|
||||
"GetSamplingStatisticSummaries": {"method": "POST", "requestUri": "/_xray/SamplingStatisticSummaries"},
|
||||
"GetSamplingTargets": {"method": "POST", "requestUri": "/_xray/SamplingTargets"},
|
||||
"GetServiceGraph": {"method": "POST", "requestUri": "/_xray/ServiceGraph"},
|
||||
"GetTimeSeriesServiceStatistics": {"method": "POST", "requestUri": "/_xray/TimeSeriesServiceStatistics"},
|
||||
"GetTraceGraph": {"method": "POST", "requestUri": "/_xray/TraceGraph"},
|
||||
"GetTraceSegmentDestination": {"method": "POST", "requestUri": "/_xray/GetTraceSegmentDestination"},
|
||||
"GetTraceSummaries": {"method": "POST", "requestUri": "/_xray/TraceSummaries"},
|
||||
"ListResourcePolicies": {"method": "POST", "requestUri": "/_xray/ListResourcePolicies"},
|
||||
"ListRetrievedTraces": {"method": "POST", "requestUri": "/_xray/ListRetrievedTraces"},
|
||||
"ListTagsForResource": {"method": "POST", "requestUri": "/_xray/ListTagsForResource"},
|
||||
"PutEncryptionConfig": {"method": "POST", "requestUri": "/_xray/PutEncryptionConfig"},
|
||||
"PutResourcePolicy": {"method": "POST", "requestUri": "/_xray/PutResourcePolicy"},
|
||||
"PutTelemetryRecords": {"method": "POST", "requestUri": "/_xray/TelemetryRecords"},
|
||||
"PutTraceSegments": {"method": "POST", "requestUri": "/_xray/TraceSegments"},
|
||||
"StartTraceRetrieval": {"method": "POST", "requestUri": "/_xray/StartTraceRetrieval"},
|
||||
"TagResource": {"method": "POST", "requestUri": "/_xray/TagResource"},
|
||||
"UntagResource": {"method": "POST", "requestUri": "/_xray/UntagResource"},
|
||||
"UpdateGroup": {"method": "POST", "requestUri": "/_xray/UpdateGroup"},
|
||||
"UpdateIndexingRule": {"method": "POST", "requestUri": "/_xray/UpdateIndexingRule"},
|
||||
"UpdateSamplingRule": {"method": "POST", "requestUri": "/_xray/UpdateSamplingRule"},
|
||||
"UpdateTraceSegmentDestination": {"method": "POST", "requestUri": "/_xray/UpdateTraceSegmentDestination"}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+19
-1
@@ -57,7 +57,8 @@ class PartitionCrossServiceSmokeIntegrationTest {
|
||||
"paymentcryptography", "pipes", "quicksight", "ram", "rds", "redshift", "redshiftserverless",
|
||||
"resourceexplorer2", "resourcegroups", "route53resolver",
|
||||
"s3tables", "s3vectors", "sagemaker", "scheduler", "secretsmanager", "servicequotas", "ses", "signer", "sns", "sqs",
|
||||
"stepfunctions", "timestreaminfluxdb", "transfer", "verifiedpermissions", "wafv2");
|
||||
"stepfunctions", "timestreaminfluxdb", "transfer", "verifiedpermissions", "wafv2",
|
||||
"xray");
|
||||
|
||||
private static final String JSON_1_0 = "application/x-amz-json-1.0";
|
||||
private static final String JSON_1_1 = "application/x-amz-json-1.1";
|
||||
@@ -100,6 +101,23 @@ class PartitionCrossServiceSmokeIntegrationTest {
|
||||
PartitionMatrix.assertArnIn(partitionCase, arn);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource(PartitionMatrix.NON_COMMERCIAL_CASES)
|
||||
void xraySamplingRuleArn(PartitionCase partitionCase) {
|
||||
String region = offered(partitionCase, "xray");
|
||||
String name = unique("smoke-rule", partitionCase);
|
||||
String body = "{\"SamplingRule\":{\"RuleName\":\"" + name + "\",\"Priority\":10,"
|
||||
+ "\"FixedRate\":0.1,\"ReservoirSize\":1,\"ServiceName\":\"*\","
|
||||
+ "\"ServiceType\":\"*\",\"Host\":\"*\",\"HTTPMethod\":\"*\","
|
||||
+ "\"URLPath\":\"*\",\"Version\":1}}";
|
||||
String arn = signed(region, "xray").contentType(JSON).body(body)
|
||||
.when().post("/CreateSamplingRule")
|
||||
.then().statusCode(200).extract().path("SamplingRuleRecord.SamplingRule.RuleARN");
|
||||
cleanup.register(() -> signed(region, "xray").contentType(JSON)
|
||||
.body("{\"RuleName\":\"" + name + "\"}").when().post("/DeleteSamplingRule"));
|
||||
PartitionMatrix.assertArnIn(partitionCase, arn);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource(PartitionMatrix.NON_COMMERCIAL_CASES)
|
||||
void paymentCryptographyKeyArn(PartitionCase partitionCase) {
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
package io.floci.aws.services.xray;
|
||||
|
||||
import io.floci.aws.core.common.AwsException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class XrayFilterExpressionTest {
|
||||
|
||||
private static XrayFilterExpression.Facts failingCall() {
|
||||
return new XrayFilterExpression.Facts(Set.of("orders-api", "dynamodb"), true, false, false,
|
||||
2.5, 500, Map.of("env", "local", "attempt", "2"));
|
||||
}
|
||||
|
||||
private static XrayFilterExpression.Facts healthCall() {
|
||||
return new XrayFilterExpression.Facts(Set.of("orders-api"), false, false, false,
|
||||
0.25, 200, Map.of("env", "local"));
|
||||
}
|
||||
|
||||
private static Predicate<XrayFilterExpression.Facts> compile(String expression) {
|
||||
return XrayFilterExpression.compile(expression);
|
||||
}
|
||||
|
||||
@Test
|
||||
void anEmptyExpressionMatchesEverything() {
|
||||
assertTrue(compile(null).test(failingCall()));
|
||||
assertTrue(compile(" ").test(healthCall()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aServicePredicateMatchesATraceThatCalledIt() {
|
||||
Predicate<XrayFilterExpression.Facts> filter = compile("service(\"dynamodb\")");
|
||||
|
||||
assertTrue(filter.test(failingCall()));
|
||||
assertFalse(filter.test(healthCall()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void flagsMatchTheTraceOutcome() {
|
||||
assertTrue(compile("error").test(failingCall()));
|
||||
assertFalse(compile("error").test(healthCall()));
|
||||
assertTrue(compile("fault").test(new XrayFilterExpression.Facts(Set.of("a"), false, true,
|
||||
false, 1.0, null, Map.of())));
|
||||
assertTrue(compile("throttle").test(new XrayFilterExpression.Facts(Set.of("a"), false,
|
||||
false, true, 1.0, null, Map.of())));
|
||||
}
|
||||
|
||||
@Test
|
||||
void numericComparisonsWorkForKeyFields() {
|
||||
assertTrue(compile("duration > 1").test(failingCall()));
|
||||
assertFalse(compile("duration > 1").test(healthCall()));
|
||||
assertTrue(compile("http.status = 500").test(failingCall()));
|
||||
assertTrue(compile("http.status >= 400").test(failingCall()));
|
||||
assertFalse(compile("http.status <= 400").test(failingCall()));
|
||||
assertTrue(compile("responsetime < 500").test(healthCall()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void annotationsCompareAsStringsAndNumbers() {
|
||||
assertTrue(compile("annotation.env = \"local\"").test(healthCall()));
|
||||
assertFalse(compile("annotation.env = \"prod\"").test(healthCall()));
|
||||
assertTrue(compile("annotation.attempt = 2").test(failingCall()));
|
||||
assertFalse(compile("annotation.missing = \"x\"").test(healthCall()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void andOrNotAndParenthesesCombine() {
|
||||
assertTrue(compile("service(\"dynamodb\") AND error").test(failingCall()));
|
||||
assertFalse(compile("service(\"dynamodb\") AND NOT error").test(failingCall()));
|
||||
assertTrue(compile("service(\"dynamodb\") OR http.status = 200").test(healthCall()));
|
||||
assertTrue(compile("(service(\"dynamodb\") OR service(\"kafka\")) AND error")
|
||||
.test(failingCall()));
|
||||
assertFalse(compile("NOT (service(\"dynamodb\") OR service(\"kafka\"))").test(failingCall()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aLoneExclamationIsRefusedInsteadOfSpinning() {
|
||||
assertTimeoutPreemptively(Duration.ofSeconds(2), () -> {
|
||||
AwsException refused = assertThrows(AwsException.class, () -> compile("hasError AND !"));
|
||||
assertEquals("InvalidRequestException", refused.getErrorCode());
|
||||
|
||||
AwsException alone = assertThrows(AwsException.class, () -> compile("!"));
|
||||
assertEquals("InvalidRequestException", alone.getErrorCode());
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void responsetimeIsComparedInSecondsLikeDuration() {
|
||||
assertTrue(compile("responsetime < 0.5").test(healthCall()));
|
||||
assertFalse(compile("responsetime > 1").test(healthCall()));
|
||||
assertTrue(compile("responsetime > 1").test(failingCall()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void theAwsKeywordsMatchTheTraceOutcome() {
|
||||
assertTrue(compile("error").test(failingCall()));
|
||||
assertFalse(compile("error").test(healthCall()));
|
||||
assertTrue(compile("ok").test(healthCall()));
|
||||
assertFalse(compile("ok").test(failingCall()));
|
||||
assertTrue(compile("fault").test(new XrayFilterExpression.Facts(Set.of("a"), false, true,
|
||||
false, 1.0, null, Map.of())));
|
||||
assertTrue(compile("throttle").test(new XrayFilterExpression.Facts(Set.of("a"), false,
|
||||
false, true, 1.0, null, Map.of())));
|
||||
}
|
||||
|
||||
@Test
|
||||
void anExclamationNegatesThePredicateAfterIt() {
|
||||
assertTrue(compile("!error").test(healthCall()));
|
||||
assertFalse(compile("!error").test(failingCall()));
|
||||
assertTrue(compile("!(service(\"dynamodb\") AND error)").test(healthCall()));
|
||||
assertFalse(compile("service(\"dynamodb\") AND !ok").test(healthCall().services().isEmpty()
|
||||
? healthCall() : new XrayFilterExpression.Facts(Set.of("dynamodb"), false, false,
|
||||
false, 0.25, 200, Map.of())));
|
||||
}
|
||||
|
||||
@Test
|
||||
void anUnsupportedPredicateIsRefusedInsteadOfIgnored() {
|
||||
AwsException thrown = assertThrows(AwsException.class, () -> compile("edge(\"a\", \"b\")"));
|
||||
|
||||
assertEquals("InvalidRequestException", thrown.getErrorCode());
|
||||
assertTrue(thrown.getMessage().contains("not supported"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void anUnbalancedExpressionIsRefused() {
|
||||
AwsException thrown = assertThrows(AwsException.class,
|
||||
() -> compile("(service(\"a\") AND error"));
|
||||
|
||||
assertEquals("InvalidRequestException", thrown.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aTrailingTokenIsRefused() {
|
||||
AwsException thrown = assertThrows(AwsException.class, () -> compile("hasError junk"));
|
||||
|
||||
assertEquals("InvalidRequestException", thrown.getErrorCode());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package io.floci.aws.services.xray;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class XrayGraphTest {
|
||||
|
||||
private static final String TRACE_ID = "1-5f3b8a0e-3c9d4d8e9b7a2c1d4e5f6a7b";
|
||||
|
||||
private static XraySegments.Node node(String id, String parentId, String name, boolean fault,
|
||||
boolean error, boolean throttle) {
|
||||
return new XraySegments.Node(TRACE_ID, id, parentId, name, 1.0, 1.5, fault, error, throttle,
|
||||
null, null, null, false, Map.of());
|
||||
}
|
||||
|
||||
private static XrayGraph.Node single(XraySegments.Node node) {
|
||||
List<XrayGraph.Node> nodes = XrayGraph.build(List.of(List.of(node)));
|
||||
assertEquals(1, nodes.size());
|
||||
return nodes.get(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void aSegmentThatIsBothErrorAndThrottledIsAThrottleAndCountsOnce() {
|
||||
XrayGraph.Node node = single(node("0f1e2d3c4b5a6978", "", "orders-api", false, true, true));
|
||||
|
||||
assertEquals(0, node.okCount());
|
||||
assertEquals(0, node.errorCount(), "a 429 that also carries the error flag is a throttle");
|
||||
assertEquals(1, node.throttleCount());
|
||||
assertEquals(0, node.faultCount());
|
||||
assertEquals(1, node.totalCount(), "a subsegment is one call, however many flags it carries");
|
||||
}
|
||||
|
||||
@Test
|
||||
void aThrottleOnlySegmentIsCountedInTheTotalAndNotAsOk() {
|
||||
XrayGraph.Node node = single(node("0f1e2d3c4b5a6978", "", "orders-api", false, false, true));
|
||||
|
||||
assertEquals(0, node.okCount());
|
||||
assertEquals(1, node.throttleCount());
|
||||
assertEquals(1, node.totalCount(), "a throttled call is not an ok call and must still be counted");
|
||||
assertEquals("throttle", node.state());
|
||||
}
|
||||
|
||||
@Test
|
||||
void anEdgeCountsItsCallsTheSameWayItsNodeDoes() {
|
||||
XraySegments.Node root = node("0f1e2d3c4b5a6978", "", "orders-api", false, false, false);
|
||||
XraySegments.Node call = node("8a7b6c5d4e3f2019", "0f1e2d3c4b5a6978", "payments", false, true, true);
|
||||
|
||||
List<XrayGraph.Node> nodes = XrayGraph.build(List.of(List.of(root, call)));
|
||||
|
||||
XrayGraph.Node orders = nodes.stream().filter(node -> node.name().equals("orders-api")).findFirst()
|
||||
.orElseThrow();
|
||||
XrayGraph.Node payments = nodes.stream().filter(node -> node.name().equals("payments")).findFirst()
|
||||
.orElseThrow();
|
||||
assertEquals(1, orders.edges().size());
|
||||
XrayGraph.Edge edge = orders.edges().get(0);
|
||||
assertEquals(edge.referenceId(), payments.referenceId());
|
||||
assertEquals(0, edge.errorCount());
|
||||
assertEquals(1, edge.throttleCount());
|
||||
assertEquals(1, edge.totalCount());
|
||||
assertEquals(0, payments.errorCount());
|
||||
assertEquals(1, payments.throttleCount());
|
||||
assertEquals(1, payments.totalCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aFaultKeepsItsOwnColumnAndTheStateReportsItFirst() {
|
||||
XrayGraph.Node node = single(node("0f1e2d3c4b5a6978", "", "orders-api", true, true, true));
|
||||
|
||||
assertEquals(1, node.faultCount());
|
||||
assertEquals(0, node.errorCount());
|
||||
assertEquals(0, node.throttleCount(), "one call is one column, and fault wins");
|
||||
assertEquals(1, node.totalCount());
|
||||
assertEquals("fault", node.state());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aSegmentWithNoFlagIsTheOnlyOneCountedAsOk() {
|
||||
XrayGraph.Node node = single(node("0f1e2d3c4b5a6978", "", "orders-api", false, false, false));
|
||||
|
||||
assertEquals(1, node.okCount());
|
||||
assertEquals(1, node.totalCount());
|
||||
assertEquals("ok", node.state());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package io.floci.aws.services.xray;
|
||||
|
||||
import io.floci.aws.testing.EnforcementFixtures;
|
||||
import io.floci.aws.testing.IamEnforcementProfile;
|
||||
import io.floci.aws.testing.PartitionCleanup;
|
||||
import io.quarkus.test.common.http.TestHTTPResource;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.junit.TestProfile;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.junit.jupiter.api.extension.AfterAllCallback;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import java.net.URI;
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
import static io.floci.aws.testing.EnforcementFixtures.auth;
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
/**
|
||||
* X-Ray routes are rewritten onto an internal prefix before the IAM filter runs, so this proves the
|
||||
* rewrite does not take a request out of IAM's reach: a key with no policy is refused on the same
|
||||
* paths a key with {@code xray:*} is allowed through.
|
||||
*/
|
||||
@QuarkusTest
|
||||
@TestProfile(IamEnforcementProfile.class)
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
class XrayIamEnforcementIntegrationTest {
|
||||
|
||||
private static final String ACCOUNT = "741686000030";
|
||||
private static final String TRACE_ID = "1-5f3b8a0e-3c9d4d8e9b7a2c1d4e5f6a7b";
|
||||
|
||||
@TestHTTPResource("/")
|
||||
URI baseUri;
|
||||
|
||||
private final PartitionCleanup cleanup = new PartitionCleanup();
|
||||
|
||||
@RegisterExtension
|
||||
final AfterAllCallback classCleanup = cleanup::afterEach;
|
||||
|
||||
private String deniedKey;
|
||||
private String allowedKey;
|
||||
|
||||
@BeforeAll
|
||||
void createKeys() {
|
||||
deniedKey = userWithPolicy(null);
|
||||
allowedKey = userWithPolicy("""
|
||||
{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"xray:*","Resource":"*"}]}
|
||||
""");
|
||||
}
|
||||
|
||||
@Test
|
||||
void aKeyWithoutAPolicyCannotWriteSegments() {
|
||||
given().header("Authorization", auth(deniedKey, "xray"))
|
||||
.contentType("application/json").body(segmentBody())
|
||||
.when().post("/TraceSegments")
|
||||
.then().statusCode(403);
|
||||
}
|
||||
|
||||
@Test
|
||||
void aKeyWithoutAPolicyCannotReadSamplingRules() {
|
||||
given().header("Authorization", auth(deniedKey, "xray"))
|
||||
.contentType("application/json").body("{}")
|
||||
.when().post("/GetSamplingRules")
|
||||
.then().statusCode(403);
|
||||
}
|
||||
|
||||
@Test
|
||||
void aKeyWithXrayAllowWritesAndReads() {
|
||||
given().header("Authorization", auth(allowedKey, "xray"))
|
||||
.contentType("application/json").body(segmentBody())
|
||||
.when().post("/TraceSegments")
|
||||
.then().statusCode(200).body("UnprocessedTraceSegments.size()", equalTo(0));
|
||||
|
||||
given().header("Authorization", auth(allowedKey, "xray"))
|
||||
.contentType("application/json").body("{}")
|
||||
.when().post("/GetSamplingRules")
|
||||
.then().statusCode(200);
|
||||
}
|
||||
|
||||
private static String segmentBody() {
|
||||
double now = Instant.now().getEpochSecond();
|
||||
String document = "{\"trace_id\":\"" + TRACE_ID + "\",\"id\":\"0f1e2d3c4b5a6978\","
|
||||
+ "\"name\":\"iam-probe\",\"start_time\":" + now + ",\"end_time\":" + (now + 1) + "}";
|
||||
return "{\"TraceSegmentDocuments\":[\"" + document.replace("\"", "\\\"") + "\"]}";
|
||||
}
|
||||
|
||||
private String userWithPolicy(String policy) {
|
||||
String user = "xray-iam-" + UUID.randomUUID();
|
||||
String key = EnforcementFixtures.createUser(cleanup, baseUri.getPort(), auth(ACCOUNT, "iam"), user)
|
||||
.accessKeyId();
|
||||
if (policy != null) {
|
||||
EnforcementFixtures.putUserPolicy(baseUri.getPort(), auth(ACCOUNT, "iam"), user, "xray", policy);
|
||||
}
|
||||
return key;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,290 @@
|
||||
package io.floci.aws.services.xray;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.hamcrest.Matchers.hasItems;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
|
||||
@QuarkusTest
|
||||
class XrayIntegrationTest {
|
||||
|
||||
private static final String ACCOUNT_ID = "000000000000";
|
||||
private static final String REGION = "us-east-1";
|
||||
private static final String TRACE_ID = "1-5f3b8a0e-3c9d4d8e9b7a2c1d4e5f6a7b";
|
||||
/** A trace of its own, so the summaries test does not inherit another test's documents. */
|
||||
private static final String GRAPH_TRACE_ID = "1-0f0e0d0c-1a2b3c4d5e6f708192a3b4c5";
|
||||
/** Inside the retention window: a segment stamped in 1970 is treated as expired. */
|
||||
private static final double NOW = Instant.now().getEpochSecond();
|
||||
private static final ObjectMapper MAPPER = new ObjectMapper();
|
||||
|
||||
/** One segment document, as an X-Ray SDK writes it. */
|
||||
private static String segment(String id, String name) {
|
||||
return String.format(Locale.ROOT,
|
||||
"{\"trace_id\":\"%s\",\"id\":\"%s\",\"name\":\"%s\","
|
||||
+ "\"start_time\":%.1f,\"end_time\":%.1f,\"type\":\"subsegment\"}",
|
||||
TRACE_ID, id, name, NOW, NOW + 1.5);
|
||||
}
|
||||
|
||||
private static String bodyOf(Object value) throws Exception {
|
||||
return MAPPER.writeValueAsString(value);
|
||||
}
|
||||
|
||||
@Test
|
||||
void aTracePutThroughTheWireComesBackAsItWasSent() throws Exception {
|
||||
String document = segment("0f1e2d3c4b5a6978", "orders-api");
|
||||
|
||||
xray().body(bodyOf(Map.of("TraceSegmentDocuments", List.of(document))))
|
||||
.when()
|
||||
.post("/TraceSegments")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("UnprocessedTraceSegments", hasSize(0));
|
||||
|
||||
xray().body(bodyOf(Map.of("TraceIds", List.of(TRACE_ID))))
|
||||
.when()
|
||||
.post("/Traces")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("Traces", hasSize(1))
|
||||
.body("Traces[0].Id", equalTo(TRACE_ID))
|
||||
.body("Traces[0].Duration", equalTo(1.5f))
|
||||
.body("Traces[0].Segments", hasSize(1))
|
||||
.body("Traces[0].Segments[0].Id", equalTo("0f1e2d3c4b5a6978"))
|
||||
.body("Traces[0].Segments[0].Document", equalTo(document));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aRejectedSegmentIsReportedWithItsReason() throws Exception {
|
||||
String broken = "{\"trace_id\":\"nope\",\"id\":\"0f1e2d3c4b5a6978\",\"name\":\"orders-api\","
|
||||
+ "\"start_time\":1.0,\"end_time\":2.0}";
|
||||
|
||||
xray().body(bodyOf(Map.of("TraceSegmentDocuments", List.of(broken))))
|
||||
.when()
|
||||
.post("/TraceSegments")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("UnprocessedTraceSegments", hasSize(1))
|
||||
.body("UnprocessedTraceSegments[0].ErrorCode", equalTo("InvalidSegment"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void anEmptyDocumentListIsRefused() throws Exception {
|
||||
xray().body(bodyOf(Map.of("TraceSegmentDocuments", List.of())))
|
||||
.when()
|
||||
.post("/TraceSegments")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("InvalidRequestException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aTraceIsScopedToTheRegionThatWroteIt() throws Exception {
|
||||
xray(REGION).body(bodyOf(Map.of("TraceSegmentDocuments",
|
||||
List.of(segment("0f1e2d3c4b5a6978", "orders-api")))))
|
||||
.when()
|
||||
.post("/TraceSegments")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
xray("eu-west-1").body(bodyOf(Map.of("TraceIds", List.of(TRACE_ID))))
|
||||
.when()
|
||||
.post("/Traces")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("Traces", hasSize(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aRequestForAnotherServiceIsNotClaimedByXray() throws Exception {
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", "AWS4-HMAC-SHA256 Credential=" + ACCOUNT_ID
|
||||
+ "/20260101/" + REGION + "/s3/aws4_request")
|
||||
.body(bodyOf(Map.of("TraceSegmentDocuments",
|
||||
List.of(segment("0f1e2d3c4b5a6978", "s3-claim")))))
|
||||
.when()
|
||||
.post("/TraceSegments");
|
||||
|
||||
xray().body(bodyOf(Map.of("TraceIds", List.of(TRACE_ID))))
|
||||
.when()
|
||||
.post("/Traces")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("Traces", hasSize(0));
|
||||
}
|
||||
|
||||
/** A root segment that called a second service, so the graph has an edge to report. */
|
||||
private static String segmentWithACall(String traceId) {
|
||||
return String.format(Locale.ROOT,
|
||||
"{\"trace_id\":\"%s\",\"id\":\"0f1e2d3c4b5a6978\",\"name\":\"orders-api\","
|
||||
+ "\"start_time\":%.1f,\"end_time\":%.1f,"
|
||||
+ "\"http\":{\"request\":{\"method\":\"GET\",\"url\":\"http://orders/\"},"
|
||||
+ "\"response\":{\"status\":200}},"
|
||||
+ "\"annotations\":{\"env\":\"local\",\"retries\":3,\"sampled\":true},"
|
||||
+ "\"subsegments\":[{\"id\":\"8a7b6c5d4e3f2019\",\"name\":\"dynamodb\","
|
||||
+ "\"start_time\":%.1f,\"end_time\":%.1f}]}",
|
||||
traceId, NOW, NOW + 1.5, NOW + 0.2, NOW + 0.9);
|
||||
}
|
||||
|
||||
@Test
|
||||
void summariesAndTheServiceGraphComeBackThroughTheWire() throws Exception {
|
||||
xray().body(bodyOf(Map.of("TraceSegmentDocuments", List.of(segmentWithACall(GRAPH_TRACE_ID)))))
|
||||
.when()
|
||||
.post("/TraceSegments")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
String window = bodyOf(Map.of("StartTime", NOW - 60, "EndTime", NOW + 60));
|
||||
String onlyTheGraphTrace = bodyOf(Map.of("StartTime", NOW - 60, "EndTime", NOW + 60,
|
||||
"FilterExpression", "service(\"dynamodb\")"));
|
||||
|
||||
xray().body(onlyTheGraphTrace)
|
||||
.when()
|
||||
.post("/TraceSummaries")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("TraceSummaries", hasSize(1))
|
||||
.body("TraceSummaries[0].Id", equalTo(GRAPH_TRACE_ID))
|
||||
.body("TraceSummaries[0].Duration", equalTo(1.5f))
|
||||
.body("TraceSummaries[0].HasError", equalTo(false))
|
||||
.body("TraceSummaries[0].Http.HttpStatus", equalTo(200))
|
||||
.body("TraceSummaries[0].EntryPoint.Name", equalTo("orders-api"))
|
||||
.body("TraceSummaries[0].ServiceIds", hasSize(2))
|
||||
.body("TraceSummaries[0].Annotations.env[0].AnnotationValue.StringValue",
|
||||
equalTo("local"))
|
||||
.body("TraceSummaries[0].Annotations.retries[0].AnnotationValue.NumberValue",
|
||||
equalTo(3.0f))
|
||||
.body("TraceSummaries[0].Annotations.sampled[0].AnnotationValue.BooleanValue",
|
||||
equalTo(true))
|
||||
.body("TracesProcessedCount", greaterThanOrEqualTo(1));
|
||||
|
||||
xray().body(window)
|
||||
.when()
|
||||
.post("/ServiceGraph")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("Services", hasSize(2))
|
||||
.body("Services[0].Name", equalTo("orders-api"))
|
||||
.body("Services[0].Type", equalTo("client"))
|
||||
.body("Services[0].State", equalTo("ok"))
|
||||
.body("Services[0].Edges", hasSize(1))
|
||||
.body("Services[0].SummaryStatistics.OkCount", greaterThanOrEqualTo(1))
|
||||
.body("Services[0].SummaryStatistics.TotalCount", greaterThanOrEqualTo(1))
|
||||
.body("Services[0].DurationHistogram", hasSize(9));
|
||||
|
||||
xray().body(bodyOf(Map.of("TraceIds", List.of(GRAPH_TRACE_ID))))
|
||||
.when()
|
||||
.post("/TraceGraph")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("Services", hasSize(2));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aThrottledCallIsReportedAsAThrottleAndCountedOnceInTheErrorTotal() throws Exception {
|
||||
String traceId = "1-9a8b7c6d-1e2f3a4b5c6d7e8f9a0b1c2d";
|
||||
String document = String.format(Locale.ROOT,
|
||||
"{\"trace_id\":\"%s\",\"id\":\"0f1e2d3c4b5a6978\",\"name\":\"orders-api\","
|
||||
+ "\"start_time\":%.1f,\"end_time\":%.1f,\"error\":true,\"throttle\":true}",
|
||||
traceId, NOW, NOW + 0.4);
|
||||
xray().body(bodyOf(Map.of("TraceSegmentDocuments", List.of(document))))
|
||||
.when()
|
||||
.post("/TraceSegments")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
xray().body(bodyOf(Map.of("StartTime", NOW - 60, "EndTime", NOW + 60)))
|
||||
.when()
|
||||
.post("/ServiceGraph")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("Services.find { it.Name == 'orders-api' }.SummaryStatistics.ErrorStatistics.ThrottleCount",
|
||||
equalTo(1))
|
||||
.body("Services.find { it.Name == 'orders-api' }.SummaryStatistics.ErrorStatistics.OtherCount",
|
||||
equalTo(0))
|
||||
.body("Services.find { it.Name == 'orders-api' }.SummaryStatistics.ErrorStatistics.TotalCount",
|
||||
equalTo(1))
|
||||
// The graph aggregates per service name across the window, and other cases here
|
||||
// post traces for the same service, so the total is at least this one call.
|
||||
.body("Services.find { it.Name == 'orders-api' }.SummaryStatistics.TotalCount",
|
||||
greaterThanOrEqualTo(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
void anUnsupportedFilterIsRefusedThroughTheWire() throws Exception {
|
||||
String request = bodyOf(Map.of("StartTime", NOW - 60, "EndTime", NOW + 60,
|
||||
"FilterExpression", "edge(\"a\", \"b\")"));
|
||||
|
||||
xray().body(request)
|
||||
.when()
|
||||
.post("/TraceSummaries")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("InvalidRequestException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void samplingRulesTargetsAndTelemetryWorkThroughTheWire() throws Exception {
|
||||
xray().body(bodyOf(Map.of("SamplingRule", Map.of(
|
||||
"RuleName", "it-rule", "Priority", 5, "FixedRate", 0.5, "ReservoirSize", 4,
|
||||
"ServiceName", "*", "ServiceType", "*", "Host", "*",
|
||||
"HTTPMethod", "*", "URLPath", "*", "Version", 1))))
|
||||
.when()
|
||||
.post("/CreateSamplingRule")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("SamplingRuleRecord.SamplingRule.RuleName", equalTo("it-rule"))
|
||||
.body("SamplingRuleRecord.SamplingRule.RuleARN",
|
||||
equalTo("arn:aws:xray:us-east-1:000000000000:sampling-rule/it-rule"));
|
||||
|
||||
xray().body("{}")
|
||||
.when()
|
||||
.post("/GetSamplingRules")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("SamplingRuleRecords.SamplingRule.RuleName", hasItems("Default", "it-rule"));
|
||||
|
||||
xray().body(bodyOf(Map.of("SamplingStatisticsDocuments", List.of(Map.of(
|
||||
"RuleName", "it-rule", "ClientID", "daemon-1",
|
||||
"Timestamp", NOW, "RequestCount", 10, "SampledCount", 1)))))
|
||||
.when()
|
||||
.post("/SamplingTargets")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("SamplingTargetDocuments", hasSize(1))
|
||||
.body("SamplingTargetDocuments[0].RuleName", equalTo("it-rule"))
|
||||
.body("SamplingTargetDocuments[0].ReservoirQuota", equalTo(4))
|
||||
.body("SamplingTargetDocuments[0].Interval", equalTo(10));
|
||||
|
||||
xray().body(bodyOf(Map.of("TelemetryRecords", List.of(Map.of(
|
||||
"Timestamp", NOW, "SegmentsReceivedCount", 2, "SegmentsSentCount", 2)),
|
||||
"Hostname", "it-host")))
|
||||
.when()
|
||||
.post("/TelemetryRecords")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
}
|
||||
|
||||
private static RequestSpecification xray() {
|
||||
return xray(REGION);
|
||||
}
|
||||
|
||||
private static RequestSpecification xray(String region) {
|
||||
String authorization = "AWS4-HMAC-SHA256 Credential=" + ACCOUNT_ID
|
||||
+ "/20260101/" + region + "/xray/aws4_request";
|
||||
return given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", authorization);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,448 @@
|
||||
package io.floci.aws.services.xray;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.floci.aws.core.common.AwsException;
|
||||
import io.floci.aws.core.storage.AccountAwareStorageBackend;
|
||||
import io.floci.aws.services.xray.model.SamplingRule;
|
||||
import io.floci.aws.services.xray.model.Trace;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class XrayServiceTest {
|
||||
|
||||
private static final String REGION = "us-east-1";
|
||||
private static final String TRACE_ID = "1-5f3b8a0e-3c9d4d8e9b7a2c1d4e5f6a7b";
|
||||
private static final String OTHER_TRACE_ID = "1-1a2b3c4d-5e6f7a8b9c0d1e2f3a4b5c6d";
|
||||
/** Inside the retention window: a segment stamped in 1970 is treated as expired. */
|
||||
private static final double NOW = Instant.now().getEpochSecond();
|
||||
/** A segment id is a 64 bit hex identifier, so the fixture cannot invent a readable one. */
|
||||
private static final String SEGMENT_ID = "0f1e2d3c4b5a6978";
|
||||
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
private XrayService service;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
service = new XrayService(AccountAwareStorageBackend.inMemory("000000000000"),
|
||||
AccountAwareStorageBackend.inMemory("000000000000"));
|
||||
}
|
||||
|
||||
private static String segment(String traceId, String id, String name, double start, double end) {
|
||||
return "{\"trace_id\":\"" + traceId + "\",\"id\":\"" + id + "\",\"name\":\"" + name
|
||||
+ "\",\"start_time\":" + start + ",\"end_time\":" + end + ",\"type\":\"subsegment\"}";
|
||||
}
|
||||
|
||||
@Test
|
||||
void segmentsOfOneTraceAreKeptTogetherAndReadBackVerbatim() {
|
||||
String root = segment(TRACE_ID, "0f1e2d3c4b5a6978", "orders-api", NOW, NOW + 1.5);
|
||||
String child = segment(TRACE_ID, "8a7b6c5d4e3f2019", "dynamodb", NOW + 0.2, NOW + 0.9);
|
||||
|
||||
List<XrayService.UnprocessedSegment> rejected = service.putTraceSegments(List.of(root, child), REGION);
|
||||
|
||||
assertTrue(rejected.isEmpty());
|
||||
XrayService.BatchGetResult result = service.batchGetTraces(List.of(TRACE_ID), REGION);
|
||||
assertEquals(1, result.traces().size());
|
||||
Trace trace = result.traces().get(0);
|
||||
assertEquals(List.of(root, child), trace.getDocuments());
|
||||
assertEquals(1.5, trace.getEndTime() - trace.getStartTime(), 0.0001);
|
||||
assertTrue(result.unprocessedIds().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aMalformedDocumentIsRejectedAloneAndTheRestIsStored() {
|
||||
String broken = "{\"trace_id\":\"not-a-trace\",\"id\":\"0f1e2d3c4b5a6978\",\"name\":\"x\","
|
||||
+ "\"start_time\":1.0,\"end_time\":2.0}";
|
||||
String good = segment(TRACE_ID, "0f1e2d3c4b5a6978", "orders-api", NOW, NOW + 1.0);
|
||||
|
||||
List<XrayService.UnprocessedSegment> rejected = service.putTraceSegments(List.of(broken, good), REGION);
|
||||
|
||||
assertEquals(1, rejected.size());
|
||||
assertEquals("InvalidSegment", rejected.get(0).errorCode());
|
||||
assertEquals(1, service.batchGetTraces(List.of(TRACE_ID), REGION).traces().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aDocumentThatIsNotJsonIsRejected() {
|
||||
List<XrayService.UnprocessedSegment> rejected =
|
||||
service.putTraceSegments(List.of("not json at all"), REGION);
|
||||
|
||||
assertEquals(1, rejected.size());
|
||||
assertEquals("InvalidSegment", rejected.get(0).errorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void anEndBeforeTheStartIsRejected() {
|
||||
String backwards = segment(TRACE_ID, "0f1e2d3c4b5a6978", "orders-api", 1001.0, 1000.0);
|
||||
|
||||
List<XrayService.UnprocessedSegment> rejected = service.putTraceSegments(List.of(backwards), REGION);
|
||||
|
||||
assertEquals(1, rejected.size());
|
||||
assertTrue(rejected.get(0).message().contains("end_time is before start_time"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aCallCarriesAtMostOneHundredSegments() {
|
||||
List<String> documents = new ArrayList<>();
|
||||
for (int i = 0; i < 101; i++) {
|
||||
documents.add(segment(TRACE_ID, "0f1e2d3c4b5a69" + String.format("%02d", i), "orders-api", NOW, NOW + 1.0));
|
||||
}
|
||||
|
||||
AwsException thrown = assertThrows(AwsException.class,
|
||||
() -> service.putTraceSegments(documents, REGION));
|
||||
|
||||
assertEquals("InvalidRequestException", thrown.getErrorCode());
|
||||
assertEquals(400, thrown.getHttpStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aBatchAsksForAtMostFiveTraces() {
|
||||
AwsException thrown = assertThrows(AwsException.class,
|
||||
() -> service.batchGetTraces(List.of("1", "2", "3", "4", "5", "6"), REGION));
|
||||
|
||||
assertEquals("InvalidRequestException", thrown.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void anUnknownTraceIdIsReportedUnprocessed() {
|
||||
service.putTraceSegments(List.of(segment(TRACE_ID, "0f1e2d3c4b5a6978", "orders-api", NOW, NOW + 1.0)), REGION);
|
||||
|
||||
XrayService.BatchGetResult result = service.batchGetTraces(List.of(TRACE_ID, OTHER_TRACE_ID), REGION);
|
||||
|
||||
assertEquals(1, result.traces().size());
|
||||
assertEquals(List.of(OTHER_TRACE_ID), result.unprocessedIds());
|
||||
}
|
||||
|
||||
@Test
|
||||
void tracesAreScopedToTheirRegion() {
|
||||
service.putTraceSegments(List.of(segment(TRACE_ID, "0f1e2d3c4b5a6978", "orders-api", NOW, NOW + 1.0)), REGION);
|
||||
|
||||
assertTrue(service.batchGetTraces(List.of(TRACE_ID), "eu-west-1").traces().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void clearForgetsEveryTrace() {
|
||||
service.putTraceSegments(List.of(segment(TRACE_ID, "0f1e2d3c4b5a6978", "orders-api", NOW, NOW + 1.0)), REGION);
|
||||
|
||||
service.clear();
|
||||
|
||||
assertTrue(service.traces(REGION).isEmpty());
|
||||
}
|
||||
|
||||
/** One trace whose root calls a different service, so the graph has an edge to find. */
|
||||
private static String traceWithACall(String traceId, double start, double duration,
|
||||
boolean error, int status) {
|
||||
return "{\"trace_id\":\"" + traceId + "\",\"id\":\"0f1e2d3c4b5a6978\","
|
||||
+ "\"name\":\"orders-api\",\"start_time\":" + start
|
||||
+ ",\"end_time\":" + (start + duration) + (error ? ",\"error\":true" : "")
|
||||
+ ",\"http\":{\"request\":{\"method\":\"GET\",\"url\":\"http://orders/\"},"
|
||||
+ "\"response\":{\"status\":" + status + "}},"
|
||||
+ "\"annotations\":{\"env\":\"local\"},"
|
||||
+ "\"subsegments\":[{\"id\":\"8a7b6c5d4e3f2019\",\"name\":\"dynamodb\","
|
||||
+ "\"start_time\":" + (start + 0.2) + ",\"end_time\":" + (start + 0.9) + "}]}";
|
||||
}
|
||||
|
||||
@Test
|
||||
void summariesReportTheTracesInsideTheWindow() {
|
||||
service.putTraceSegments(List.of(traceWithACall(TRACE_ID, NOW, 1.5, false, 200)), REGION);
|
||||
service.putTraceSegments(List.of(traceWithACall(OTHER_TRACE_ID, NOW + 500, 0.5, true, 500)),
|
||||
REGION);
|
||||
|
||||
XrayService.SummaryPage page = service.traceSummaries(NOW - 10, NOW + 10, null, null, null,
|
||||
REGION);
|
||||
|
||||
assertEquals(1, page.processedCount(), "only the trace inside the window is processed");
|
||||
assertEquals(1, page.items().size());
|
||||
XrayService.TraceSummary summary = page.items().get(0);
|
||||
assertEquals(TRACE_ID, summary.id());
|
||||
assertEquals(1.5, summary.duration(), 0.0001);
|
||||
assertEquals(Integer.valueOf(200), summary.httpStatus());
|
||||
assertEquals(List.of("orders-api", "dynamodb"), summary.services());
|
||||
assertEquals("orders-api", summary.entryPoint());
|
||||
assertEquals("local", summary.annotations().get("env"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aFilterNarrowsTheSummariesAndARefusedOneIsAnError() {
|
||||
service.putTraceSegments(List.of(traceWithACall(TRACE_ID, NOW, 1.5, false, 200)), REGION);
|
||||
service.putTraceSegments(List.of(traceWithACall(OTHER_TRACE_ID, NOW + 1, 0.5, true, 500)),
|
||||
REGION);
|
||||
|
||||
assertEquals(2, service.traceSummaries(NOW - 10, NOW + 30, null, null, null, REGION)
|
||||
.items().size());
|
||||
assertEquals(1, service.traceSummaries(NOW - 10, NOW + 30, "error", null, null, REGION)
|
||||
.items().size());
|
||||
assertEquals(1, service.traceSummaries(NOW - 10, NOW + 30, "service(\"dynamodb\") AND http.status = 200",
|
||||
null, null, REGION).items().size());
|
||||
|
||||
AwsException refused = assertThrows(AwsException.class, () -> service.traceSummaries(
|
||||
NOW - 10, NOW + 30, "sampling.stratum = 1", null, null, REGION));
|
||||
assertEquals("InvalidRequestException", refused.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aWindowThatEndsBeforeItStartsIsRefused() {
|
||||
AwsException thrown = assertThrows(AwsException.class,
|
||||
() -> service.traceSummaries(NOW, NOW - 1, null, null, null, REGION));
|
||||
|
||||
assertEquals("InvalidRequestException", thrown.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void theServiceGraphHasANodePerServiceAndAnEdgePerCall() {
|
||||
service.putTraceSegments(List.of(traceWithACall(TRACE_ID, NOW, 1.5, false, 200)), REGION);
|
||||
service.putTraceSegments(List.of(traceWithACall(OTHER_TRACE_ID, NOW + 1, 0.5, true, 500)),
|
||||
REGION);
|
||||
|
||||
List<XrayGraph.Node> nodes = service.serviceGraph(NOW - 10, NOW + 10, REGION);
|
||||
|
||||
assertEquals(2, nodes.size());
|
||||
XrayGraph.Node orders = nodes.get(0);
|
||||
assertEquals("orders-api", orders.name());
|
||||
assertEquals("client", orders.type());
|
||||
assertEquals(2, orders.totalCount());
|
||||
assertEquals(1, orders.edges().size());
|
||||
XrayGraph.Node dynamodb = nodes.get(1);
|
||||
assertEquals("dynamodb", dynamodb.name());
|
||||
assertEquals(orders.edges().get(0).referenceId(), dynamodb.referenceId());
|
||||
assertEquals(2, dynamodb.totalCount());
|
||||
assertTrue(orders.durationHistogram().size() > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void theTraceGraphAnswersTheNamedTracesOnly() {
|
||||
service.putTraceSegments(List.of(traceWithACall(TRACE_ID, NOW, 1.5, false, 200)), REGION);
|
||||
|
||||
List<XrayGraph.Node> nodes = service.traceGraph(List.of(TRACE_ID), REGION);
|
||||
|
||||
assertEquals(2, nodes.size());
|
||||
assertTrue(service.traceGraph(List.of(OTHER_TRACE_ID), REGION).isEmpty());
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static String rule(String name, int priority, double rate) {
|
||||
return "{\"SamplingRule\":{\"RuleName\":\"" + name + "\",\"Priority\":" + priority
|
||||
+ ",\"FixedRate\":" + rate + ",\"ReservoirSize\":5,\"ServiceName\":\"orders-api\","
|
||||
+ "\"ServiceType\":\"*\",\"Host\":\"*\",\"HTTPMethod\":\"*\","
|
||||
+ "\"URLPath\":\"*\",\"Version\":1}}";
|
||||
}
|
||||
|
||||
@Test
|
||||
void theDefaultRuleIsAlwaysServedFirstAndCannotBeDeleted() throws Exception {
|
||||
List<SamplingRule> rules = service.samplingRules(REGION);
|
||||
|
||||
assertEquals(1, rules.size());
|
||||
SamplingRule rule = rules.get(0);
|
||||
assertEquals("Default", rule.getRuleName());
|
||||
assertEquals(10000, rule.getPriority());
|
||||
assertEquals(0.05, rule.getFixedRate(), 0.0001);
|
||||
assertEquals(1, rule.getReservoirSize());
|
||||
assertEquals("arn:aws:xray:us-east-1:000000000000:sampling-rule/Default", rule.getRuleArn());
|
||||
|
||||
AwsException refused = assertThrows(AwsException.class, () -> service.deleteSamplingRule(
|
||||
objectMapper.readTree("{\"RuleName\":\"Default\"}"), REGION));
|
||||
assertEquals("InvalidRequestException", refused.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aRuleIsCreatedUpdatedListedAndDeleted() throws Exception {
|
||||
SamplingRule created = service.createSamplingRule(objectMapper.readTree(rule("orders", 1, 0.5)),
|
||||
REGION);
|
||||
|
||||
assertEquals("orders", created.getRuleName());
|
||||
assertEquals("arn:aws:xray:us-east-1:000000000000:sampling-rule/orders", created.getRuleArn());
|
||||
assertEquals(2, service.samplingRules(REGION).size());
|
||||
assertEquals("orders", service.samplingRules(REGION).get(0).getRuleName(), "priority orders the list");
|
||||
|
||||
SamplingRule updated = service.updateSamplingRule(objectMapper.readTree(
|
||||
"{\"SamplingRuleUpdate\":{\"RuleName\":\"orders\",\"FixedRate\":0.25,"
|
||||
+ "\"ReservoirSize\":9}}"), REGION);
|
||||
assertEquals(0.25, updated.getFixedRate(), 0.0001);
|
||||
assertEquals(9, updated.getReservoirSize());
|
||||
assertEquals(1, updated.getPriority(), "an update keeps the members it was not given");
|
||||
|
||||
SamplingRule deleted = service.deleteSamplingRule(
|
||||
objectMapper.readTree("{\"RuleARN\":\"" + created.getRuleArn() + "\"}"), REGION);
|
||||
assertEquals("orders", deleted.getRuleName());
|
||||
assertEquals(1, service.samplingRules(REGION).size());
|
||||
|
||||
AwsException missing = assertThrows(AwsException.class, () -> service.deleteSamplingRule(
|
||||
objectMapper.readTree("{\"RuleName\":\"orders\"}"), REGION));
|
||||
assertEquals("InvalidRequestException", missing.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aRegionTakesAtMostTwentyFiveRulesAndRejectsADuplicate() throws Exception {
|
||||
for (int i = 1; i <= 25; i++) {
|
||||
service.createSamplingRule(objectMapper.readTree(rule("rule-" + i, i, 0.1)), REGION);
|
||||
}
|
||||
|
||||
AwsException tooMany = assertThrows(AwsException.class,
|
||||
() -> service.createSamplingRule(objectMapper.readTree(rule("rule-26", 26, 0.1)), REGION));
|
||||
assertEquals("RuleLimitExceededException", tooMany.getErrorCode());
|
||||
|
||||
AwsException duplicate = assertThrows(AwsException.class,
|
||||
() -> service.createSamplingRule(objectMapper.readTree(rule("rule-1", 1, 0.1)), REGION));
|
||||
assertEquals("InvalidRequestException", duplicate.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void targetsAnswerTheRuleTheDaemonAskedForAndReportUnknownOnes() throws Exception {
|
||||
service.createSamplingRule(objectMapper.readTree(rule("orders", 1, 0.5)), REGION);
|
||||
|
||||
XrayService.Targets targets = service.samplingTargets(objectMapper.readTree(
|
||||
"{\"SamplingStatisticsDocuments\":["
|
||||
+ "{\"RuleName\":\"orders\",\"ClientID\":\"daemon-1\",\"Timestamp\":1.0,"
|
||||
+ "\"RequestCount\":10,\"SampledCount\":2},"
|
||||
+ "{\"RuleName\":\"ghost\",\"ClientID\":\"daemon-1\",\"Timestamp\":1.0,"
|
||||
+ "\"RequestCount\":1,\"SampledCount\":0}]}"), REGION);
|
||||
|
||||
assertEquals(1, targets.documents().size());
|
||||
XrayService.Target target = targets.documents().get(0);
|
||||
assertEquals("orders", target.ruleName());
|
||||
assertEquals(0.5, target.fixedRate(), 0.0001);
|
||||
assertEquals(Integer.valueOf(5), target.reservoirQuota());
|
||||
assertEquals(10, target.interval());
|
||||
assertEquals(1, targets.unprocessed().size());
|
||||
assertEquals("RuleNotFound", targets.unprocessed().get(0).errorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aRejectedUpdateLeavesTheRuleUntouched() throws Exception {
|
||||
service.createSamplingRule(objectMapper.readTree(rule("orders", 1, 0.5)), REGION);
|
||||
|
||||
// ReservoirSize is valid and FixedRate is not, so nothing may be applied.
|
||||
AwsException refused = assertThrows(AwsException.class, () -> service.updateSamplingRule(
|
||||
objectMapper.readTree("{\"SamplingRuleUpdate\":{\"RuleName\":\"orders\","
|
||||
+ "\"ReservoirSize\":9,\"FixedRate\":4.5}}"), REGION));
|
||||
assertEquals("InvalidRequestException", refused.getErrorCode());
|
||||
|
||||
SamplingRule unchanged = service.samplingRules(REGION).get(0);
|
||||
assertEquals("orders", unchanged.getRuleName());
|
||||
assertEquals(5, unchanged.getReservoirSize());
|
||||
assertEquals(0.5, unchanged.getFixedRate(), 0.0001);
|
||||
}
|
||||
|
||||
@Test
|
||||
void theDefaultRuleCannotBeUpdatedAndIsNeverStoredTwice() throws Exception {
|
||||
AwsException refused = assertThrows(AwsException.class, () -> service.updateSamplingRule(
|
||||
objectMapper.readTree("{\"SamplingRuleUpdate\":{\"RuleName\":\"Default\","
|
||||
+ "\"FixedRate\":0.9}}"), REGION));
|
||||
assertEquals("InvalidRequestException", refused.getErrorCode());
|
||||
|
||||
List<SamplingRule> rules = service.samplingRules(REGION);
|
||||
assertEquals(1, rules.size());
|
||||
assertEquals(0.05, rules.get(0).getFixedRate(), 0.0001);
|
||||
}
|
||||
|
||||
@Test
|
||||
void aSegmentStillInFlightIsAccepted() throws Exception {
|
||||
String open = "{\"trace_id\":\"" + TRACE_ID + "\",\"id\":\"0f1e2d3c4b5a6978\","
|
||||
+ "\"name\":\"orders-api\",\"start_time\":" + NOW + "}";
|
||||
|
||||
List<XrayService.UnprocessedSegment> rejected = service.putTraceSegments(List.of(open), REGION);
|
||||
|
||||
assertTrue(rejected.isEmpty());
|
||||
assertEquals(1, service.batchGetTraces(List.of(TRACE_ID), REGION).traces().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aRetriedSegmentReplacesTheStoredOne() {
|
||||
String document = segment(TRACE_ID, "0f1e2d3c4b5a6978", "orders-api", NOW, NOW + 1.0);
|
||||
|
||||
service.putTraceSegments(List.of(document, document), REGION);
|
||||
|
||||
Trace trace = service.batchGetTraces(List.of(TRACE_ID), REGION).traces().get(0);
|
||||
assertEquals(1, trace.getDocuments().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aThrottledCallIsCountedAsThrottledInTheGraph() {
|
||||
String throttled = "{\"trace_id\":\"" + TRACE_ID + "\",\"id\":\"0f1e2d3c4b5a6978\","
|
||||
+ "\"name\":\"orders-api\",\"start_time\":" + NOW + ",\"end_time\":" + (NOW + 1)
|
||||
+ ",\"throttle\":true}";
|
||||
service.putTraceSegments(List.of(throttled), REGION);
|
||||
|
||||
List<XrayGraph.Node> nodes = service.serviceGraph(NOW - 10, NOW + 10, REGION);
|
||||
|
||||
assertEquals(1, nodes.size());
|
||||
assertEquals("throttle", nodes.get(0).state());
|
||||
assertEquals(0, nodes.get(0).okCount());
|
||||
assertEquals(1, nodes.get(0).throttleCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
void storingASegmentSwapsTheDocumentListInsteadOfEditingTheOneReadersHold() {
|
||||
service.putTraceSegments(List.of(segment(TRACE_ID, SEGMENT_ID, "orders-api", NOW, NOW + 0.2)), REGION);
|
||||
List<String> held = service.batchGetTraces(List.of(TRACE_ID), REGION).traces().get(0).getDocuments();
|
||||
assertEquals(1, held.size());
|
||||
// A summary or a BatchGetTraces call walks this list while the daemon keeps posting
|
||||
// segments; if the writer edited it in place that walk would throw and the held view
|
||||
// would change under it.
|
||||
assertDoesNotThrow(() -> held.forEach(document -> document.length()));
|
||||
|
||||
service.putTraceSegments(List.of(segment(TRACE_ID, SEGMENT_ID, "orders-api", NOW, NOW + 2.4)), REGION);
|
||||
|
||||
assertEquals(1, held.size(), "the list already handed out keeps what it had");
|
||||
List<String> current = service.batchGetTraces(List.of(TRACE_ID), REGION).traces().get(0).getDocuments();
|
||||
assertEquals(1, current.size());
|
||||
assertNotSame(held, current, "a write publishes a new list, it does not edit the old one");
|
||||
assertEquals(current, service.batchGetTraces(List.of(TRACE_ID), REGION).traces().get(0).getDocuments());
|
||||
}
|
||||
|
||||
@Test
|
||||
void racingCreatesOfOneRuleLeaveExactlyOne() throws Exception {
|
||||
int racers = 8;
|
||||
ExecutorService pool = Executors.newFixedThreadPool(racers);
|
||||
CountDownLatch start = new CountDownLatch(1);
|
||||
List<Future<Boolean>> results = new ArrayList<>();
|
||||
try {
|
||||
for (int i = 0; i < racers; i++) {
|
||||
results.add(pool.submit(() -> {
|
||||
start.await();
|
||||
try {
|
||||
service.createSamplingRule(objectMapper.readTree(rule("race", 1, 0.1)), REGION);
|
||||
return true;
|
||||
} catch (AwsException expected) {
|
||||
return false;
|
||||
}
|
||||
}));
|
||||
}
|
||||
start.countDown();
|
||||
long created = 0;
|
||||
for (Future<Boolean> result : results) {
|
||||
created += result.get(10, TimeUnit.SECONDS) ? 1 : 0;
|
||||
}
|
||||
assertEquals(1, created);
|
||||
} finally {
|
||||
pool.shutdownNow();
|
||||
}
|
||||
assertEquals(2, service.samplingRules(REGION).size(), "the rule and the Default one");
|
||||
}
|
||||
|
||||
@Test
|
||||
void telemetryRecordsAreAccepted() throws Exception {
|
||||
int accepted = service.putTelemetryRecords(objectMapper.readTree(
|
||||
"{\"TelemetryRecords\":[{\"Timestamp\":1.0,\"SegmentsReceivedCount\":3,"
|
||||
+ "\"SegmentsSentCount\":3}],\"Hostname\":\"local\"}"), REGION);
|
||||
|
||||
assertEquals(1, accepted);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -562,6 +562,8 @@ floci:
|
||||
enabled: true
|
||||
signer:
|
||||
enabled: true
|
||||
xray:
|
||||
enabled: true
|
||||
cognitoidentity:
|
||||
enabled: true
|
||||
globalaccelerator:
|
||||
|
||||
@@ -168,7 +168,7 @@ NAMESPACES = ("access-analyzer", "acm", "application-autoscaling", "athena", "bc
|
||||
"cognito-idp", "controltower", "cur", "datasync", "ec2", "ecr", "elasticloadbalancing", "elasticmapreduce", "es", "events",
|
||||
"firehose", "globalaccelerator", "inspector2", "kinesisanalytics", "macie2", "payment-cryptography",
|
||||
"quicksight", "redshift", "redshift-data", "rekognition", "servicediscovery", "servicequotas", "sso",
|
||||
"states", "textract", "timestream-influxdb", "translate", "signer")
|
||||
"states", "textract", "timestream-influxdb", "translate", "signer", "xray")
|
||||
|
||||
# SDK clients the reference lists for a namespace's operations whose requests Floci does not serve, and why: their
|
||||
# members are not read.
|
||||
|
||||
@@ -113,7 +113,7 @@ NAMESPACES = (
|
||||
"payment-cryptography", "pipes", "rds", "redshift", "redshift-serverless", "rekognition", "resource-groups",
|
||||
"route53resolver", "sagemaker", "scheduler", "secretsmanager", "servicediscovery", "ses", "signer", "sns", "sqs",
|
||||
"ssm", "sso", "states", "sts", "swf", "textract", "timestream-influxdb", "transcribe", "transfer", "translate",
|
||||
"wafv2",
|
||||
"wafv2", "xray",
|
||||
)
|
||||
|
||||
_NO_ROUTES = "REST routes no rule maps yet"
|
||||
@@ -175,6 +175,8 @@ NOT_READ = {
|
||||
"rds:DeleteDBCluster": NO_TAGS,
|
||||
"rds:DeleteDBInstance": NO_TAGS,
|
||||
"rds:DeleteTenantDatabase": NO_TAGS,
|
||||
"network-firewall:CreateFirewallPolicyV2": NO_TAGS,
|
||||
"events:StartReplay": NO_TAGS,
|
||||
"rds:StopDBInstance": NO_TAGS,
|
||||
"sagemaker:CreateClusterExtension": NOT_IN_BOTOCORE,
|
||||
"ssm:StartExecutionPreview": NO_TAGS,
|
||||
|
||||
@@ -73,6 +73,7 @@ MODELS: dict[str, str] = {
|
||||
"s3control": "s3",
|
||||
"scheduler": "scheduler",
|
||||
"signer": "signer",
|
||||
"xray": "xray",
|
||||
}
|
||||
|
||||
# The models whose routes are rewritten onto an internal prefix, and the prefix they are rewritten
|
||||
@@ -87,9 +88,11 @@ INTERNAL_ROUTES: dict[str, tuple[str, bool]] = {
|
||||
# filter owns, so its routes are vendored as the rewritten path: the action and the request's
|
||||
# resource labels both resolve from it.
|
||||
"signer": ("/_signer", False),
|
||||
# X-Ray's routes collide with S3's path-style ones too, for the same reason and with the same
|
||||
# fix: the vendored route is the path its filter rewrites the request onto.
|
||||
"xray": ("/_xray", False),
|
||||
}
|
||||
|
||||
|
||||
# Operations a model does not serve itself, so their path is not rewritten onto its internal prefix.
|
||||
# The shared tags controller serves /tags/{resourceArn} for every service that is a TagHandler, and
|
||||
# the service's route filter leaves that path alone; prefixing it here would advertise a route no
|
||||
|
||||
@@ -212,6 +212,10 @@ services:
|
||||
- TagResourceByBody
|
||||
- TagResourcePut
|
||||
- UntagResourceByQuery
|
||||
- service: xray
|
||||
doc: docs/services/xray.md
|
||||
sources:
|
||||
- { path: services/xray/XrayController.java, mode: rest }
|
||||
- service: connect
|
||||
doc: docs/services/connect.md
|
||||
sources:
|
||||
|
||||
Reference in new issue
Block a user