code: public final MetricDescriptor createMetricDescriptor(
        String name, MetricDescriptor metricDescriptor) {
  
      CreateMetricDescriptorRequest request =
          CreateMetricDescriptorRequest.newBuilder()
              .setName(name)
              .setMetricDescriptor(metricDescriptor)
              .build();
      return createMetricDescriptor(request);
    }
docs: Creates a new metric descriptor. User-created metric descriptors define [custom
  metrics](/monitoring/custom-metrics).
  
  <p>Sample code:
  
  <pre><code>
  try (MetricServiceClient metricServiceClient = MetricServiceClient.create()) {
  ProjectName name = ProjectName.of("[PROJECT]");
  MetricDescriptor metricDescriptor = MetricDescriptor.newBuilder().build();
  MetricDescriptor response = metricServiceClient.createMetricDescriptor(name.toString(), metricDescriptor);
  }
  </code></pre>
  
  @param name The project on which to execute the request. The format is
  `"projects/{project_id_or_number}"`.
  @param metricDescriptor The new [custom metric](/monitoring/custom-metrics) descriptor.
  @throws com.google.api.gax.rpc.ApiException if the remote call fails