-
Notifications
You must be signed in to change notification settings - Fork 834
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
Add memory mode support to OTLP exporters #6430
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a1548a6
Add memory mode support to OTLP span exporters
jack-berg 3d22bfc
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
jack-berg 0f346b2
Add low allocation support to OTLP metric exporters
jack-berg cb5f4ac
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
jack-berg 039bdfa
Add low allocation support to OTLP log exporters
jack-berg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,9 @@ | |
import static io.opentelemetry.sdk.metrics.Aggregation.explicitBucketHistogram; | ||
|
||
import io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporterBuilder; | ||
import io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporterBuilder; | ||
import io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporterBuilder; | ||
import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder; | ||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; | ||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException; | ||
import io.opentelemetry.sdk.common.export.MemoryMode; | ||
|
@@ -212,12 +214,12 @@ public static void configureOtlpHistogramDefaultAggregation( | |
} | ||
|
||
/** | ||
* Calls {@code #setMemoryMode} on the {@code Otlp{Protocol}MetricExporterBuilder} with the {@code | ||
* memoryMode}. | ||
* Calls {@code #setMemoryMode} on the {@code Otlp{Protocol}{Signal}ExporterBuilder} with the | ||
* {@code memoryMode}. | ||
*/ | ||
public static void setMemoryModeOnOtlpMetricExporterBuilder( | ||
Object builder, MemoryMode memoryMode) { | ||
public static void setMemoryModeOnOtlpExporterBuilder(Object builder, MemoryMode memoryMode) { | ||
try { | ||
// Metrics | ||
if (builder instanceof OtlpGrpcMetricExporterBuilder) { | ||
// Calling getDeclaredMethod causes all private methods to be read, which causes a | ||
// ClassNotFoundException when running with the OkHttHttpProvider as the private | ||
|
@@ -237,9 +239,27 @@ public static void setMemoryModeOnOtlpMetricExporterBuilder( | |
"setMemoryMode", MemoryMode.class); | ||
method.setAccessible(true); | ||
method.invoke(builder, memoryMode); | ||
} else if (builder instanceof OtlpGrpcSpanExporterBuilder) { | ||
// Calling getDeclaredMethod causes all private methods to be read, which causes a | ||
// ClassNotFoundException when running with the OkHttHttpProvider as the private | ||
// setManagedChanel(io.grpc.ManagedChannel) is reached and io.grpc.ManagedChannel is not on | ||
// the classpath. io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanUtil provides a layer | ||
// of indirection which avoids scanning the OtlpGrpcSpanExporterBuilder private methods. | ||
Class<?> otlpGrpcMetricUtil = | ||
Class.forName("io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanUtil"); | ||
Method method = | ||
otlpGrpcMetricUtil.getDeclaredMethod( | ||
"setMemoryMode", OtlpGrpcSpanExporterBuilder.class, MemoryMode.class); | ||
method.setAccessible(true); | ||
method.invoke(null, builder, memoryMode); | ||
} else if (builder instanceof OtlpHttpSpanExporterBuilder) { | ||
Method method = | ||
OtlpHttpSpanExporterBuilder.class.getDeclaredMethod("setMemoryMode", MemoryMode.class); | ||
method.setAccessible(true); | ||
method.invoke(builder, memoryMode); | ||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This ugliness will go away once we promote memory mode to the stable API. I think we just need a release or so to be sure we think this concept is going to work. |
||
throw new IllegalArgumentException( | ||
"Can only set memory mode on OtlpHttpMetricExporterBuilder and OtlpGrpcMetricExporterBuilder."); | ||
"Cannot set memory mode. Unrecognized OTLP exporter builder"); | ||
} | ||
} catch (NoSuchMethodException | ||
| InvocationTargetException | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could have been avoided by using method handles. Alternatively could have used an internal interface to expose this method.