class OsResource extends ResourceProvider {

  @Override
  protected Attributes getAttributes() {
    final String os;
    try {
      os = System.getProperty("os.name");
    } catch (SecurityException t) {
      // Security manager enabled, can't provide much os information.
      return Attributes.empty();
    }

    if (os == null) {
      return Attributes.empty();
    }

    Attributes.Builder attributes = Attributes.newBuilder();

    String osName = getOs(os);
    if (osName != null) {
      attributes.setAttribute(ResourceAttributes.OS_NAME, osName);
    }

    String version = null;
    try {
      version = System.getProperty("os.version");
    } catch (SecurityException e) {
      // Ignore
    }
    String osDescription = version != null ? os + ' ' + version : os;
    attributes.setAttribute(ResourceAttributes.OS_DESCRIPTION, osDescription);

    return attributes.build();
  }

}