@@ -40,7 +40,7 @@ public Tracer GetTracer(
4040#endif
4141 string name ,
4242 string ? version ) =>
43- this . GetTracer ( name , version , null ) ;
43+ this . GetTracer ( name , version , null , null ) ;
4444
4545 /// <summary>
4646 /// Gets a tracer with given name, version and tags.
@@ -49,12 +49,35 @@ public Tracer GetTracer(
4949 /// <param name="version">Version of the instrumentation library.</param>
5050 /// <param name="tags">Tags associated with the tracer.</param>
5151 /// <returns>Tracer instance.</returns>
52+ // 1.14.0 BACKCOMPAT OVERLOAD -- DO NOT TOUCH
53+ public Tracer GetTracer (
54+ #if NET
55+ [ AllowNull ]
56+ #endif
57+ string name ,
58+ string ? version ,
59+ IEnumerable < KeyValuePair < string , object ? > > ? tags )
60+ {
61+ return this . GetTracer ( name , version , null , tags ) ;
62+ }
63+
64+ /// <summary>
65+ /// Gets a tracer with given name, version and tags.
66+ /// </summary>
67+ /// <param name="name">Name identifying the instrumentation library.</param>
68+ /// <param name="version">Version of the instrumentation library.</param>
69+ /// <param name="schemaUrl">Schema URL associated with the tracer.</param>
70+ /// <param name="tags">Tags associated with the tracer.</param>
71+ /// <returns>Tracer instance.</returns>
5272 public Tracer GetTracer (
5373#if NET
5474 [ AllowNull ]
5575#endif
5676 string name ,
5777 string ? version = null ,
78+ #pragma warning disable CA1054 // Change the type of attribute from 'string' to 'System.Uri'
79+ string ? schemaUrl = null ,
80+ #pragma warning restore CA1054 // Change the type of attribute from 'string' to 'System.Uri'
5881 IEnumerable < KeyValuePair < string , object ? > > ? tags = null )
5982 {
6083 var tracers = this . Tracers ;
@@ -64,7 +87,7 @@ public Tracer GetTracer(
6487 return new ( activitySource : null ) ;
6588 }
6689
67- var key = new TracerKey ( name , version , tags ) ;
90+ var key = new TracerKey ( name , version , schemaUrl , tags ) ;
6891
6992 if ( ! tracers . TryGetValue ( key , out var tracer ) )
7093 {
@@ -77,7 +100,14 @@ public Tracer GetTracer(
77100 return new ( activitySource : null ) ;
78101 }
79102
80- tracer = new ( new ( key . Name , key . Version , key . Tags ) ) ;
103+ var activitySourceOptions = new System . Diagnostics . ActivitySourceOptions ( key . Name )
104+ {
105+ Version = key . Version ,
106+ Tags = key . Tags ,
107+ TelemetrySchemaUrl = key . SchemaUrl ,
108+ } ;
109+
110+ tracer = new ( new ( activitySourceOptions ) ) ;
81111 bool result = tracers . TryAdd ( key , tracer ) ;
82112#if DEBUG
83113 System . Diagnostics . Debug . Assert ( result , "Write into tracers cache failed" ) ;
@@ -118,19 +148,22 @@ internal readonly record struct TracerKey
118148 {
119149 public readonly string Name ;
120150 public readonly string ? Version ;
151+ public readonly string ? SchemaUrl ;
121152 public readonly KeyValuePair < string , object ? > [ ] ? Tags ;
122153
123- public TracerKey ( string ? name , string ? version , IEnumerable < KeyValuePair < string , object ? > > ? tags )
154+ public TracerKey ( string ? name , string ? version , string ? schemaUrl , IEnumerable < KeyValuePair < string , object ? > > ? tags )
124155 {
125156 this . Name = name ?? string . Empty ;
126157 this . Version = version ;
158+ this . SchemaUrl = schemaUrl ;
127159 this . Tags = GetOrderedTags ( tags ) ;
128160 }
129161
130162 public bool Equals ( TracerKey other )
131163 {
132164 if ( ! string . Equals ( this . Name , other . Name , StringComparison . Ordinal ) ||
133- ! string . Equals ( this . Version , other . Version , StringComparison . Ordinal ) )
165+ ! string . Equals ( this . Version , other . Version , StringComparison . Ordinal ) ||
166+ ! string . Equals ( this . SchemaUrl , other . SchemaUrl , StringComparison . Ordinal ) )
134167 {
135168 return false ;
136169 }
@@ -146,9 +179,11 @@ public override int GetHashCode()
146179#if NET
147180 hash = ( hash * 31 ) + ( this . Name ? . GetHashCode ( StringComparison . Ordinal ) ?? 0 ) ;
148181 hash = ( hash * 31 ) + ( this . Version ? . GetHashCode ( StringComparison . Ordinal ) ?? 0 ) ;
182+ hash = ( hash * 31 ) + ( this . SchemaUrl ? . GetHashCode ( StringComparison . Ordinal ) ?? 0 ) ;
149183#else
150184 hash = ( hash * 31 ) + ( this . Name ? . GetHashCode ( ) ?? 0 ) ;
151185 hash = ( hash * 31 ) + ( this . Version ? . GetHashCode ( ) ?? 0 ) ;
186+ hash = ( hash * 31 ) + ( this . SchemaUrl ? . GetHashCode ( ) ?? 0 ) ;
152187#endif
153188
154189 hash = ( hash * 31 ) + GetTagsHashCode ( this . Tags ) ;
0 commit comments