-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Enable statsbeat #37032
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
Merged
Merged
Enable statsbeat #37032
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
1d72587
Enable statsbeat
heyams 3fbbab7
Fix imports
heyams 4f41c81
Merge remote-tracking branch 'upstream/main' into heya/enable-statsbeat
heyams 109cbf0
Test using a shorter intervals
heyams 90eeefb
Update
heyams df57c1b
Merge remote-tracking branch 'upstream/main' into heya/enable-statsbeat
heyams 2945a09
Add end-to-end test
heyams 8af83d8
Fix imports
heyams 2bd42f8
Fix spotbug
heyams bff7b01
Fix test
heyams e0e5ede
Merge remote-tracking branch 'upstream/main' into heya/enable-statsbeat
heyams 11ecc7b
Merge remote-tracking branch 'upstream/main' into heya/enable-statsbeat
heyams 965fa63
Update test
heyams 1022037
Fix tests
heyams f16a643
Remove standalone flag
heyams 456a1dc
Fix compilation
heyams 1085d08
Fix
heyams 0b855a2
Fix tests
heyams 273d4aa
Remove setRpAttachType
heyams 06ff391
Merge remote-tracking branch 'upstream/main' into heya/enable-statsbeat
heyams 2e72fb0
Use unreleased version of azure-core-test per Srikanta's request
heyams 69ce931
Address comments
heyams 18b6d75
Merge remote-tracking branch 'upstream/main' into heya/enable-statsbeat
heyams 84d82e9
Update unreleased_com.azure:azure-core-test version
heyams 0c98a5d
Fix duplicate entry in version_client.txt
heyams 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -27,13 +27,17 @@ | |
| import com.azure.monitor.opentelemetry.exporter.implementation.SpanDataMapper; | ||
| import com.azure.monitor.opentelemetry.exporter.implementation.builders.AbstractTelemetryBuilder; | ||
| import com.azure.monitor.opentelemetry.exporter.implementation.configuration.ConnectionString; | ||
| import com.azure.monitor.opentelemetry.exporter.implementation.configuration.StatsbeatConnectionString; | ||
| import com.azure.monitor.opentelemetry.exporter.implementation.heartbeat.HeartbeatExporter; | ||
| import com.azure.monitor.opentelemetry.exporter.implementation.localstorage.LocalStorageStats; | ||
| import com.azure.monitor.opentelemetry.exporter.implementation.localstorage.LocalStorageTelemetryPipelineListener; | ||
| import com.azure.monitor.opentelemetry.exporter.implementation.models.ContextTagKeys; | ||
| import com.azure.monitor.opentelemetry.exporter.implementation.pipeline.TelemetryItemExporter; | ||
| import com.azure.monitor.opentelemetry.exporter.implementation.pipeline.TelemetryPipeline; | ||
| import com.azure.monitor.opentelemetry.exporter.implementation.pipeline.TelemetryPipelineListener; | ||
| import com.azure.monitor.opentelemetry.exporter.implementation.statsbeat.Feature; | ||
| import com.azure.monitor.opentelemetry.exporter.implementation.statsbeat.StatsbeatModule; | ||
| import com.azure.monitor.opentelemetry.exporter.implementation.utils.PropertyHelper; | ||
| import com.azure.monitor.opentelemetry.exporter.implementation.utils.ResourceParser; | ||
| import com.azure.monitor.opentelemetry.exporter.implementation.utils.TempDirs; | ||
| import com.azure.monitor.opentelemetry.exporter.implementation.utils.VersionGenerator; | ||
|
|
@@ -55,9 +59,12 @@ | |
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Objects; | ||
| import java.util.Set; | ||
| import java.util.function.BiConsumer; | ||
|
|
||
| import static java.util.concurrent.TimeUnit.DAYS; | ||
| import static java.util.concurrent.TimeUnit.MINUTES; | ||
| import static java.util.concurrent.TimeUnit.SECONDS; | ||
|
|
||
| /** | ||
| * This class provides a fluent builder API to configure the OpenTelemetry SDK with Azure Monitor Exporters. | ||
|
|
@@ -71,6 +78,9 @@ public final class AzureMonitorExporterBuilder { | |
| private static final String APPLICATIONINSIGHTS_AUTHENTICATION_SCOPE = | ||
| "https://monitor.azure.com//.default"; | ||
|
|
||
| private static final String STATSBEAT_LONG_INTERVAL_SECONDS = "STATSBEAT_LONG_INTERVAL_SECONDS"; | ||
| private static final String STATSBEAT_SHORT_INTERVAL_SECONDS = "STATSBEAT_SHORT_INTERVAL_SECONDS"; | ||
|
|
||
| private static final Map<String, String> PROPERTIES = | ||
| CoreUtils.getProperties("azure-monitor-opentelemetry-exporter.properties"); | ||
|
|
||
|
|
@@ -257,7 +267,7 @@ public SpanExporter buildTraceExporter() { | |
| public MetricExporter buildMetricExporter() { | ||
| internalBuildAndFreeze(); | ||
| // TODO (trask) how to pass along configuration properties? | ||
| return buildMetricExporter(DefaultConfigProperties.createForTest(Collections.emptyMap())); | ||
| return buildMetricExporter(DefaultConfigProperties.create(Collections.emptyMap())); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -271,7 +281,7 @@ public MetricExporter buildMetricExporter() { | |
| public LogRecordExporter buildLogRecordExporter() { | ||
| internalBuildAndFreeze(); | ||
| // TODO (trask) how to pass along configuration properties? | ||
| return buildLogRecordExporter(DefaultConfigProperties.createForTest(Collections.emptyMap())); | ||
| return buildLogRecordExporter(DefaultConfigProperties.create(Collections.emptyMap())); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -351,10 +361,45 @@ private SpanExporter buildTraceExporter(ConfigProperties configProperties) { | |
| private MetricExporter buildMetricExporter(ConfigProperties configProperties) { | ||
| HeartbeatExporter.start( | ||
| MINUTES.toSeconds(15), createDefaultsPopulator(configProperties), builtTelemetryItemExporter::send); | ||
| if (connectionString != null) { | ||
| StatsbeatModule statsbeatModule = new StatsbeatModule(PropertyHelper::lazyUpdateVmRpIntegration); | ||
| statsbeatModule.start( | ||
| builtTelemetryItemExporter, | ||
| this::getStatsbeatConnectionString, | ||
| connectionString::getInstrumentationKey, | ||
| false, | ||
| getStatsbeaLongInterval(configProperties.getInt(STATSBEAT_LONG_INTERVAL_SECONDS)), | ||
| getStatsbeatShortInterval(configProperties.getInt(STATSBEAT_SHORT_INTERVAL_SECONDS)), | ||
| false, | ||
| initStatsbeatFeatures()); | ||
| } | ||
| return new AzureMonitorMetricExporter( | ||
| new MetricDataMapper(createDefaultsPopulator(configProperties), true), builtTelemetryItemExporter); | ||
| } | ||
|
|
||
| private long getStatsbeaLongInterval(Integer intervalFromConfig) { | ||
| if (intervalFromConfig == null) { | ||
| return DAYS.toSeconds(1); // default to every 24 hours | ||
| } | ||
| return SECONDS.toSeconds(intervalFromConfig); | ||
| } | ||
|
|
||
| private long getStatsbeatShortInterval(Integer intervalFromConfig) { | ||
| if (intervalFromConfig == null) { | ||
| return MINUTES.toSeconds(15); // default to every 15 mins | ||
| } | ||
| return SECONDS.toSeconds(intervalFromConfig); | ||
| } | ||
|
|
||
| private Set<Feature> initStatsbeatFeatures() { | ||
| // TODO (jean): start tracking native image usage based on a system property or env var to indicate it's from the native image path | ||
|
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. I 'm beginning to wonder if tracking native image usage with a |
||
| return Collections.emptySet(); | ||
| } | ||
|
|
||
| private StatsbeatConnectionString getStatsbeatConnectionString() { | ||
| return StatsbeatConnectionString.create(connectionString, null, null); | ||
| } | ||
|
|
||
| private LogRecordExporter buildLogRecordExporter(ConfigProperties configProperties) { | ||
| return new AzureMonitorLogRecordExporter( | ||
| new LogDataMapper(true, false, createDefaultsPopulator(configProperties)), builtTelemetryItemExporter); | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.