Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] enabled mockTelemetryPlugin for IT and fixed OOM (#13054) #13269

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Fixed
- Fix bulk API ignores ingest pipeline for upsert ([#12883](https://github.com/opensearch-project/OpenSearch/pull/12883))
- Fix issue with feature flags where default value may not be honored ([#12849](https://github.com/opensearch-project/OpenSearch/pull/12849))
- Enabled mockTelemetryPlugin for IT and fixed OOM issues ([#13054](https://github.com/opensearch-project/OpenSearch/pull/13054))
- Fix implement mark() and markSupported() in class FilterStreamInput ([#13098](https://github.com/opensearch-project/OpenSearch/pull/13098))
- Fix snapshot _status API to return correct status for partial snapshots ([#13260](https://github.com/opensearch-project/OpenSearch/pull/13260))

Expand Down
1 change: 1 addition & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ This will instruct all JVMs (including any that run cli tools such as creating t
- In order to remotely attach a debugger to the process: `--debug-jvm`
- In order to set a different keystore password: `--keystore-password yourpassword`
- In order to set an OpenSearch setting, provide a setting with the following prefix: `-Dtests.opensearch.`
- In order to enable stack trace of the MockSpanData during testing, add: `-Dtests.telemetry.span.stack_traces=true` (Storing stack traces alongside span data can be useful for comprehensive debugging and performance optimization during testing, as it provides insights into the exact code paths and execution sequences, facilitating efficient issue identification and resolution. Note: Enabling this might lead to OOM issues while running ITs)

## Test case filtering

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2112,8 +2112,7 @@ protected boolean addMockGeoShapeFieldMapper() {
* @return boolean.
*/
protected boolean addMockTelemetryPlugin() {
// setting to false until https://github.com/opensearch-project/OpenSearch/issues/12615 is resolved
return false;
return true;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.opensearch.test.telemetry.tracing;

import org.opensearch.common.Booleans;
import org.opensearch.telemetry.tracing.Span;
import org.opensearch.test.telemetry.tracing.validators.AllSpansAreEndedProperly;
import org.opensearch.test.telemetry.tracing.validators.AllSpansHaveUniqueId;
Expand All @@ -29,6 +30,14 @@ public StrictCheckSpanProcessor() {}

private static Map<String, MockSpanData> spanMap = new ConcurrentHashMap<>();

// If you want to see the stack trace for each spanData, then
// update the flag to true or set the corresponding system property to true
// This is helpful in debugging the tests. Default value is false.
// Note: Enabling this might lead to OOM issues while running ITs.
private static final boolean isStackTraceForSpanEnabled = Booleans.parseBoolean(
System.getProperty("tests.telemetry.span.stack_traces", "false")
);

@Override
public void onStart(Span span) {
spanMap.put(span.getSpanId(), toMockSpanData(span));
Expand All @@ -53,14 +62,15 @@ public List<MockSpanData> getFinishedSpanItems() {

private MockSpanData toMockSpanData(Span span) {
String parentSpanId = (span.getParentSpan() != null) ? span.getParentSpan().getSpanId() : "";
StackTraceElement[] stackTrace = isStackTraceForSpanEnabled ? Thread.currentThread().getStackTrace() : null;
MockSpanData spanData = new MockSpanData(
span.getSpanId(),
parentSpanId,
span.getTraceId(),
System.nanoTime(),
false,
span.getSpanName(),
Thread.currentThread().getStackTrace(),
stackTrace,
(span instanceof MockSpan) ? ((MockSpan) span).getAttributes() : Map.of()
);
return spanData;
Expand Down
Loading