@@ -27,15 +27,15 @@ public TelemetryItem(Activity activity, ref ActivityTagsProcessor activityTagsPr
2727 {
2828 if ( activityTagsProcessor . activityType . HasFlag ( OperationType . V2 ) )
2929 {
30- Tags [ ContextTagKeys . AiOperationName . ToString ( ) ] = TraceHelper . GetOperationNameV2 ( activity , ref activityTagsProcessor . MappedTags ) ;
30+ Tags [ ContextTagKeys . AiOperationName . ToString ( ) ] = TraceHelper . GetOperationNameV2 ( activity , ref activityTagsProcessor . MappedTags ) . Truncate ( SchemaConstants . Tags_AiOperationName_MaxLength ) ;
3131 }
3232 else if ( activityTagsProcessor . activityType . HasFlag ( OperationType . Http ) )
3333 {
34- Tags [ ContextTagKeys . AiOperationName . ToString ( ) ] = TraceHelper . GetOperationName ( activity , ref activityTagsProcessor . MappedTags ) ;
34+ Tags [ ContextTagKeys . AiOperationName . ToString ( ) ] = TraceHelper . GetOperationName ( activity , ref activityTagsProcessor . MappedTags ) . Truncate ( SchemaConstants . Tags_AiOperationName_MaxLength ) ;
3535 }
3636 else
3737 {
38- Tags [ ContextTagKeys . AiOperationName . ToString ( ) ] = activity . DisplayName ;
38+ Tags [ ContextTagKeys . AiOperationName . ToString ( ) ] = activity . DisplayName . Truncate ( SchemaConstants . Tags_AiOperationName_MaxLength ) ;
3939 }
4040
4141 // Set ip in case of server spans only.
@@ -79,8 +79,8 @@ public TelemetryItem(string name, TelemetryItem telemetryItem, ActivitySpanId ac
7979 Tags [ "ai.user.userAgent" ] = userAgent ;
8080 }
8181
82- Tags [ ContextTagKeys . AiCloudRole . ToString ( ) ] = telemetryItem . Tags [ ContextTagKeys . AiCloudRole . ToString ( ) ] ;
83- Tags [ ContextTagKeys . AiCloudRoleInstance . ToString ( ) ] = telemetryItem . Tags [ ContextTagKeys . AiCloudRoleInstance . ToString ( ) ] ;
82+ Tags [ ContextTagKeys . AiCloudRole . ToString ( ) ] = telemetryItem . Tags [ ContextTagKeys . AiCloudRole . ToString ( ) ] . Truncate ( SchemaConstants . Tags_AiCloudRole_MaxLength ) ;
83+ Tags [ ContextTagKeys . AiCloudRoleInstance . ToString ( ) ] = telemetryItem . Tags [ ContextTagKeys . AiCloudRoleInstance . ToString ( ) ] . Truncate ( SchemaConstants . Tags_AiCloudRoleInstance_MaxLength ) ;
8484 Tags [ ContextTagKeys . AiInternalSdkVersion . ToString ( ) ] = SdkVersionUtils . s_sdkVersion . Truncate ( SchemaConstants . Tags_AiInternalSdkVersion_MaxLength ) ;
8585 InstrumentationKey = telemetryItem . InstrumentationKey ;
8686
@@ -116,8 +116,8 @@ public TelemetryItem(DateTime time, AzureMonitorResource? resource, string instr
116116 private void SetResourceSdkVersionAndIkey ( AzureMonitorResource ? resource , string instrumentationKey )
117117 {
118118 InstrumentationKey = instrumentationKey ;
119- Tags [ ContextTagKeys . AiCloudRole . ToString ( ) ] = resource ? . RoleName ;
120- Tags [ ContextTagKeys . AiCloudRoleInstance . ToString ( ) ] = resource ? . RoleInstance ;
119+ Tags [ ContextTagKeys . AiCloudRole . ToString ( ) ] = resource ? . RoleName . Truncate ( SchemaConstants . Tags_AiCloudRole_MaxLength ) ;
120+ Tags [ ContextTagKeys . AiCloudRoleInstance . ToString ( ) ] = resource ? . RoleInstance . Truncate ( SchemaConstants . Tags_AiCloudRoleInstance_MaxLength ) ;
121121 Tags [ ContextTagKeys . AiInternalSdkVersion . ToString ( ) ] = SdkVersionUtils . s_sdkVersion . Truncate ( SchemaConstants . Tags_AiInternalSdkVersion_MaxLength ) ;
122122 }
123123
@@ -131,7 +131,7 @@ private void SetAuthenticatedUserId(ref ActivityTagsProcessor activityTagsProces
131131 {
132132 if ( activityTagsProcessor . EndUserId != null )
133133 {
134- Tags [ ContextTagKeys . AiUserAuthUserId . ToString ( ) ] = activityTagsProcessor . EndUserId ;
134+ Tags [ ContextTagKeys . AiUserAuthUserId . ToString ( ) ] = activityTagsProcessor . EndUserId . Truncate ( SchemaConstants . Tags_AiUserAuthUserId_MaxLength ) ;
135135 }
136136 }
137137 }
0 commit comments