Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,24 @@ public TelemetryItem(Activity activity, ref ActivityTagsProcessor activityTagsPr
{
if (activity.ParentSpanId != default)
{
Tags[ContextTagKeys.AiOperationParentId.ToString()] = activity.ParentSpanId.ToHexString();
Tags[ContextTagKeys.AiOperationParentId.ToString()] = activity.ParentSpanId.ToHexString().Truncate(SchemaConstants.Tags_AiOperationParentId_MaxLength);
Comment thread
rajkumar-rangaraj marked this conversation as resolved.
Outdated
}

Tags[ContextTagKeys.AiOperationId.ToString()] = activity.TraceId.ToHexString();
Tags[ContextTagKeys.AiOperationId.ToString()] = activity.TraceId.ToHexString().Truncate(SchemaConstants.Tags_AiOperationId_MaxLength);

if (activity.GetTelemetryType() == TelemetryType.Request)
{
if (activityTagsProcessor.activityType.HasFlag(OperationType.V2))
{
Tags[ContextTagKeys.AiOperationName.ToString()] = TraceHelper.GetOperationNameV2(activity, ref activityTagsProcessor.MappedTags);
Tags[ContextTagKeys.AiOperationName.ToString()] = TraceHelper.GetOperationNameV2(activity, ref activityTagsProcessor.MappedTags).Truncate(SchemaConstants.Tags_AiOperationName_MaxLength);
}
else if (activityTagsProcessor.activityType.HasFlag(OperationType.Http))
{
Tags[ContextTagKeys.AiOperationName.ToString()] = TraceHelper.GetOperationName(activity, ref activityTagsProcessor.MappedTags);
Tags[ContextTagKeys.AiOperationName.ToString()] = TraceHelper.GetOperationName(activity, ref activityTagsProcessor.MappedTags).Truncate(SchemaConstants.Tags_AiOperationName_MaxLength);
}
else
{
Tags[ContextTagKeys.AiOperationName.ToString()] = activity.DisplayName;
Tags[ContextTagKeys.AiOperationName.ToString()] = activity.DisplayName.Truncate(SchemaConstants.Tags_AiOperationName_MaxLength);
}

// Set ip in case of server spans only.
Expand Down Expand Up @@ -70,17 +70,17 @@ public TelemetryItem(Activity activity, ref ActivityTagsProcessor activityTagsPr
public TelemetryItem(string name, TelemetryItem telemetryItem, ActivitySpanId activitySpanId, ActivityKind kind, DateTimeOffset activityEventTimeStamp) :
this(name, FormatUtcTimestamp(activityEventTimeStamp.DateTime))
{
Tags[ContextTagKeys.AiOperationParentId.ToString()] = activitySpanId.ToHexString();
Tags[ContextTagKeys.AiOperationId.ToString()] = telemetryItem.Tags[ContextTagKeys.AiOperationId.ToString()];
Tags[ContextTagKeys.AiOperationParentId.ToString()] = activitySpanId.ToHexString().Truncate(SchemaConstants.Tags_AiOperationParentId_MaxLength);
Tags[ContextTagKeys.AiOperationId.ToString()] = telemetryItem.Tags[ContextTagKeys.AiOperationId.ToString().Truncate(SchemaConstants.Tags_AiOperationId_MaxLength)];
Comment thread
TimothyMothra marked this conversation as resolved.
Outdated

if (telemetryItem.Tags.TryGetValue("ai.user.userAgent", out string? userAgent))
{
// todo: update swagger to include this key.
Tags["ai.user.userAgent"] = userAgent;
}

Tags[ContextTagKeys.AiCloudRole.ToString()] = telemetryItem.Tags[ContextTagKeys.AiCloudRole.ToString()];
Tags[ContextTagKeys.AiCloudRoleInstance.ToString()] = telemetryItem.Tags[ContextTagKeys.AiCloudRoleInstance.ToString()];
Tags[ContextTagKeys.AiCloudRole.ToString()] = telemetryItem.Tags[ContextTagKeys.AiCloudRole.ToString().Truncate(SchemaConstants.Tags_AiCloudRole_MaxLength)];
Comment thread
TimothyMothra marked this conversation as resolved.
Outdated
Tags[ContextTagKeys.AiCloudRoleInstance.ToString()] = telemetryItem.Tags[ContextTagKeys.AiCloudRoleInstance.ToString().Truncate(SchemaConstants.Tags_AiCloudRoleInstance_MaxLength)];
Tags[ContextTagKeys.AiInternalSdkVersion.ToString()] = SdkVersionUtils.s_sdkVersion.Truncate(SchemaConstants.Tags_AiInternalSdkVersion_MaxLength);
InstrumentationKey = telemetryItem.InstrumentationKey;

Expand All @@ -95,12 +95,12 @@ public TelemetryItem (LogRecord logRecord, AzureMonitorResource? resource, strin
{
if (logRecord.TraceId != default)
{
Tags[ContextTagKeys.AiOperationId.ToString()] = logRecord.TraceId.ToHexString();
Tags[ContextTagKeys.AiOperationId.ToString()] = logRecord.TraceId.ToHexString().Truncate(SchemaConstants.Tags_AiOperationId_MaxLength);
}

if (logRecord.SpanId != default)
{
Tags[ContextTagKeys.AiOperationParentId.ToString()] = logRecord.SpanId.ToHexString();
Tags[ContextTagKeys.AiOperationParentId.ToString()] = logRecord.SpanId.ToHexString().Truncate(SchemaConstants.Tags_AiOperationParentId_MaxLength);
}

InstrumentationKey = instrumentationKey;
Expand All @@ -116,8 +116,8 @@ public TelemetryItem(DateTime time, AzureMonitorResource? resource, string instr
private void SetResourceSdkVersionAndIkey(AzureMonitorResource? resource, string instrumentationKey)
{
InstrumentationKey = instrumentationKey;
Tags[ContextTagKeys.AiCloudRole.ToString()] = resource?.RoleName;
Tags[ContextTagKeys.AiCloudRoleInstance.ToString()] = resource?.RoleInstance;
Tags[ContextTagKeys.AiCloudRole.ToString()] = resource?.RoleName.Truncate(SchemaConstants.Tags_AiCloudRole_MaxLength);
Tags[ContextTagKeys.AiCloudRoleInstance.ToString()] = resource?.RoleInstance.Truncate(SchemaConstants.Tags_AiCloudRoleInstance_MaxLength);
Tags[ContextTagKeys.AiInternalSdkVersion.ToString()] = SdkVersionUtils.s_sdkVersion.Truncate(SchemaConstants.Tags_AiInternalSdkVersion_MaxLength);
}

Expand All @@ -131,7 +131,7 @@ private void SetAuthenticatedUserId(ref ActivityTagsProcessor activityTagsProces
{
if (activityTagsProcessor.EndUserId != null)
{
Tags[ContextTagKeys.AiUserAuthUserId.ToString()] = activityTagsProcessor.EndUserId;
Tags[ContextTagKeys.AiUserAuthUserId.ToString()] = activityTagsProcessor.EndUserId.Truncate(SchemaConstants.Tags_AiUserAuthUserId_MaxLength);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,33 @@ internal static class SchemaConstants
public const int TelemetryEnvelope_Time_MaxLength = 64;
public const int TelemetryEnvelope_InstrumentationKey_MaxLength = 40;

public const int Tags_AiApplicationVer_MaxLength = 1024;
public const int Tags_AiDeviceId_MaxLength = 1024;
public const int Tags_AiDeviceLocale_MaxLength = 64;
public const int Tags_AiDeviceModel_MaxLength = 256;
public const int Tags_AiDeviceOemName_MaxLength = 256;
public const int Tags_AiDeviceOsVersion_MaxLength = 256;
public const int Tags_AiDeviceType_MaxLength = 64;
public const int Tags_AiLocationIp_MaxLength = 46;
public const int Tags_AiLocationCountry_MaxLength = 256;
public const int Tags_AiLocationProvince_MaxLength = 256;
public const int Tags_AiLocationCity_MaxLength = 256;
public const int Tags_AiOperationId_MaxLength = 128;
public const int Tags_AiOperationName_MaxLength = 1024;
public const int Tags_AiOperationParentId_MaxLength = 512;
public const int Tags_AiOperationSyntheticSource_MaxLength = 1024;
public const int Tags_AiOperationCorrelationVector_MaxLength = 64;
public const int Tags_AiSessionId_MaxLength = 64;
public const int Tags_AiSessionIsFirst_MaxLength = 5;
public const int Tags_AiUserAccountId_MaxLength = 1024;
public const int Tags_AiUserId_MaxLength = 128;
public const int Tags_AiUserAuthUserId_MaxLength = 1024;
public const int Tags_AiCloudRole_MaxLength = 256;
public const int Tags_AiCloudRoleVer_MaxLength = 256;
public const int Tags_AiCloudRoleInstance_MaxLength = 256;
public const int Tags_AiCloudLocation_MaxLength = 256;
public const int Tags_AiInternalSdkVersion_MaxLength = 64;
public const int Tags_AiInternalAgentVersion_MaxLength = 64;
public const int Tags_AiInternalNodeName_MaxLength = 256;
}
}