diff --git a/.envrc b/.envrc index 97b3f16c6f..f58a7cee60 100644 --- a/.envrc +++ b/.envrc @@ -1,2 +1,3 @@ -export VIRTUAL_ENV=".venv" -layout python3 +export VIRTUAL_ENV="${PWD}/.venv" +devenv sync +PATH_add "${PWD}/.venv/bin" diff --git a/.gitignore b/.gitignore index be4f11ce3d..5f87fdbd5c 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ spring-server.txt spy.log .kotlin **/tomcat.8080/webapps/ +**/__pycache__ diff --git a/.python-version b/.python-version new file mode 100644 index 0000000000..2c20ac9bea --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.13.3 diff --git a/devenv/config.ini b/devenv/config.ini new file mode 100644 index 0000000000..b546b762c0 --- /dev/null +++ b/devenv/config.ini @@ -0,0 +1,16 @@ +[devenv] +minimum_version = 1.22.1 + +[uv] +darwin_arm64 = https://github.com/astral-sh/uv/releases/download/0.8.2/uv-aarch64-apple-darwin.tar.gz +darwin_arm64_sha256 = 954d24634d5f37fa26c7af75eb79893d11623fc81b4de4b82d60d1ade4bfca22 +darwin_x86_64 = https://github.com/astral-sh/uv/releases/download/0.8.2/uv-x86_64-apple-darwin.tar.gz +darwin_x86_64_sha256 = ae755df53c8c2c1f3dfbee6e3d2e00be0dfbc9c9b4bdffdb040b96f43678b7ce +linux_arm64 = https://github.com/astral-sh/uv/releases/download/0.8.2/uv-aarch64-unknown-linux-gnu.tar.gz +linux_arm64_sha256 = 27da35ef54e9131c2e305de67dd59a07c19257882c6b1f3cf4d8d5fbb8eaf4ca +linux_x86_64 = https://github.com/astral-sh/uv/releases/download/0.8.2/uv-x86_64-unknown-linux-gnu.tar.gz +linux_x86_64_sha256 = 6dcb28a541868a455aefb2e8d4a1283dd6bf888605a2db710f0530cec888b0ad +# used for autoupdate +# NOTE: if using uv-build as a build backend, you'll have to make sure the versions match +version = 0.8.2 + diff --git a/devenv/sync.py b/devenv/sync.py new file mode 100644 index 0000000000..45e663cd99 --- /dev/null +++ b/devenv/sync.py @@ -0,0 +1,23 @@ +from devenv import constants +from devenv.lib import config, proc, uv +import os + +def main(context: dict[str, str]) -> int: + reporoot = context["reporoot"] + cfg = config.get_repo(reporoot) + + uv.install( + cfg["uv"]["version"], + cfg["uv"][constants.SYSTEM_MACHINE], + cfg["uv"][f"{constants.SYSTEM_MACHINE}_sha256"], + reporoot, + ) + + # reporoot/.venv is the default venv location + print(f"syncing .venv ...") + if not os.path.exists(".venv"): + proc.run(("uv", "venv", "--seed")) + proc.run(("uv", "sync", "--frozen", "--quiet")) + + return 0 + diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000..55509e3912 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[project] +name = "javasdk" +version = "0.0.0" diff --git a/sentry/src/main/java/io/sentry/SentryClient.java b/sentry/src/main/java/io/sentry/SentryClient.java index e67a6a6aea..f198de5342 100644 --- a/sentry/src/main/java/io/sentry/SentryClient.java +++ b/sentry/src/main/java/io/sentry/SentryClient.java @@ -1657,6 +1657,7 @@ public void close(final boolean isRestarting) { try { flush(isRestarting ? 0 : options.getShutdownTimeoutMillis()); loggerBatchProcessor.close(isRestarting); + metricsBatchProcessor.close(isRestarting); transport.close(isRestarting); } catch (IOException e) { options @@ -1684,6 +1685,7 @@ public void close(final boolean isRestarting) { @Override public void flush(final long timeoutMillis) { loggerBatchProcessor.flush(timeoutMillis); + metricsBatchProcessor.flush(timeoutMillis); transport.flush(timeoutMillis); } diff --git a/sentry/src/test/java/io/sentry/SentryClientTest.kt b/sentry/src/test/java/io/sentry/SentryClientTest.kt index 28d176d85b..ef7c8e7b08 100644 --- a/sentry/src/test/java/io/sentry/SentryClientTest.kt +++ b/sentry/src/test/java/io/sentry/SentryClientTest.kt @@ -14,7 +14,9 @@ import io.sentry.hints.Cached import io.sentry.hints.DiskFlushNotification import io.sentry.hints.TransactionEnd import io.sentry.logger.ILoggerBatchProcessor +import io.sentry.logger.ILoggerBatchProcessorFactory import io.sentry.metrics.IMetricsBatchProcessor +import io.sentry.metrics.IMetricsBatchProcessorFactory import io.sentry.protocol.Contexts import io.sentry.protocol.Feedback import io.sentry.protocol.Mechanism @@ -78,6 +80,10 @@ class SentryClientTest { class Fixture { var transport = mock() var factory = mock() + var loggerBatchProcessor = mock() + var loggerBatchProcessorFactory = mock() + var metricsBatchProcessor = mock() + var metricsBatchProcessorFactory = mock() val maxAttachmentSize: Long = (5 * 1024 * 1024).toLong() val scopes = mock() val sentryTracer: SentryTracer @@ -94,12 +100,16 @@ class SentryClientTest { setLogger(mock()) maxAttachmentSize = this@Fixture.maxAttachmentSize setTransportFactory(factory) + logs.setLoggerBatchProcessorFactory(loggerBatchProcessorFactory) + metrics.setMetricsBatchProcessorFactory(metricsBatchProcessorFactory) release = "0.0.1" isTraceSampling = true } init { whenever(factory.create(any(), any())).thenReturn(transport) + whenever(loggerBatchProcessorFactory.create(any(), any())).thenReturn(loggerBatchProcessor) + whenever(metricsBatchProcessorFactory.create(any(), any())).thenReturn(metricsBatchProcessor) whenever(scopes.options).thenReturn(sentryOptions) sentryTracer = SentryTracer( @@ -168,21 +178,29 @@ class SentryClientTest { @Test fun `when client is closed with isRestarting false, transport waits`() { - val sut = fixture.getSut() + val sut = fixture.getSut { options -> options.logs.isEnabled = true } assertTrue(sut.isEnabled) sut.close(false) assertNotEquals(0, fixture.sentryOptions.shutdownTimeoutMillis) verify(fixture.transport).flush(eq(fixture.sentryOptions.shutdownTimeoutMillis)) + verify(fixture.loggerBatchProcessor).flush(eq(fixture.sentryOptions.shutdownTimeoutMillis)) + verify(fixture.metricsBatchProcessor).flush(eq(fixture.sentryOptions.shutdownTimeoutMillis)) verify(fixture.transport).close(eq(false)) + verify(fixture.loggerBatchProcessor).close(eq(false)) + verify(fixture.metricsBatchProcessor).close(eq(false)) } @Test fun `when client is closed with isRestarting true, transport does not wait`() { - val sut = fixture.getSut() + val sut = fixture.getSut { options -> options.logs.isEnabled = true } assertTrue(sut.isEnabled) sut.close(true) verify(fixture.transport).flush(eq(0)) + verify(fixture.loggerBatchProcessor).flush(eq(0)) + verify(fixture.metricsBatchProcessor).flush(eq(0)) verify(fixture.transport).close(eq(true)) + verify(fixture.loggerBatchProcessor).close(eq(true)) + verify(fixture.metricsBatchProcessor).close(eq(true)) } @Test diff --git a/uv.lock b/uv.lock new file mode 100644 index 0000000000..84b7527660 --- /dev/null +++ b/uv.lock @@ -0,0 +1,8 @@ +version = 1 +revision = 2 +requires-python = ">=3.13" + +[[package]] +name = "javasdk" +version = "0.0.0" +source = { virtual = "." }