/// <exception cref="System.IO.IOException"/> private int AddSpanReceiver(IList <string> args) { string className = StringUtils.PopOptionWithArgument("-class", args); if (className == null) { System.Console.Error.WriteLine("You must specify the classname with -class."); return(1); } ByteArrayOutputStream configStream = new ByteArrayOutputStream(); TextWriter configsOut = new TextWriter(configStream, false, "UTF-8"); SpanReceiverInfoBuilder factory = new SpanReceiverInfoBuilder(className); string prefix = string.Empty; for (int i = 0; i < args.Count; ++i) { string str = args[i]; if (!str.StartsWith(ConfigPrefix)) { System.Console.Error.WriteLine("Can't understand argument: " + str); return(1); } str = Runtime.Substring(str, ConfigPrefix.Length); int equalsIndex = str.IndexOf("="); if (equalsIndex < 0) { System.Console.Error.WriteLine("Can't parse configuration argument " + str); System.Console.Error.WriteLine("Arguments must be in the form key=value"); return(1); } string key = Runtime.Substring(str, 0, equalsIndex); string value = Runtime.Substring(str, equalsIndex + 1); factory.AddConfigurationPair(key, value); configsOut.Write(prefix + key + " = " + value); prefix = ", "; } string configStreamStr = configStream.ToString("UTF-8"); try { long id = remote.AddSpanReceiver(factory.Build()); System.Console.Out.WriteLine("Added trace span receiver " + id + " with configuration " + configStreamStr); } catch (IOException e) { System.Console.Out.WriteLine("addSpanReceiver error with configuration " + configStreamStr ); throw; } return(0); }
/// <exception cref="Com.Google.Protobuf.ServiceException"/> public virtual TraceAdminPB.AddSpanReceiverResponseProto AddSpanReceiver(RpcController controller, TraceAdminPB.AddSpanReceiverRequestProto req) { try { SpanReceiverInfoBuilder factory = new SpanReceiverInfoBuilder(req.GetClassName()); foreach (TraceAdminPB.ConfigPair config in req.GetConfigList()) { factory.AddConfigurationPair(config.GetKey(), config.GetValue()); } long id = server.AddSpanReceiver(factory.Build()); return((TraceAdminPB.AddSpanReceiverResponseProto)TraceAdminPB.AddSpanReceiverResponseProto .NewBuilder().SetId(id).Build()); } catch (IOException e) { throw new ServiceException(e); } }