Skip to content

Commit b15d400

Browse files
authored
Merge pull request #3417 from 1c-syntax/feature/hash-server-name
Хэширование имени хоста и отправка в Sentry, фильтрация стак трейса по принадлежности к приложению
2 parents de6cea6 + 66e0891 commit b15d400

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/sentry/SentryScopeConfigurer.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,15 @@
2424
import io.sentry.IScope;
2525
import io.sentry.Sentry;
2626
import io.sentry.protocol.User;
27+
import jakarta.annotation.Nullable;
2728
import jakarta.annotation.PostConstruct;
2829
import lombok.RequiredArgsConstructor;
2930
import org.eclipse.lsp4j.ServerInfo;
3031
import org.springframework.beans.factory.annotation.Value;
3132
import org.springframework.stereotype.Component;
3233

34+
import java.net.InetAddress;
35+
import java.net.UnknownHostException;
3336
import java.util.UUID;
3437

3538
/**
@@ -57,9 +60,10 @@ public void init() {
5760
options.setDsn(dsn);
5861
options.setEnvironment(environment);
5962
options.setRelease(serverInfo.getVersion());
60-
options.setTag("server.version", serverInfo.getVersion());
6163
options.setAttachServerName(false);
64+
options.setServerName(getServerName());
6265
options.setBeforeSend(beforeSendCallback);
66+
options.addInAppInclude("com.github._1c_syntax.bsl.languageserver");
6367
});
6468
}
6569

@@ -70,4 +74,15 @@ public void init() {
7074
});
7175
}
7276

77+
@Nullable
78+
private String getServerName() {
79+
try {
80+
String hostName = InetAddress.getLocalHost().getHostName();
81+
return UUID.nameUUIDFromBytes(hostName.getBytes()).toString();
82+
} catch (UnknownHostException e) {
83+
// ignore
84+
return null;
85+
}
86+
}
87+
7388
}

0 commit comments

Comments
 (0)