-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Support Statsbeat in EU regions (#2082) * Use a diff statsbeat ikey in eu regions * Use lowercase * Fix spotless * Reserve statsbeat config when applicable * Make test easier to understand * Remove unused constants * Decouple TelemetryClient * Add comments * Refactor * Fix spotless * Remove assignment * Fix tests * Convert url to string * Use regex * Strict protocol * No need to escape dash * Remove escape * Add a startup profiler for debugging (#2085) * Add StartupProfiler * Fix errorprone * Fix spotless * Invoke before premain Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com> * Create dump in applicationinsights folder * Show the full path of the dump * Fix lgtm * Allow sout * Fix lgtm * Supress systemout at the method level * Fix style complain * Address comments * Fix spotless * Address comments * Return when exception occurs * Remove comment Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com> * Use getBoolean for system property Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com> * Fix startup profiling (#2092) * Fix startup profiling * errorprone * Shorten host property in network statsbeat (#2087) * Shorten host * Use regex * Fix spotless * Strict protocol * Remove sout debugging * Remove escape . * Send endpointUrl when region is not found * Turn off oshi logging (#2086) * Turn off oshi logging * Update oshi logger level * Don't mark throttle as error (#2079) * Update azure-core dependency (#2095) Co-authored-by: Helen Y <56097766+heyams@users.noreply.github.com>
- Loading branch information
Showing
14 changed files
with
507 additions
and
105 deletions.
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
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
94 changes: 94 additions & 0 deletions
94
...com/microsoft/applicationinsights/agent/internal/telemetry/StatsbeatConnectionString.java
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 |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* ApplicationInsights-Java | ||
* Copyright (c) Microsoft Corporation | ||
* All rights reserved. | ||
* | ||
* MIT License | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this | ||
* software and associated documentation files (the ""Software""), to deal in the Software | ||
* without restriction, including without limitation the rights to use, copy, modify, merge, | ||
* publish, distribute, sublicense, and/or sell copies of the Software, and to permit | ||
* persons to whom the Software is furnished to do so, subject to the following conditions: | ||
* The above copyright notice and this permission notice shall be included in all copies or | ||
* substantial portions of the Software. | ||
* THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE | ||
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
* DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
package com.microsoft.applicationinsights.agent.internal.telemetry; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
import javax.annotation.Nullable; | ||
|
||
final class StatsbeatConnectionString { | ||
|
||
// visible for testing | ||
static final String EU_REGION_STATSBEAT_IKEY = | ||
"7dc56bab-3c0c-4e9f-9ebb-d1acadee8d0f"; // westeu-aistatsbeat | ||
static final String EU_REGION_STATSBEAT_ENDPOINT = | ||
"https://westeurope-5.in.applicationinsights.azure.com/"; | ||
static final String NON_EU_REGION_STATSBEAT_IKEY = | ||
"c4a29126-a7cb-47e5-b348-11414998b11e"; // workspace-aistatsbeat | ||
static final String NON_EU_REGION_STATSBEAT_ENDPOINT = | ||
"https://westus-0.in.applicationinsights.azure.com/"; | ||
|
||
private static final Pattern pattern = Pattern.compile("^https?://(?:www\\.)?([^/.-]+)"); | ||
|
||
private static final Set<String> EU_REGION_GEO_SET = new HashSet<>(10); | ||
|
||
static { | ||
EU_REGION_GEO_SET.add("westeurope"); | ||
EU_REGION_GEO_SET.add("northeurope"); | ||
EU_REGION_GEO_SET.add("francecentral"); | ||
EU_REGION_GEO_SET.add("francesouth"); | ||
EU_REGION_GEO_SET.add("germanywestcentral"); | ||
EU_REGION_GEO_SET.add("norwayeast"); | ||
EU_REGION_GEO_SET.add("norwaywest"); | ||
EU_REGION_GEO_SET.add("swedencentral"); | ||
EU_REGION_GEO_SET.add("switzerlandnorth"); | ||
EU_REGION_GEO_SET.add("switzerlandwest"); | ||
} | ||
|
||
// visible for testing | ||
static InstrumentationKeyEndpointPair getInstrumentationKeyAndEndpointPair( | ||
String customerEndpoint) { | ||
String geo = getGeoWithoutStampSpecific(customerEndpoint); | ||
if (EU_REGION_GEO_SET.contains(geo.toLowerCase())) { | ||
return new InstrumentationKeyEndpointPair( | ||
EU_REGION_STATSBEAT_IKEY, EU_REGION_STATSBEAT_ENDPOINT); | ||
} | ||
|
||
return new InstrumentationKeyEndpointPair( | ||
NON_EU_REGION_STATSBEAT_IKEY, NON_EU_REGION_STATSBEAT_ENDPOINT); | ||
} | ||
|
||
// visible for testing | ||
@Nullable | ||
static String getGeoWithoutStampSpecific(String endpointUrl) { | ||
Matcher matcher = pattern.matcher(endpointUrl); | ||
if (matcher.find()) { | ||
return matcher.group(1); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
private StatsbeatConnectionString() {} | ||
|
||
static class InstrumentationKeyEndpointPair { | ||
public final String instrumentationKey; | ||
public final String endpoint; | ||
|
||
public InstrumentationKeyEndpointPair(String instrumentationKey, String endpoint) { | ||
this.instrumentationKey = instrumentationKey; | ||
this.endpoint = endpoint; | ||
} | ||
} | ||
} |
Oops, something went wrong.