83 references to OpenTelemetryConsts
Microsoft.Extensions.AI (83)
ChatCompletion\OpenTelemetryChatClient.cs (51)
64string name = string.IsNullOrEmpty(sourceName) ? OpenTelemetryConsts.DefaultSourceName : sourceName!; 69OpenTelemetryConsts.GenAI.Client.TokenUsage.Name, 70OpenTelemetryConsts.TokensUnit, 71OpenTelemetryConsts.GenAI.Client.TokenUsage.Description, 72advice: new() { HistogramBucketBoundaries = OpenTelemetryConsts.GenAI.Client.TokenUsage.ExplicitBucketBoundaries }); 75OpenTelemetryConsts.GenAI.Client.OperationDuration.Name, 76OpenTelemetryConsts.SecondsUnit, 77OpenTelemetryConsts.GenAI.Client.OperationDuration.Description, 78advice: new() { HistogramBucketBoundaries = OpenTelemetryConsts.GenAI.Client.OperationDuration.ExplicitBucketBoundaries }); 220string.IsNullOrWhiteSpace(modelId) ? OpenTelemetryConsts.GenAI.Chat : $"{OpenTelemetryConsts.GenAI.Chat} {modelId}", 226.AddTag(OpenTelemetryConsts.GenAI.Operation.Name, OpenTelemetryConsts.GenAI.Chat) 227.AddTag(OpenTelemetryConsts.GenAI.Request.Model, modelId) 228.AddTag(OpenTelemetryConsts.GenAI.SystemName, _system); 233.AddTag(OpenTelemetryConsts.Server.Address, _serverAddress) 234.AddTag(OpenTelemetryConsts.Server.Port, _serverPort); 241_ = activity.AddTag(OpenTelemetryConsts.GenAI.Request.FrequencyPenalty, frequencyPenalty); 246_ = activity.AddTag(OpenTelemetryConsts.GenAI.Request.MaxTokens, maxTokens); 251_ = activity.AddTag(OpenTelemetryConsts.GenAI.Request.PresencePenalty, presencePenalty); 256_ = activity.AddTag(OpenTelemetryConsts.GenAI.Request.StopSequences, $"[{string.Join(", ", stopSequences.Select(s => $"\"{s}\""))}]"); 261_ = activity.AddTag(OpenTelemetryConsts.GenAI.Request.Temperature, temperature); 266_ = activity.AddTag(OpenTelemetryConsts.GenAI.Request.TopK, topK); 271_ = activity.AddTag(OpenTelemetryConsts.GenAI.Request.TopP, top_p); 285_ = activity.AddTag(OpenTelemetryConsts.GenAI.Request.PerProvider(_system, "response_format"), responseFormat); 290_ = activity.AddTag(OpenTelemetryConsts.GenAI.Request.PerProvider(_system, "seed"), seed); 301OpenTelemetryConsts.GenAI.Request.PerProvider(_system, JsonNamingPolicy.SnakeCaseLower.ConvertName(prop.Key)), 328tags.Add(OpenTelemetryConsts.Error.Type, error.GetType().FullName); 339tags.Add(OpenTelemetryConsts.GenAI.Token.Type, "input"); 347tags.Add(OpenTelemetryConsts.GenAI.Token.Type, "output"); 356.AddTag(OpenTelemetryConsts.Error.Type, error.GetType().FullName) 369_ = activity.AddTag(OpenTelemetryConsts.GenAI.Response.FinishReasons, $"[\"{finishReason.Value.ToLowerInvariant()}\"]"); 375_ = activity.AddTag(OpenTelemetryConsts.GenAI.Response.Id, completion.CompletionId); 380_ = activity.AddTag(OpenTelemetryConsts.GenAI.Response.Model, completion.ModelId); 385_ = activity.AddTag(OpenTelemetryConsts.GenAI.Response.InputTokens, inputTokens); 390_ = activity.AddTag(OpenTelemetryConsts.GenAI.Response.OutputTokens, outputTokens); 403OpenTelemetryConsts.GenAI.Response.PerProvider(_system, JsonNamingPolicy.SnakeCaseLower.ConvertName(prop.Key)), 413tags.Add(OpenTelemetryConsts.GenAI.Operation.Name, OpenTelemetryConsts.GenAI.Chat); 417tags.Add(OpenTelemetryConsts.GenAI.Request.Model, requestModelId); 420tags.Add(OpenTelemetryConsts.GenAI.SystemName, _system); 424tags.Add(OpenTelemetryConsts.Server.Address, endpointAddress); 425tags.Add(OpenTelemetryConsts.Server.Port, _serverPort); 430tags.Add(OpenTelemetryConsts.GenAI.Response.Model, responseModel); 446Log(new(1, OpenTelemetryConsts.GenAI.Assistant.Message), 453Log(new(1, OpenTelemetryConsts.GenAI.Tool.Message), 465Log(new(1, message.Role == ChatRole.System ? OpenTelemetryConsts.GenAI.System.Message : OpenTelemetryConsts.GenAI.User.Message), 482EventId id = new(1, OpenTelemetryConsts.GenAI.Choice); 503new(OpenTelemetryConsts.Event.Name, id.Name), 504new(OpenTelemetryConsts.GenAI.SystemName, _system),
Embeddings\OpenTelemetryEmbeddingGenerator.cs (32)
61string name = string.IsNullOrEmpty(sourceName) ? OpenTelemetryConsts.DefaultSourceName : sourceName!; 66OpenTelemetryConsts.GenAI.Client.TokenUsage.Name, 67OpenTelemetryConsts.TokensUnit, 68OpenTelemetryConsts.GenAI.Client.TokenUsage.Description, 69advice: new() { HistogramBucketBoundaries = OpenTelemetryConsts.GenAI.Client.TokenUsage.ExplicitBucketBoundaries }); 72OpenTelemetryConsts.GenAI.Client.OperationDuration.Name, 73OpenTelemetryConsts.SecondsUnit, 74OpenTelemetryConsts.GenAI.Client.OperationDuration.Description, 75advice: new() { HistogramBucketBoundaries = OpenTelemetryConsts.GenAI.Client.OperationDuration.ExplicitBucketBoundaries }); 132string.IsNullOrWhiteSpace(modelId) ? OpenTelemetryConsts.GenAI.Embeddings : $"{OpenTelemetryConsts.GenAI.Embeddings} {modelId}", 136new(OpenTelemetryConsts.GenAI.Operation.Name, OpenTelemetryConsts.GenAI.Embeddings), 137new(OpenTelemetryConsts.GenAI.Request.Model, modelId), 138new(OpenTelemetryConsts.GenAI.SystemName, _modelProvider), 146.AddTag(OpenTelemetryConsts.Server.Address, _endpointAddress) 147.AddTag(OpenTelemetryConsts.Server.Port, _endpointPort); 152_ = activity.AddTag(OpenTelemetryConsts.GenAI.Request.EmbeddingDimensions, dimensions); 166OpenTelemetryConsts.GenAI.Request.PerProvider(_system, JsonNamingPolicy.SnakeCaseLower.ConvertName(prop.Key)), 202tags.Add(OpenTelemetryConsts.Error.Type, error.GetType().FullName); 211tags.Add(OpenTelemetryConsts.GenAI.Token.Type, "input"); 222.AddTag(OpenTelemetryConsts.Error.Type, error.GetType().FullName) 228_ = activity.AddTag(OpenTelemetryConsts.GenAI.Response.InputTokens, inputTokens); 233_ = activity.AddTag(OpenTelemetryConsts.GenAI.Response.Model, responseModelId); 245OpenTelemetryConsts.GenAI.Response.PerProvider(_system, JsonNamingPolicy.SnakeCaseLower.ConvertName(prop.Key)), 254tags.Add(OpenTelemetryConsts.GenAI.Operation.Name, OpenTelemetryConsts.GenAI.Embeddings); 258tags.Add(OpenTelemetryConsts.GenAI.Request.Model, requestModelId); 261tags.Add(OpenTelemetryConsts.GenAI.SystemName, _modelProvider); 265tags.Add(OpenTelemetryConsts.Server.Address, endpointAddress); 266tags.Add(OpenTelemetryConsts.Server.Port, _endpointPort); 272tags.Add(OpenTelemetryConsts.GenAI.Response.Model, responseModelId);