From 535ab6d9032a42d9c9bfa0c1e5327ba68ca270c7 Mon Sep 17 00:00:00 2001 From: tamassoltesz Date: Tue, 19 Aug 2025 12:00:39 +0200 Subject: [PATCH 1/5] feat: add hikari logs to otel --- CHANGELOG.md | 4 +++ build.gradle | 2 +- .../supertokens/pluginInterface/Storage.java | 3 +- .../opentelemetry/OtelProvider.java | 28 +++++++++++++++++++ 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 src/main/java/io/supertokens/pluginInterface/opentelemetry/OtelProvider.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 7749244d..5b3f7e4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [8.0.3] + +- Adds OpenTelemetry support for the plugin interface + ## [8.0.2] - Adds back `implementationDependencies.json` file, but now it is generated by the build process diff --git a/build.gradle b/build.gradle index 66fa5fa9..5923962e 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ plugins { id 'java-library' } -version = "8.0.2" +version = "8.0.3" repositories { mavenCentral() diff --git a/src/main/java/io/supertokens/pluginInterface/Storage.java b/src/main/java/io/supertokens/pluginInterface/Storage.java index a5adca1d..726832d1 100644 --- a/src/main/java/io/supertokens/pluginInterface/Storage.java +++ b/src/main/java/io/supertokens/pluginInterface/Storage.java @@ -24,6 +24,7 @@ import io.supertokens.pluginInterface.multitenancy.AppIdentifier; import io.supertokens.pluginInterface.multitenancy.TenantIdentifier; import io.supertokens.pluginInterface.multitenancy.exceptions.TenantOrAppNotFoundException; +import io.supertokens.pluginInterface.opentelemetry.OtelProvider; import java.util.List; import java.util.Map; @@ -52,7 +53,7 @@ void loadConfig(JsonObject jsonConfig, Set logLevels, TenantIdentifie // then this function should throw an error since this is a misconfig from ther user's side. void assertThatConfigFromSameUserPoolIsNotConflicting(JsonObject otherConfig) throws InvalidConfigException; - void initFileLogging(String infoLogPath, String errorLogPath); + void initFileLogging(String infoLogPath, String errorLogPath, OtelProvider otelProvider); void stopLogging(); diff --git a/src/main/java/io/supertokens/pluginInterface/opentelemetry/OtelProvider.java b/src/main/java/io/supertokens/pluginInterface/opentelemetry/OtelProvider.java new file mode 100644 index 00000000..c94573ab --- /dev/null +++ b/src/main/java/io/supertokens/pluginInterface/opentelemetry/OtelProvider.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +package io.supertokens.pluginInterface.opentelemetry; + +import io.supertokens.pluginInterface.multitenancy.TenantIdentifier; + +import java.util.Map; + +public interface OtelProvider { + static final String RESOURCE_ID = "io.supertokens.telemetry.TelemetryProvider"; + + public void createLogEvent(TenantIdentifier tenantIdentifier, String logMessage, String logLevel); + public void createLogEvent(TenantIdentifier tenantIdentifier, String logMessage, String logLevel, Map additionalAttributes); +} From ba44909cda9878c3f465a67ab1312be3dc329b6a Mon Sep 17 00:00:00 2001 From: Sattvik Chakravarthy Date: Tue, 26 Aug 2025 12:35:33 +0530 Subject: [PATCH 2/5] Update build.gradle --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 5923962e..eeee1fe1 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ plugins { id 'java-library' } -version = "8.0.3" +version = "8.1.0" repositories { mavenCentral() @@ -27,4 +27,4 @@ tasks.register('copyJars', Copy) { test { systemProperty 'noSetup', System.getProperty('noSetup') -} \ No newline at end of file +} From f218af8581c983bcc8897faf8437750b684562bd Mon Sep 17 00:00:00 2001 From: tamassoltesz Date: Tue, 26 Aug 2025 09:40:05 +0200 Subject: [PATCH 3/5] chore: update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b3f7e4f..d2cb0c5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] -## [8.0.3] +## [8.1.0] - Adds OpenTelemetry support for the plugin interface From 2561a2f077cc0ba7bf772135b378c8d92507c77c Mon Sep 17 00:00:00 2001 From: tamassoltesz Date: Wed, 27 Aug 2025 16:55:31 +0200 Subject: [PATCH 4/5] feat: otel extension --- .../opentelemetry/OtelProvider.java | 7 ++++++ .../opentelemetry/RunnableWithOtel.java | 23 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/main/java/io/supertokens/pluginInterface/opentelemetry/RunnableWithOtel.java diff --git a/src/main/java/io/supertokens/pluginInterface/opentelemetry/OtelProvider.java b/src/main/java/io/supertokens/pluginInterface/opentelemetry/OtelProvider.java index c94573ab..b9fefdd0 100644 --- a/src/main/java/io/supertokens/pluginInterface/opentelemetry/OtelProvider.java +++ b/src/main/java/io/supertokens/pluginInterface/opentelemetry/OtelProvider.java @@ -25,4 +25,11 @@ public interface OtelProvider { public void createLogEvent(TenantIdentifier tenantIdentifier, String logMessage, String logLevel); public void createLogEvent(TenantIdentifier tenantIdentifier, String logMessage, String logLevel, Map additionalAttributes); + + public T wrapInSpanWithReturn(TenantIdentifier tenantIdentifier, String spanName, + Map additionalAttributes, RunnableWithOtel runWithOtel); + + public void createSpanWithAttributes(TenantIdentifier tenantIdentifier, String spanName, + Map additionalAttributes); + } diff --git a/src/main/java/io/supertokens/pluginInterface/opentelemetry/RunnableWithOtel.java b/src/main/java/io/supertokens/pluginInterface/opentelemetry/RunnableWithOtel.java new file mode 100644 index 00000000..71c8be89 --- /dev/null +++ b/src/main/java/io/supertokens/pluginInterface/opentelemetry/RunnableWithOtel.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2025, VRAI Labs and/or its affiliates. All rights reserved. + * + * This software is licensed under the Apache License, Version 2.0 (the + * "License") as published by the Apache Software Foundation. + * + * You may not use this file except in compliance with the License. You may + * obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +package io.supertokens.pluginInterface.opentelemetry; + +@FunctionalInterface +public interface RunnableWithOtel { + + T runWithReturnValue(); +} From bcec68693690cd2ad8341aaffcff9ccff473fa58 Mon Sep 17 00:00:00 2001 From: tamassoltesz Date: Fri, 29 Aug 2025 15:41:48 +0200 Subject: [PATCH 5/5] feat: changing exception handling --- .../supertokens/pluginInterface/opentelemetry/OtelProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/supertokens/pluginInterface/opentelemetry/OtelProvider.java b/src/main/java/io/supertokens/pluginInterface/opentelemetry/OtelProvider.java index b9fefdd0..a4a0386c 100644 --- a/src/main/java/io/supertokens/pluginInterface/opentelemetry/OtelProvider.java +++ b/src/main/java/io/supertokens/pluginInterface/opentelemetry/OtelProvider.java @@ -28,7 +28,7 @@ public interface OtelProvider { public T wrapInSpanWithReturn(TenantIdentifier tenantIdentifier, String spanName, Map additionalAttributes, RunnableWithOtel runWithOtel); - + public void createSpanWithAttributes(TenantIdentifier tenantIdentifier, String spanName, Map additionalAttributes);