-
Notifications
You must be signed in to change notification settings - Fork 102
fix: use the same background executor in otel reader and monitoring c… #2746
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,9 @@ | |
| import io.opentelemetry.sdk.metrics.export.MetricExporter; | ||
| import io.opentelemetry.sdk.metrics.export.PeriodicMetricReader; | ||
| import java.io.IOException; | ||
| import java.time.Duration; | ||
| import java.util.Map; | ||
| import java.util.concurrent.ScheduledExecutorService; | ||
| import javax.annotation.Nullable; | ||
|
|
||
| /** | ||
|
|
@@ -100,27 +102,47 @@ public static void registerBuiltinMetrics( | |
| @Nullable Credentials credentials, SdkMeterProviderBuilder builder, @Nullable String endpoint) | ||
|
Contributor
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. should this method be deprecated?
Contributor
Author
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. I don't think so, we just marked everything else with project id as deprecated since project id is not used anymore. Also the whole class is deprecated because we want to encourage poeple to move to CustomOpenTelemetryMetricsProvider |
||
| throws IOException { | ||
| registerBuiltinMetricsWithUniverseDomain( | ||
| credentials, builder, endpoint, Credentials.GOOGLE_DEFAULT_UNIVERSE); | ||
| credentials, builder, endpoint, Credentials.GOOGLE_DEFAULT_UNIVERSE, null); | ||
| } | ||
|
|
||
| /** | ||
| * Register built-in metrics on the {@link SdkMeterProviderBuilder} with custom credentials, | ||
| * endpoint and executor service. | ||
| */ | ||
| public static void registerBuiltinMetrics( | ||
| @Nullable Credentials credentials, | ||
| SdkMeterProviderBuilder builder, | ||
| @Nullable String endpoint, | ||
| @Nullable ScheduledExecutorService executorService) | ||
| throws IOException { | ||
| registerBuiltinMetricsWithUniverseDomain( | ||
| credentials, builder, endpoint, Credentials.GOOGLE_DEFAULT_UNIVERSE, executorService); | ||
| } | ||
|
|
||
| static void registerBuiltinMetricsWithUniverseDomain( | ||
| @Nullable Credentials credentials, | ||
| SdkMeterProviderBuilder builder, | ||
| @Nullable String endpoint, | ||
| String universeDomain) | ||
| String universeDomain, | ||
| @Nullable ScheduledExecutorService executorService) | ||
| throws IOException { | ||
| MetricExporter publicExporter = | ||
| BigtableCloudMonitoringExporter.create( | ||
| "bigtable metrics", | ||
| credentials, | ||
| endpoint, | ||
| universeDomain, | ||
| new BigtableCloudMonitoringExporter.PublicTimeSeriesConverter()); | ||
| new BigtableCloudMonitoringExporter.PublicTimeSeriesConverter(), | ||
| executorService); | ||
|
|
||
| for (Map.Entry<InstrumentSelector, View> entry : | ||
| BuiltinMetricsConstants.getAllViews().entrySet()) { | ||
| builder.registerView(entry.getKey(), entry.getValue()); | ||
| } | ||
| builder.registerMetricReader(PeriodicMetricReader.create(publicExporter)); | ||
| builder.registerMetricReader( | ||
| PeriodicMetricReader.builder(publicExporter) | ||
| .setExecutor(executorService) | ||
| .setInterval(Duration.ofMinutes(1)) | ||
| .build()); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
when is this null? add a comment