Skip to content

Commit

Permalink
Merge pull request #3417 from 1c-syntax/feature/hash-server-name
Browse files Browse the repository at this point in the history
Хэширование имени хоста и отправка в Sentry, фильтрация стак трейса по принадлежности к приложению
  • Loading branch information
nixel2007 authored Feb 12, 2025
2 parents de6cea6 + 66e0891 commit b15d400
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@
import io.sentry.IScope;
import io.sentry.Sentry;
import io.sentry.protocol.User;
import jakarta.annotation.Nullable;
import jakarta.annotation.PostConstruct;
import lombok.RequiredArgsConstructor;
import org.eclipse.lsp4j.ServerInfo;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.UUID;

/**
Expand Down Expand Up @@ -57,9 +60,10 @@ public void init() {
options.setDsn(dsn);
options.setEnvironment(environment);
options.setRelease(serverInfo.getVersion());
options.setTag("server.version", serverInfo.getVersion());
options.setAttachServerName(false);
options.setServerName(getServerName());
options.setBeforeSend(beforeSendCallback);
options.addInAppInclude("com.github._1c_syntax.bsl.languageserver");
});
}

Expand All @@ -70,4 +74,15 @@ public void init() {
});
}

@Nullable
private String getServerName() {
try {
String hostName = InetAddress.getLocalHost().getHostName();
return UUID.nameUUIDFromBytes(hostName.getBytes()).toString();
} catch (UnknownHostException e) {
// ignore
return null;
}
}

}

0 comments on commit b15d400

Please sign in to comment.