Tracking Selectors

Tracking selectors tell LoadStrike where to find the ID that ties one workflow together. Use them when the source and destination need to be matched in the report.

What this page helps you do

What this page helps you do

Tracking selectors tell LoadStrike where to find the ID that ties one workflow together. Use them when the source and destination need to be matched in the report.

Who this is for

Teams controlling runtime behavior, tracking, reporting, licensing, or policy from code, JSON, or CLI settings.

Prerequisites

  • A scenario or run configuration that already works locally

By the end

The documented runtime setting or policy surface for this part of the product.

Use this page when

Use this page when runtime behavior changes because of configuration, policy, or execution settings rather than the scenario body itself.

Visual guide

Transaction diagram showing source action, handoff, downstream processing, and completion.
The settings on this page only make sense when the workflow is treated as one transaction from source action to downstream completion.

Guide

Header Selector

Use a header selector when the tracking ID travels as metadata, for example `header:X-Correlation-Id`. The selector prefix is case-insensitive, but the header name after the prefix is exact-case. Selector helper APIs also expose direct TrackingFieldSelector construction plus Parse, TryParse, Extract, and string formatting helpers across the public SDKs that publish selector helper methods.

LoadStrike Trace Header

Set UseLoadStrikeTraceIdHeader to true when generated source traffic does not already have a business tracking field. When TrackingField is omitted, LoadStrike uses `header:loadstrike-trace-id` and injects a GUID value into messages it produces. The header is not injected when the source endpoint is in Consume mode or RunMode is CorrelateExistingTraffic, because those modes observe existing traffic only.

Body Selector

Use a body selector when the tracking ID only exists inside the payload, for example `json:$.trackingId` or `json:$trackingId`. JSON property lookup is exact-case, so every property segment in the selector must match the payload exactly. MessagePayloadType can be supplied for typed parsing, and invalid selector expressions use the same helper error contract across SDKs.

Destination GatherByField

GatherByField is an optional destination selector that uses the same syntax as TrackingField. Use it when the report should group results by tenant, region, event type, or another business dimension. Grouping stays case-sensitive by default unless GatherByFieldValueCaseSensitive is turned off.

Endpoint Base Fields

TrafficEndpointDefinition also carries shared endpoint fields such as AutoGenerateTrackingIdWhenMissing, PollInterval, MessageHeaders, MessagePayload, MessagePayloadType, JsonSettings, JsonConvertSettings, and ContentType. These apply across endpoint adapters, and PollInterval must be positive when it is explicitly configured.

Configuration samples

Use these samples to see how Tracking Selectors is configured in code, JSON, or CLI surfaces where this page documents them.

If you run these examples locally, add a valid runner key before execution starts. Set it with WithRunnerKey("...") or the config key LoadStrike:RunnerKey.

Tracking Selectors

using LoadStrike;

var source = new HttpEndpointDefinition
{
    Name = "orders-api",
    Mode = TrafficEndpointMode.Produce,
    Url = "https://api.example.com/orders",
    Method = "POST",
    MessageHeaders =
    {
        ["X-Tenant-Id"] = "Tenant-A"
    },
    MessagePayload = new { orderId = "ORD-1001", amount = 49.95m }
};

var destination = new KafkaEndpointDefinition
{
    Name = "orders-events",
    Mode = TrafficEndpointMode.Consume,
    GatherByField = TrackingFieldSelector.Parse("header:X-Tenant-Id"),
    BootstrapServers = "localhost:9092",
    Topic = "orders.completed",
    ConsumerGroupId = "orders-tests"
};

var tracking = new CrossPlatformTrackingConfiguration
{
    Source = source,
    Destination = destination,
    UseLoadStrikeTraceIdHeader = true,
    TrackingFieldValueCaseSensitive = false,
    GatherByFieldValueCaseSensitive = false
};

var scenario = CrossPlatformScenarioConfigurator
    .Configure(LoadStrikeScenario.Empty("orders-selector-demo"), tracking)
    .WithLoadSimulations(LoadStrikeSimulation.Inject(10, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(20)));

LoadStrikeRunner.RegisterScenarios(scenario)
    .WithRunnerKey("rkl_your_local_runner_key")
    .Run();

Tracking selector fields and formats

TrackingFieldSelector.Parse(expression)

Parses a selector string such as header:X-Correlation-Id or json:$.trackingId. The selector prefix is case-insensitive, but the header name or JSON path segments after the prefix must match exact casing.

TrackingFieldLocation.Header

Direct constructor value for header-based extraction.

TrackingFieldLocation.Json

Direct constructor value for JSON-path extraction.

header:<name>

Reads the correlation value from a message header or HTTP header. <name> is exact-case, so header:X-Correlation-Id and header:x-correlation-id are treated as different selectors.

json:$.<path>

Reads the correlation value from a JSON body path. Use it only when the payload is actually JSON, and keep every JSON property segment in its exact original casing.

TrackingFieldValueCaseSensitive

Defaults to true on the tracking configuration. Set it to false when source and destination values may differ only by casing but should still match.

TryParse(expression, out selector)

Safe parser when you want to validate external selector input before constructing the scenario.