wu-sheng commented on a change in pull request #6: Feat: add performance data URL: https://github.com/apache/skywalking-client-js/pull/6#discussion_r376933920
########## File path: src/performance/index.ts ########## @@ -0,0 +1,55 @@ + +/** + * 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. + */ + +import { CustomPerfOptionsType } from '../types'; +import Report from '../services/report'; +import pagePerf from './perf'; + +class TracePerf { + private isPerf: boolean = true; + private perfConfig = { + resources: [], + perfDetail: {}, + } as any; + + public recordPerf(options: CustomPerfOptionsType) { + if (this.isPerf) { + this.perfConfig.performance = pagePerf.getPerfTiming(); + } + const perfInfo = { + perfDetail: this.perfConfig.perfDetail, + resources: this.perfConfig.resources, + ...options, + }; + new Report(options.reportUrl).sendByXhr(perfInfo); + this.clearPerf(); Review comment: No, those two parameters are required, that is why I asked. 1. Version could be set as `-` by default, if the client-js doesn't set it, but this must notify the backend implementation. 1. Service Name is not existing in the protocol, only service ID, which means you have registered successfully. Do you want to add a name to the protocol as an alternative way? My point is, this register would take time, you should have a buffer to hold this value until the register is done. Unless you should add name and version strings into the protocol. Also, you should know, the ID is required in the distributed tracing too. Even you add name and version in this protocol, you can't add those in the tracing protocol, the buffer mechanism is still required. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
