Skip to content

Commit bea07c7

Browse files
authored
Merge pull request #5009 from getsentry/01-08-use_uv_for_managing_python_version
Use uv for managing python version
2 parents 82249fc + 7f42e1f commit bea07c7

File tree

9 files changed

+77
-4
lines changed

9 files changed

+77
-4
lines changed

.envrc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
export VIRTUAL_ENV=".venv"
2-
layout python3
1+
export VIRTUAL_ENV="${PWD}/.venv"
2+
devenv sync
3+
PATH_add "${PWD}/.venv/bin"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ spring-server.txt
2727
spy.log
2828
.kotlin
2929
**/tomcat.8080/webapps/
30+
**/__pycache__

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.13.3

devenv/config.ini

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[devenv]
2+
minimum_version = 1.22.1
3+
4+
[uv]
5+
darwin_arm64 = https://github.com/astral-sh/uv/releases/download/0.8.2/uv-aarch64-apple-darwin.tar.gz
6+
darwin_arm64_sha256 = 954d24634d5f37fa26c7af75eb79893d11623fc81b4de4b82d60d1ade4bfca22
7+
darwin_x86_64 = https://github.com/astral-sh/uv/releases/download/0.8.2/uv-x86_64-apple-darwin.tar.gz
8+
darwin_x86_64_sha256 = ae755df53c8c2c1f3dfbee6e3d2e00be0dfbc9c9b4bdffdb040b96f43678b7ce
9+
linux_arm64 = https://github.com/astral-sh/uv/releases/download/0.8.2/uv-aarch64-unknown-linux-gnu.tar.gz
10+
linux_arm64_sha256 = 27da35ef54e9131c2e305de67dd59a07c19257882c6b1f3cf4d8d5fbb8eaf4ca
11+
linux_x86_64 = https://github.com/astral-sh/uv/releases/download/0.8.2/uv-x86_64-unknown-linux-gnu.tar.gz
12+
linux_x86_64_sha256 = 6dcb28a541868a455aefb2e8d4a1283dd6bf888605a2db710f0530cec888b0ad
13+
# used for autoupdate
14+
# NOTE: if using uv-build as a build backend, you'll have to make sure the versions match
15+
version = 0.8.2
16+

devenv/sync.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from devenv import constants
2+
from devenv.lib import config, proc, uv
3+
import os
4+
5+
def main(context: dict[str, str]) -> int:
6+
reporoot = context["reporoot"]
7+
cfg = config.get_repo(reporoot)
8+
9+
uv.install(
10+
cfg["uv"]["version"],
11+
cfg["uv"][constants.SYSTEM_MACHINE],
12+
cfg["uv"][f"{constants.SYSTEM_MACHINE}_sha256"],
13+
reporoot,
14+
)
15+
16+
# reporoot/.venv is the default venv location
17+
print(f"syncing .venv ...")
18+
if not os.path.exists(".venv"):
19+
proc.run(("uv", "venv", "--seed"))
20+
proc.run(("uv", "sync", "--frozen", "--quiet"))
21+
22+
return 0
23+

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[project]
2+
name = "javasdk"
3+
version = "0.0.0"

