Skip to content

Commit 9d3253f

Browse files
authored
fix: test slowness due to invalid otel url (#1184)
* fix: test slowness due to invalid otel url * fix: domain fix and changelog
1 parent 9b84d8c commit 9d3253f

File tree

9 files changed

+41
-30
lines changed

9 files changed

+41
-30
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
1111

1212
- Adds hikari logs to opentelemetry
1313
- Fetches core and plugin config from env
14+
- Open Telemetry configuration is now optional
15+
- Migrates API calls from supertokens.io to supertokens.com
1416

1517
## [11.0.5]
1618

config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,6 @@ core_config_version: 0
183183
# account recovery token is valid for.
184184
# webauthn_recover_account_token_lifetime:
185185

186-
# (OPTIONAL | Default: http://localhost:4317) string value. The URL of the OpenTelemetry collector to which the core
186+
# (OPTIONAL | Default: null) string value. The URL of the OpenTelemetry collector to which the core
187187
# will send telemetry data. This should be in the format http://<host>:<port> or https://<host>:<port>.
188188
# otel_collector_connection_uri:

devConfig.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,6 @@ disable_telemetry: true
183183
# account recovery token is valid for.
184184
# webauthn_recover_account_token_lifetime:
185185

186-
# (OPTIONAL | Default: http://localhost:4317) string value. The URL of the OpenTelemetry collector to which the core
186+
# (OPTIONAL | Default: null) string value. The URL of the OpenTelemetry collector to which the core
187187
# will send telemetry data. This should be in the format http://<host>:<port> or https://<host>:<port>.
188188
# otel_collector_connection_uri:

ee/src/main/java/io/supertokens/ee/EEFeatureFlag.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ private EE_FEATURES[] doServerCall(String licenseKey)
523523
ProcessState.getInstance(main)
524524
.addState(ProcessState.PROCESS_STATE.LICENSE_KEY_CHECK_NETWORK_CALL, null, json);
525525
JsonObject licenseCheckResponse = HttpRequest.sendJsonPOSTRequest(this.main, REQUEST_ID,
526-
"https://api.supertokens.io/0/st/license/check",
526+
"https://api.supertokens.com/0/st/license/check",
527527
json, 10000, 10000, 0);
528528
if (licenseCheckResponse.get("status").getAsString().equalsIgnoreCase("OK")) {
529529
Logging.debug(main, appIdentifier.getAsPublicTenantIdentifier(), "API returned OK");

src/main/java/io/supertokens/config/CoreConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,8 @@ public class CoreConfig {
409409
@ConfigDescription(
410410
"The URL of the OpenTelemetry collector to which the core will send telemetry data. " +
411411
"This should be in the format http://<host>:<port> or https://<host>:<port>. (Default: " +
412-
"http://localhost:4317)")
413-
private String otel_collector_connection_uri = "http://localhost:4317";
412+
"null)")
413+
private String otel_collector_connection_uri = null;
414414

415415
@IgnoreForAnnotationCheck
416416
private static boolean disableOAuthValidationForTest = false;

src/main/java/io/supertokens/cronjobs/telemetry/Telemetry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ protected void doTaskPerApp(AppIdentifier app) throws Exception {
157157
json.add("maus", new JsonArray());
158158
}
159159

160-
String url = "https://api.supertokens.io/0/st/telemetry";
160+
String url = "https://api.supertokens.com/0/st/telemetry";
161161

162162
// we call the API only if we are not testing the core, of if the request can be mocked (in case a test
163163
// wants

src/main/java/io/supertokens/storageLayer/StorageLayer.java

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public class StorageLayer extends ResourceDistributor.SingletonResource {
5454
public static final String RESOURCE_KEY = "io.supertokens.storageLayer.StorageLayer";
5555
private final Storage storage;
5656
private static URLClassLoader ucl = null;
57+
private static Storage storageInstanceForEnv = null;
5758

5859
public Storage getUnderlyingStorage() {
5960
return storage;
@@ -68,30 +69,34 @@ public static Storage getNewBulkImportProxyStorageInstance(Main main, JsonObject
6869
}
6970

7071
public static void updateConfigJsonFromEnv(Main main, JsonObject configJson) {
71-
Storage result;
72-
if (StorageLayer.ucl == null) {
73-
result = new Start(main);
74-
} else {
75-
Storage storageLayer = null;
76-
ServiceLoader<Storage> sl = ServiceLoader.load(Storage.class, ucl);
77-
for (Storage plugin : sl) {
78-
if (storageLayer == null) {
79-
storageLayer = plugin;
72+
if (storageInstanceForEnv == null) {
73+
Storage result;
74+
if (StorageLayer.ucl == null) {
75+
result = new Start(main);
76+
} else {
77+
Storage storageLayer = null;
78+
ServiceLoader<Storage> sl = ServiceLoader.load(Storage.class, ucl);
79+
for (Storage plugin : sl) {
80+
if (storageLayer == null) {
81+
storageLayer = plugin;
82+
} else {
83+
throw new QuitProgramException(
84+
"Multiple database plugins found. Please make sure that just one plugin is in the "
85+
+ "/plugin" + " "
86+
+ "folder of the installation. Alternatively, please redownload and install "
87+
+ "SuperTokens" + ".");
88+
}
89+
}
90+
if (storageLayer != null) {
91+
result = storageLayer;
8092
} else {
81-
throw new QuitProgramException(
82-
"Multiple database plugins found. Please make sure that just one plugin is in the "
83-
+ "/plugin" + " "
84-
+ "folder of the installation. Alternatively, please redownload and install "
85-
+ "SuperTokens" + ".");
93+
result = new Start(main);
8694
}
8795
}
88-
if (storageLayer != null) {
89-
result = storageLayer;
90-
} else {
91-
result = new Start(main);
92-
}
96+
storageInstanceForEnv = result;
9397
}
94-
result.updateConfigJsonFromEnv(configJson);
98+
99+
storageInstanceForEnv.updateConfigJsonFromEnv(configJson);
95100
}
96101

97102
private static Storage getNewInstance(Main main, JsonObject config, TenantIdentifier tenantIdentifier, boolean doNotLog, boolean isBulkImportProxy) throws InvalidConfigException {

src/main/java/io/supertokens/telemetry/TelemetryProvider.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public void createLogEvent(TenantIdentifier tenantIdentifier, String logMessage,
7474
public void createLogEvent(TenantIdentifier tenantIdentifier, String logMessage,
7575
String logLevel, Map<String, String> additionalAttributes) {
7676
if (openTelemetry == null) {
77-
throw new IllegalStateException("OpenTelemetry is not initialized. Call initialize() first.");
77+
return; // no telemetry provider available
7878
}
7979
SpanBuilder spanBuilder = createSpanBuilder(tenantIdentifier, logLevel, additionalAttributes);
8080

@@ -143,6 +143,12 @@ public static Span addEventToSpan(Span span, String eventName, Attributes attrib
143143

144144

145145
private static OpenTelemetry initializeOpenTelemetry(Main main) {
146+
String collectorUri = Config.getBaseConfig(main).getOtelCollectorConnectionURI();
147+
148+
if (collectorUri == null || collectorUri.isEmpty()) {
149+
return null;
150+
}
151+
146152
if (getInstance(main) != null && getInstance(main).openTelemetry != null) {
147153
return getInstance(main).openTelemetry; // already initialized
148154
}
@@ -151,8 +157,6 @@ private static OpenTelemetry initializeOpenTelemetry(Main main) {
151157
.put(SERVICE_NAME, "supertokens-core")
152158
.build();
153159

154-
String collectorUri = Config.getBaseConfig(main).getOtelCollectorConnectionURI();
155-
156160
SdkTracerProvider sdkTracerProvider =
157161
SdkTracerProvider.builder()
158162
.setResource(resource)

src/main/java/io/supertokens/version/VersionFile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void validate() {
3838
if (core_version == null || plugin_interface_version == null) {
3939
throw new QuitProgramException(
4040
"version.yaml file seems to be corrupted. Please redownload and install SuperTokens from "
41-
+ "https://supertokens.io/dashboard");
41+
+ "https://supertokens.com/");
4242
}
4343
}
4444

0 commit comments

Comments
 (0)