[Feature] Add sampleType to SampleResult
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.3k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 5
Description
### Use case
There is currently no explicit/documented field in `SampleResult` that identifies the type of result, such as `SAMPLE` or `TRANSACTION`.
The current workaround is to use:
```java
TransactionController.isFromTransactionController(sampleResult)
```
However, this approach is fragile because transaction detection depends on other `SampleResult` fields. In particular, it can break when a user redefines the `responseMessage` of the Transaction Controller with a custom value.
This behavior is also not documented, so users have no way to know that redefining the Transaction Controller's `responseMessage` can silently break transaction detection.
### Possible solution
Add an explicit `sampleType` field to `SampleResult`, for example:
```java
public enum SampleType {
SAMPLE,
TRANSACTION
}
```
Then consumers could use:
```java
sampleResult.getSampleType() == SampleType.TRANSACTION
```
This would provide a reliable way for listeners, backend listeners, plugins, and other consumers to identify the type of a `SampleResult`.
### Possible workarounds
_No response_
### JMeter Version
5.6.3
### Java Version
java 17.0.7
### OS Version
_No response_
Contributor guide
Research direction
Read the SampleResult API and TransactionController.isFromTransactionController entry point first, then trace how listeners, backend listeners, plugins, and other consumers identify result types. Done means SampleResult exposes an explicit SAMPLE or TRANSACTION type that remains reliable when a Transaction Controller responseMessage is customized.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100