sentry/src/main/java/io/sentry/SentryClient.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,6 +1657,7 @@ public void close(final boolean isRestarting) {
16571657
try {
16581658
flush(isRestarting ? 0 : options.getShutdownTimeoutMillis());
16591659
loggerBatchProcessor.close(isRestarting);
1660+
metricsBatchProcessor.close(isRestarting);
16601661
transport.close(isRestarting);
16611662
} catch (IOException e) {
16621663
options
@@ -1684,6 +1685,7 @@ public void close(final boolean isRestarting) {
16841685
@Override
16851686
public void flush(final long timeoutMillis) {
16861687
loggerBatchProcessor.flush(timeoutMillis);
1688+
metricsBatchProcessor.flush(timeoutMillis);
16871689
transport.flush(timeoutMillis);
16881690
}
16891691

sentry/src/test/java/io/sentry/SentryClientTest.kt

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ import io.sentry.hints.Cached
1414
import io.sentry.hints.DiskFlushNotification
1515
import io.sentry.hints.TransactionEnd
1616
import io.sentry.logger.ILoggerBatchProcessor
17+
import io.sentry.logger.ILoggerBatchProcessorFactory
1718
import io.sentry.metrics.IMetricsBatchProcessor
19+
import io.sentry.metrics.IMetricsBatchProcessorFactory
1820
import io.sentry.protocol.Contexts
1921
import io.sentry.protocol.Feedback
2022
import io.sentry.protocol.Mechanism
@@ -78,6 +80,10 @@ class SentryClientTest {
7880
class Fixture {
7981
var transport = mock<ITransport>()
8082
var factory = mock<ITransportFactory>()
83+
var loggerBatchProcessor = mock<ILoggerBatchProcessor>()
84+
var loggerBatchProcessorFactory = mock<ILoggerBatchProcessorFactory>()
85+
var metricsBatchProcessor = mock<IMetricsBatchProcessor>()
86+
var metricsBatchProcessorFactory = mock<IMetricsBatchProcessorFactory>()
8187
val maxAttachmentSize: Long = (5 * 1024 * 1024).toLong()
8288
val scopes = mock<IScopes>()
8389
val sentryTracer: SentryTracer
@@ -94,12 +100,16 @@ class SentryClientTest {
94100
setLogger(mock())
95101
maxAttachmentSize = this@Fixture.maxAttachmentSize
96102
setTransportFactory(factory)
103+
logs.setLoggerBatchProcessorFactory(loggerBatchProcessorFactory)
104+
metrics.setMetricsBatchProcessorFactory(metricsBatchProcessorFactory)
97105
release = "0.0.1"
98106
isTraceSampling = true
99107
}
100108

101109
init {
102110
whenever(factory.create(any(), any())).thenReturn(transport)
111+
whenever(loggerBatchProcessorFactory.create(any(), any())).thenReturn(loggerBatchProcessor)
112+
whenever(metricsBatchProcessorFactory.create(any(), any())).thenReturn(metricsBatchProcessor)
103113
whenever(scopes.options).thenReturn(sentryOptions)
104114
sentryTracer =
105115
SentryTracer(
@@ -168,21 +178,29 @@ class SentryClientTest {
168178

169179
@Test
170180
fun `when client is closed with isRestarting false, transport waits`() {
171-
val sut = fixture.getSut()
181+
val sut = fixture.getSut { options -> options.logs.isEnabled = true }
172182
assertTrue(sut.isEnabled)
173183
sut.close(false)
174184
assertNotEquals(0, fixture.sentryOptions.shutdownTimeoutMillis)
175185
verify(fixture.transport).flush(eq(fixture.sentryOptions.shutdownTimeoutMillis))
186+
verify(fixture.loggerBatchProcessor).flush(eq(fixture.sentryOptions.shutdownTimeoutMillis))
187+
verify(fixture.metricsBatchProcessor).flush(eq(fixture.sentryOptions.shutdownTimeoutMillis))
176188
verify(fixture.transport).close(eq(false))
189+
verify(fixture.loggerBatchProcessor).close(eq(false))
190+
verify(fixture.metricsBatchProcessor).close(eq(false))
177191
}
178192

179193
@Test
180194
fun `when client is closed with isRestarting true, transport does not wait`() {
181-
val sut = fixture.getSut()
195+
val sut = fixture.getSut { options -> options.logs.isEnabled = true }
182196
assertTrue(sut.isEnabled)
183197
sut.close(true)
184198
verify(fixture.transport).flush(eq(0))
199+
verify(fixture.loggerBatchProcessor).flush(eq(0))
200+
verify(fixture.metricsBatchProcessor).flush(eq(0))
185201
verify(fixture.transport).close(eq(true))
202+
verify(fixture.loggerBatchProcessor).close(eq(true))
203+
verify(fixture.metricsBatchProcessor).close(eq(true))
186204
}
187205

188206
@Test

uv.lock

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)