com.rollbar.notifier.provider.server.ServerProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rollbar-java Show documentation
Show all versions of rollbar-java Show documentation
For connecting your applications built on the JVM to Rollbar for Error Reporting
package com.rollbar.notifier.provider.server;
import com.rollbar.api.payload.data.Server;
import com.rollbar.notifier.provider.Provider;
import java.net.InetAddress;
import java.net.UnknownHostException;
/**
* Server provider that populates the server's hostname.
*/
public class ServerProvider implements Provider {
@Override
public Server provide() {
try {
InetAddress host = InetAddress.getLocalHost();
return new Server.Builder()
.host(host.getHostName())
.build();
} catch (UnknownHostException e) {
return new Server.Builder()
.host("localhost")
.build();
}
}
}