@@ -87,6 +87,11 @@ public class Configuration
8787 /// </summary>
8888 public const string JaegerSamplerManagerHostPort = JaegerPrefix + "SAMPLER_MANAGER_HOST_PORT" ;
8989
90+ /// <summary>
91+ /// The url for the remote sampling conf when using sampler type remote.
92+ /// </summary>
93+ public const string JaegerSamplingEndpoint = JaegerPrefix + "SAMPLING_ENDPOINT" ;
94+
9095 /// <summary>
9196 /// The service name.
9297 /// </summary>
@@ -161,7 +166,7 @@ public static Configuration FromIConfiguration(ILoggerFactory loggerFactory, ICo
161166 {
162167 ILogger logger = loggerFactory . CreateLogger < Configuration > ( ) ;
163168
164- return new Configuration ( GetProperty ( JaegerServiceName , configuration ) , loggerFactory )
169+ return new Configuration ( GetProperty ( JaegerServiceName , logger , configuration ) , loggerFactory )
165170 . WithTracerTags ( TracerTagsFromIConfiguration ( logger , configuration ) )
166171 . WithTraceId128Bit ( GetPropertyAsBool ( JaegerTraceId128Bit , logger , configuration ) . GetValueOrDefault ( false ) )
167172 . WithReporter ( ReporterConfiguration . FromIConfiguration ( loggerFactory , configuration ) )
@@ -312,10 +317,16 @@ public class SamplerConfiguration
312317
313318 /// <summary>
314319 /// HTTP host:port of the sampling manager that can provide sampling strategy to this service.
315- /// Optional.
316320 /// </summary>
321+ [ Obsolete ( "Please use SamplingEndpoint instead!" ) ]
317322 public string ManagerHostPort { get ; private set ; }
318323
324+ /// <summary>
325+ /// The URL of the sampling manager that can provide sampling strategy to this service.
326+ /// Optional.
327+ /// </summary>
328+ public string SamplingEndpoint { get ; private set ; }
329+
319330 public SamplerConfiguration ( ILoggerFactory loggerFactory )
320331 {
321332 _loggerFactory = loggerFactory ;
@@ -327,11 +338,14 @@ public SamplerConfiguration(ILoggerFactory loggerFactory)
327338 public static SamplerConfiguration FromIConfiguration ( ILoggerFactory loggerFactory , IConfiguration configuration )
328339 {
329340 ILogger logger = loggerFactory . CreateLogger < Configuration > ( ) ;
330-
341+
342+ #pragma warning disable CS0618 // Supress warning on obsolete method: WithManagerHostPort
331343 return new SamplerConfiguration ( loggerFactory )
332- . WithType ( GetProperty ( JaegerSamplerType , configuration ) )
344+ . WithType ( GetProperty ( JaegerSamplerType , logger , configuration ) )
333345 . WithParam ( GetPropertyAsDouble ( JaegerSamplerParam , logger , configuration ) )
334- . WithManagerHostPort ( GetProperty ( JaegerSamplerManagerHostPort , configuration ) ) ;
346+ . WithManagerHostPort ( GetProperty ( JaegerSamplerManagerHostPort , logger , configuration , JaegerSamplingEndpoint ) )
347+ . WithSamplingEndpoint ( GetProperty ( JaegerSamplingEndpoint , logger , configuration ) ) ;
348+ #pragma warning restore CS0618 // Supress warning on obsolete method: WithManagerHostPort
335349 }
336350
337351 /// <summary>
@@ -347,9 +361,12 @@ public static SamplerConfiguration FromEnv(ILoggerFactory loggerFactory)
347361
348362 public virtual ISampler GetSampler ( string serviceName , IMetrics metrics )
349363 {
364+ #pragma warning disable CS0618 // Supress warning on obsolete property: ManagerHostPort
350365 string samplerType = StringOrDefault ( Type , RemoteControlledSampler . Type ) ;
351366 double samplerParam = Param . GetValueOrDefault ( ProbabilisticSampler . DefaultSamplingProbability ) ;
352367 string hostPort = StringOrDefault ( ManagerHostPort , HttpSamplingManager . DefaultHostPort ) ;
368+ string samplingEndpoint = StringOrDefault ( SamplingEndpoint , "http://" + hostPort ) ;
369+ #pragma warning disable CS0618 // Supress warning on obsolete property: ManagerHostPort
353370
354371 switch ( samplerType )
355372 {
@@ -362,7 +379,7 @@ public virtual ISampler GetSampler(string serviceName, IMetrics metrics)
362379 case RemoteControlledSampler . Type :
363380 return new RemoteControlledSampler . Builder ( serviceName )
364381 . WithLoggerFactory ( _loggerFactory )
365- . WithSamplingManager ( new HttpSamplingManager ( hostPort ) )
382+ . WithSamplingManager ( new HttpSamplingManager ( samplingEndpoint ) )
366383 . WithInitialSampler ( new ProbabilisticSampler ( samplerParam ) )
367384 . WithMetrics ( metrics )
368385 . Build ( ) ;
@@ -383,11 +400,18 @@ public SamplerConfiguration WithParam(double? param)
383400 return this ;
384401 }
385402
403+ [ Obsolete ( "Use WithSamplingEndpoint instead!" ) ]
386404 public SamplerConfiguration WithManagerHostPort ( string managerHostPort )
387405 {
388406 ManagerHostPort = managerHostPort ;
389407 return this ;
390408 }
409+
410+ public SamplerConfiguration WithSamplingEndpoint ( string samplingEndpoint )
411+ {
412+ SamplingEndpoint = samplingEndpoint ;
413+ return this ;
414+ }
391415 }
392416
393417 /// <summary>
@@ -412,7 +436,7 @@ public static CodecConfiguration FromIConfiguration(ILoggerFactory loggerFactory
412436 ILogger logger = loggerFactory . CreateLogger < Configuration > ( ) ;
413437
414438 CodecConfiguration codecConfiguration = new CodecConfiguration ( loggerFactory ) ;
415- string propagation = GetProperty ( JaegerPropagation , configuration ) ;
439+ string propagation = GetProperty ( JaegerPropagation , logger , configuration ) ;
416440 if ( propagation != null )
417441 {
418442 foreach ( string format in propagation . Split ( ',' ) )
@@ -706,13 +730,13 @@ public static SenderConfiguration FromIConfiguration(ILoggerFactory loggerFactor
706730 {
707731 ILogger logger = loggerFactory . CreateLogger < Configuration > ( ) ;
708732
709- string agentHost = GetProperty ( JaegerAgentHost , configuration ) ;
733+ string agentHost = GetProperty ( JaegerAgentHost , logger , configuration ) ;
710734 int ? agentPort = GetPropertyAsInt ( JaegerAgentPort , logger , configuration ) ;
711735
712- string collectorEndpoint = GetProperty ( JaegerEndpoint , configuration ) ;
713- string authToken = GetProperty ( JaegerAuthToken , configuration ) ;
714- string authUsername = GetProperty ( JaegerUser , configuration ) ;
715- string authPassword = GetProperty ( JaegerPassword , configuration ) ;
736+ string collectorEndpoint = GetProperty ( JaegerEndpoint , logger , configuration ) ;
737+ string authToken = GetProperty ( JaegerAuthToken , logger , configuration ) ;
738+ string authUsername = GetProperty ( JaegerUser , logger , configuration ) ;
739+ string authPassword = GetProperty ( JaegerPassword , logger , configuration ) ;
716740
717741 return new SenderConfiguration ( loggerFactory )
718742 . WithAgentHost ( agentHost )
@@ -740,14 +764,20 @@ private static string StringOrDefault(string value, string defaultValue)
740764 return value != null && value . Length > 0 ? value : defaultValue ;
741765 }
742766
743- private static string GetProperty ( string name , IConfiguration configuration )
767+ private static string GetProperty ( string name , ILogger logger , IConfiguration configuration , string replacedBy = null )
744768 {
745- return configuration [ name ] ;
769+ var value = configuration [ name ] ;
770+ if ( replacedBy != null && value != null )
771+ {
772+ logger . LogWarning ( $ "The entry { name } is obsolete. Use { replacedBy } instead!") ;
773+ }
774+
775+ return value ;
746776 }
747777
748778 private static int ? GetPropertyAsInt ( string name , ILogger logger , IConfiguration configuration )
749779 {
750- string value = GetProperty ( name , configuration ) ;
780+ string value = GetProperty ( name , logger , configuration ) ;
751781 if ( ! string . IsNullOrEmpty ( value ) )
752782 {
753783 if ( int . TryParse ( value , NumberStyles . Integer , CultureInfo . InvariantCulture , out int intValue ) )
@@ -764,7 +794,7 @@ private static string GetProperty(string name, IConfiguration configuration)
764794
765795 private static double ? GetPropertyAsDouble ( string name , ILogger logger , IConfiguration configuration )
766796 {
767- string value = GetProperty ( name , configuration ) ;
797+ string value = GetProperty ( name , logger , configuration ) ;
768798 if ( ! string . IsNullOrEmpty ( value ) )
769799 {
770800 if ( double . TryParse ( value , NumberStyles . Float , CultureInfo . InvariantCulture , out double doubleValue ) )
@@ -795,7 +825,7 @@ private static string GetProperty(string name, IConfiguration configuration)
795825 /// </summary>
796826 private static bool ? GetPropertyAsBool ( string name , ILogger logger , IConfiguration configuration )
797827 {
798- string value = GetProperty ( name , configuration ) ;
828+ string value = GetProperty ( name , logger , configuration ) ;
799829 if ( ! string . IsNullOrEmpty ( value ) )
800830 {
801831 if ( string . Equals ( value , "1" , StringComparison . Ordinal ) )
@@ -822,7 +852,7 @@ private static string GetProperty(string name, IConfiguration configuration)
822852 private static Dictionary < string , string > TracerTagsFromIConfiguration ( ILogger logger , IConfiguration configuration )
823853 {
824854 Dictionary < string , string > tracerTagMaps = null ;
825- string tracerTags = GetProperty ( JaegerTags , configuration ) ;
855+ string tracerTags = GetProperty ( JaegerTags , logger , configuration ) ;
826856 if ( ! string . IsNullOrEmpty ( tracerTags ) )
827857 {
828858 string [ ] tags = tracerTags . Split ( ',' ) ;
@@ -835,7 +865,7 @@ private static Dictionary<string, string> TracerTagsFromIConfiguration(ILogger l
835865 {
836866 tracerTagMaps = new Dictionary < string , string > ( ) ;
837867 }
838- tracerTagMaps [ tagValue [ 0 ] . Trim ( ) ] = ResolveValue ( tagValue [ 1 ] . Trim ( ) , configuration ) ;
868+ tracerTagMaps [ tagValue [ 0 ] . Trim ( ) ] = ResolveValue ( tagValue [ 1 ] . Trim ( ) , logger , configuration ) ;
839869 }
840870 else
841871 {
@@ -846,14 +876,14 @@ private static Dictionary<string, string> TracerTagsFromIConfiguration(ILogger l
846876 return tracerTagMaps ;
847877 }
848878
849- private static string ResolveValue ( string value , IConfiguration configuration )
879+ private static string ResolveValue ( string value , ILogger logger , IConfiguration configuration )
850880 {
851881 if ( value . StartsWith ( "${" ) && value . EndsWith ( "}" ) )
852882 {
853883 string [ ] kvp = value . Substring ( 2 , value . Length - 3 ) . Split ( ':' ) ;
854884 if ( kvp . Length > 0 )
855885 {
856- string propertyValue = GetProperty ( kvp [ 0 ] . Trim ( ) , configuration ) ;
886+ string propertyValue = GetProperty ( kvp [ 0 ] . Trim ( ) , logger , configuration ) ;
857887 if ( propertyValue == null && kvp . Length > 1 )
858888 {
859889 propertyValue = kvp [ 1 ] . Trim ( ) ;
0 commit comments