private void createMetricSchemaEntity(String metricName, Map event, MetricDescriptor metricDescriptor) throws IOException, EagleServiceClientException { MetricSchemaEntity schemaEntity = new MetricSchemaEntity(); Map<String, String> schemaTags = new HashMap<>(); schemaEntity.setTags(schemaTags); schemaTags.put(MetricSchemaEntity.METRIC_SITE_TAG, metricDescriptor.getSiteIdSelector().getSiteId(event)); schemaTags.put(MetricSchemaEntity.METRIC_NAME_TAG, metricName); schemaTags.put(MetricSchemaEntity.METRIC_GROUP_TAG, metricDescriptor.getMetricGroupSelector().getMetricGroup(event)); schemaEntity.setGranularityByField(metricDescriptor.getGranularity()); schemaEntity.setDimensionFields(metricDescriptor.getDimensionFields()); schemaEntity.setMetricFields(Collections.singletonList(GENERIC_METRIC_VALUE_NAME)); schemaEntity.setModifiedTimestamp(System.currentTimeMillis()); GenericServiceAPIResponseEntity<String> response = this.client.create(Collections.singletonList(schemaEntity)); if (response.isSuccess()) { if (LOG.isDebugEnabled()) { LOG.debug("Created {}", schemaEntity); } } else { LOG.error("Failed to create {}", schemaEntity, response.getException()); throw new IOException("Service error: " + response.getException()); } } }