func()

in pkg/inst-api-semconv/instrumenter/ai/ai_attrs_extractor.go [56:99]


func (h *AILLMAttrsExtractor[REQUEST, RESPONSE, GETTER1, GETTER2]) OnStart(attributes []attribute.KeyValue, parentContext context.Context, request REQUEST) ([]attribute.KeyValue, context.Context) {
	attributes, parentContext = h.Base.OnStart(attributes, parentContext, request)
	attributes = append(attributes, attribute.KeyValue{
		Key:   semconv.GenAIRequestModelKey,
		Value: attribute.StringValue(h.LLMGetter.GetAIRequestModel(request)),
	}, attribute.KeyValue{
		Key:   semconv.GenAIRequestEncodingFormatsKey,
		Value: attribute.StringSliceValue(h.LLMGetter.GetAIRequestEncodingFormats(request)),
	}, attribute.KeyValue{
		Key:   semconv.GenAIRequestMaxTokensKey,
		Value: attribute.Int64Value(h.LLMGetter.GetAIRequestMaxTokens(request)),
	}, attribute.KeyValue{
		Key:   semconv.GenAIRequestFrequencyPenaltyKey,
		Value: attribute.Float64Value(h.LLMGetter.GetAIRequestFrequencyPenalty(request)),
	}, attribute.KeyValue{
		Key:   semconv.GenAIRequestPresencePenaltyKey,
		Value: attribute.Float64Value(h.LLMGetter.GetAIRequestPresencePenalty(request)),
	}, attribute.KeyValue{
		Key:   semconv.GenAIRequestStopSequencesKey,
		Value: attribute.StringSliceValue(h.LLMGetter.GetAIRequestStopSequences(request)),
	}, attribute.KeyValue{
		Key:   semconv.GenAIRequestTemperatureKey,
		Value: attribute.Float64Value(h.LLMGetter.GetAIRequestTemperature(request)),
	}, attribute.KeyValue{
		Key:   semconv.GenAIRequestTopKKey,
		Value: attribute.Float64Value(h.LLMGetter.GetAIRequestTopK(request)),
	}, attribute.KeyValue{
		Key:   semconv.GenAIRequestTopPKey,
		Value: attribute.Float64Value(h.LLMGetter.GetAIRequestTopP(request)),
	}, attribute.KeyValue{
		Key:   semconv.GenAIUsageInputTokensKey,
		Value: attribute.Int64Value(h.LLMGetter.GetAIUsageInputTokens(request)),
	}, attribute.KeyValue{
		Key:   semconv.ServerAddressKey,
		Value: attribute.StringValue(h.LLMGetter.GetAIServerAddress(request)),
	}, attribute.KeyValue{
		Key:   semconv.GenAIRequestSeedKey,
		Value: attribute.Int64Value(h.LLMGetter.GetAIRequestSeed(request)),
	})
	if h.Base.AttributesFilter != nil {
		attributes = h.Base.AttributesFilter(attributes)
	}
	return attributes, parentContext
}