cole-bq commented on code in PR #1838: URL: https://github.com/apache/tinkerpop/pull/1838#discussion_r1029968748
########## gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/util/UserAgent.java: ########## @@ -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. + */ +package org.apache.tinkerpop.gremlin.driver.util; + +import org.apache.tinkerpop.gremlin.util.Gremlin; +import javax.naming.NamingException; + +public class UserAgent { + + /** + * Request header name for user agent + */ + public static final String USER_AGENT_HEADER_NAME = "User-Agent"; + /** + * User Agent body to be sent in web socket handshake + * Has the form of: + * [Application Name] [GLV Name]/[Version] [Language Runtime Version] [OS]/[Version] [CPU Architecture] + */ + public static final String WS_HANDSHAKE_USER_AGENT; + + static { + String applicationName = ""; + try { + applicationName = ((String)(new javax.naming.InitialContext().lookup("java:app/AppName"))).replace(' ', '_'); + } catch (NamingException e) { + applicationName = "NotAvailable"; + }; + + final String glvVersion = Gremlin.version().replace(' ', '_'); + final String javaVersion = System.getProperty("java.version", "NotAvailable").replace(' ', '_'); Review Comment: While implementing this change I didn't have any intentions of making the user agent customizable. It is true that the user agent being constructed from system properties means that they can be overridden in maven with `-D` but this override only applies to that single execution. I'm not sure of any specific use cases for this behavior and such I'm not sure where it should be documented. I was wondering if you have anywhere in mind where it would be convenient, I don't want to dump extra information in places where it is not useful. Thanks. -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
