[ https://issues.apache.org/jira/browse/SCB-85?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16312390#comment-16312390 ]
ASF GitHub Bot commented on SCB-85: ----------------------------------- WillemJiang commented on a change in pull request #476: [SCB-85] Upgrade Metrics File Output from 0.5.0 to 1.0.0-m1 URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/476#discussion_r159589006 ########## File path: metrics/metrics-extension/metrics-write-file/src/main/java/io/servicecomb/metrics/extension/writefile/SimpleFileContentFormatter.java ########## @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.servicecomb.metrics.extension.writefile; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.stream.Collectors; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; + +import com.fasterxml.jackson.core.JsonProcessingException; + +import io.servicecomb.foundation.common.net.NetUtils; +import io.servicecomb.foundation.common.utils.JsonUtils; +import io.servicecomb.serviceregistry.RegistryUtils; +import io.servicecomb.serviceregistry.api.registry.Microservice; + +@Component +public class SimpleFileContentFormatter implements FileContentFormatter { + private static final Logger logger = LoggerFactory.getLogger(SimpleFileContentFormatter.class); + + private final String applicationName; + + private String hostName; + + @Autowired + public SimpleFileContentFormatter() { + hostName = NetUtils.getHostName(); + if (StringUtils.isEmpty(hostName)) { + hostName = NetUtils.getHostAddress(); + } + + //may any problem ? + if (RegistryUtils.getServiceRegistry() == null) { Review comment: In this case we just throw the exception to let the user find out the reason. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Upgrade Metrics File Output from 0.5.0 to 1.0.0-m1 > -------------------------------------------------- > > Key: SCB-85 > URL: https://issues.apache.org/jira/browse/SCB-85 > Project: Apache ServiceComb > Issue Type: Sub-task > Components: Java-Chassis > Reporter: yangyongzheng > Assignee: yangyongzheng > Fix For: java-chassis-1.0.0-m1 > > > Because metrics had complete reflected in 1.0.0-m1,so we need upgrade file > output example and show new features. > 1.support more build-in metric > 2.support output operation level metric -- This message was sent by Atlassian JIRA (v6.4.14#64029)