Skip to content

Commit

Permalink
Merge branch 'opensearch-project:main' into segment-download-stats
Browse files Browse the repository at this point in the history
  • Loading branch information
shourya035 authored Jul 6, 2023
2 parents 743c09a + c1c23b4 commit 94f0f58
Show file tree
Hide file tree
Showing 35 changed files with 741 additions and 419 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Improve summary error message for invalid setting updates ([#4792](https://github.com/opensearch-project/OpenSearch/pull/4792))
- Pass localNode info to all plugins on node start ([#7919](https://github.com/opensearch-project/OpenSearch/pull/7919))
- Improved performance of parsing floating point numbers ([#7909](https://github.com/opensearch-project/OpenSearch/pull/7909))
- Move span actions to Scope ([#8411](https://github.com/opensearch-project/OpenSearch/pull/8411))

### Deprecated

Expand Down Expand Up @@ -97,6 +98,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Enable Point based optimization for custom comparators ([#8168](https://github.com/opensearch-project/OpenSearch/pull/8168))
- [Extensions] Support extension additional settings with extension REST initialization ([#8414](https://github.com/opensearch-project/OpenSearch/pull/8414))
- Adds mock implementation for TelemetryPlugin ([#7545](https://github.com/opensearch-project/OpenSearch/issues/7545))
- Support transport action names when registering NamedRoutes ([#7957](https://github.com/opensearch-project/OpenSearch/pull/7957))

### Dependencies
- Bump `com.azure:azure-storage-common` from 12.21.0 to 12.21.1 (#7566, #7814)
Expand Down Expand Up @@ -131,6 +133,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Bump `com.google.api-client:google-api-client` from 1.34.0 to 2.2.0 ([#8276](https://github.com/opensearch-project/OpenSearch/pull/8276))
- Update Apache HttpCore/ HttpClient and Apache HttpCore5 / HttpClient5 dependencies ([#8434](https://github.com/opensearch-project/OpenSearch/pull/8434))
- Bump `org.apache.maven:maven-model` from 3.9.2 to 3.9.3 (#8403)
- Bump `io.projectreactor.netty:reactor-netty` and `io.projectreactor.netty:reactor-netty-core` from 1.1.7 to 1.1.8 (#8405)

### Changed
- Replace jboss-annotations-api_1.2_spec with jakarta.annotation-api ([#7836](https://github.com/opensearch-project/OpenSearch/pull/7836))
Expand All @@ -148,6 +151,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Add self-organizing hash table to improve the performance of bucket aggregations ([#7652](https://github.com/opensearch-project/OpenSearch/pull/7652))
- Check UTF16 string size before converting to String to avoid OOME ([#7963](https://github.com/opensearch-project/OpenSearch/pull/7963))
- Move ZSTD compression codecs out of the sandbox ([#7908](https://github.com/opensearch-project/OpenSearch/pull/7908))
- Update ZSTD default compression level ([#8471](https://github.com/opensearch-project/OpenSearch/pull/8471))


### Deprecated
Expand All @@ -167,4 +171,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Security

[Unreleased 3.0]: https://github.com/opensearch-project/OpenSearch/compare/2.x...HEAD
[Unreleased 2.x]: https://github.com/opensearch-project/OpenSearch/compare/2.8...2.x
[Unreleased 2.x]: https://github.com/opensearch-project/OpenSearch/compare/2.8...2.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package org.opensearch.telemetry.tracing;

import java.util.function.Consumer;

/**
* Default implementation of Scope
*/
public class DefaultSpanScope implements SpanScope {

private final Span span;

private final Consumer<Span> onCloseConsumer;

/**
* Creates Scope instance for the given span
*
* @param span underlying span
* @param onCloseConsumer consumer to execute on scope close
*/
public DefaultSpanScope(Span span, Consumer<Span> onCloseConsumer) {
this.span = span;
this.onCloseConsumer = onCloseConsumer;
}

@Override
public void addSpanAttribute(String key, String value) {
span.addAttribute(key, value);
}

@Override
public void addSpanAttribute(String key, long value) {
span.addAttribute(key, value);
}

@Override
public void addSpanAttribute(String key, double value) {
span.addAttribute(key, value);
}

@Override
public void addSpanAttribute(String key, boolean value) {
span.addAttribute(key, value);
}

@Override
public void addSpanEvent(String event) {
span.addEvent(event);
}

@Override
public void setError(Exception exception) {
span.setError(exception);
}

/**
* Executes the runnable to end the scope
*/
@Override
public void close() {
onCloseConsumer.accept(span);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

/**
*
* The default tracer implementation. This class implements the basic logic for span lifecycle and its state management.
* It also handles tracing context propagation between spans.
* The default tracer implementation. It handles tracing context propagation between spans by maintaining
* current active span in its storage
*
*
*/
Expand All @@ -36,41 +36,11 @@ public DefaultTracer(TracingTelemetry tracingTelemetry, TracerContextStorage<Str
}

@Override
public Scope startSpan(String spanName) {
public SpanScope startSpan(String spanName) {
Span span = createSpan(spanName, getCurrentSpan());
setCurrentSpanInContext(span);
addDefaultAttributes(span);
return new ScopeImpl(() -> endSpan(span));
}

@Override
public void addSpanAttribute(String key, String value) {
Span currentSpan = getCurrentSpan();
currentSpan.addAttribute(key, value);
}

@Override
public void addSpanAttribute(String key, long value) {
Span currentSpan = getCurrentSpan();
currentSpan.addAttribute(key, value);
}

@Override
public void addSpanAttribute(String key, double value) {
Span currentSpan = getCurrentSpan();
currentSpan.addAttribute(key, value);
}

@Override
public void addSpanAttribute(String key, boolean value) {
Span currentSpan = getCurrentSpan();
currentSpan.addAttribute(key, value);
}

@Override
public void addSpanEvent(String event) {
Span currentSpan = getCurrentSpan();
currentSpan.addEvent(event);
return new DefaultSpanScope(span, (scopeSpan) -> endSpan(scopeSpan));
}

@Override
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ public interface Span {
*/
void addAttribute(String key, Boolean value);

/**
* Records error in the span
*
* @param exception exception to be recorded
*/
void setError(Exception exception);

/**
* Adds an event in the span
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package org.opensearch.telemetry.tracing;

import org.opensearch.telemetry.tracing.noop.NoopSpanScope;

/**
* An auto-closeable that represents scope of the span.
* It provides interface for all the span operations.
*/
public interface SpanScope extends AutoCloseable {
/**
* No-op Scope implementation
*/
SpanScope NO_OP = new NoopSpanScope();

/**
* Adds string attribute to the {@link Span}.
*
* @param key attribute key
* @param value attribute value
*/
void addSpanAttribute(String key, String value);

/**
* Adds long attribute to the {@link Span}.
*
* @param key attribute key
* @param value attribute value
*/
void addSpanAttribute(String key, long value);

/**
* Adds double attribute to the {@link Span}.
*
* @param key attribute key
* @param value attribute value
*/
void addSpanAttribute(String key, double value);

/**
* Adds boolean attribute to the {@link Span}.
*
* @param key attribute key
* @param value attribute value
*/
void addSpanAttribute(String key, boolean value);

/**
* Adds an event to the {@link Span}.
*
* @param event event name
*/
void addSpanEvent(String event);

/**
* Records error in the span
*
* @param exception exception to be recorded
*/
void setError(Exception exception);

/**
* closes the scope
*/
@Override
void close();
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import java.io.Closeable;

/**
* Tracer is the interface used to create a {@link Span} and interact with current active {@link Span}.
* Tracer is the interface used to create a {@link Span}
* It automatically handles the context propagation between threads, tasks, nodes etc.
*
* All methods on the Tracer object are multi-thread safe.
Expand All @@ -24,44 +24,6 @@ public interface Tracer extends Closeable {
* @param spanName span name
* @return scope of the span, must be closed with explicit close or with try-with-resource
*/
Scope startSpan(String spanName);
SpanScope startSpan(String spanName);

/**
* Adds string attribute to the current active {@link Span}.
*
* @param key attribute key
* @param value attribute value
*/
void addSpanAttribute(String key, String value);

/**
* Adds long attribute to the current active {@link Span}.
*
* @param key attribute key
* @param value attribute value
*/
void addSpanAttribute(String key, long value);

/**
* Adds double attribute to the current active {@link Span}.
*
* @param key attribute key
* @param value attribute value
*/
void addSpanAttribute(String key, double value);

/**
* Adds boolean attribute to the current active {@link Span}.
*
* @param key attribute key
* @param value attribute value
*/
void addSpanAttribute(String key, boolean value);

/**
* Adds an event to the current active {@link Span}.
*
* @param event event name
*/
void addSpanEvent(String event);
}
Loading

0 comments on commit 94f0f58

Please sign in to comment.