Repository: pydantic/pydantic-ai
File: pydantic_ai_slim/pydantic_ai/models/instrumented.py (Python)

Code before:
                        metric_attributes = {
                            GEN_AI_SYSTEM_ATTRIBUTE: system,
                            'gen_ai.operation.name': operation,
                            'gen_ai.request.model': request_model,
                            'gen_ai.response.model': response_model,
                        }
                        if response.usage.input_tokens:  # pragma: no branch
                            self.instrumentation_settings.tokens_histogram.record(
                                response.usage.input_tokens,
                                {**metric_attributes, 'gen_ai.token.type': 'input'},
                            )
                        if response.usage.output_tokens:  # pragma: no branch
                            self.instrumentation_settings.tokens_histogram.record(
                                response.usage.output_tokens,
                                {**metric_attributes, 'gen_ai.token.type': 'output'},
                            )

                    nonlocal record_metrics
                    record_metrics = _record_metrics

                    if not span.is_recording():
                        return

                    self.instrumentation_settings.handle_messages(messages, response, system, span)
                    try:
                        cost_attributes = {'operation.cost': float(response.price().total_price)}
                    except LookupError:
                        cost_attributes = {}
                    span.set_attributes(
                        {
                            **response.usage.opentelemetry_attributes(),
                            'gen_ai.response.model': response_model,
                            **cost_attributes,
                        }
                    )
                    span.update_name(f'{operation} {request_model}')

                yield finish
        finally:
            if record_metrics:
                # We only want to record metrics after the span is finished,
                # to prevent them from being redundantly recorded in the span itself by logfire.
                record_metrics()

    @staticmethod
    def model_attributes(model: Model):
        attributes: dict[str, AttributeValue] = {
            GEN_AI_SYSTEM_ATTRIBUTE: model.system,
            GEN_AI_REQUEST_MODEL_ATTRIBUTE: model.model_name,
        }
        if base_url := model.base_url:

Review comment (suggestion):
Can you see if you can incorporate https://github.com/pydantic/pydantic-ai/pull/2684 into this PR? Marcelo is out but Samuel said he wanted `price` to be renamed to `cost`

Code after:
                        metric_attributes = {
                            GEN_AI_SYSTEM_ATTRIBUTE: system,
                            'gen_ai.operation.name': operation,
                            'gen_ai.request.model': request_model,
                            'gen_ai.response.model': response_model,
                        }
                        if response.usage.input_tokens:  # pragma: no branch
                            self.instrumentation_settings.tokens_histogram.record(
                                response.usage.input_tokens,
                                {**metric_attributes, 'gen_ai.token.type': 'input'},
                            )
                        if response.usage.output_tokens:  # pragma: no branch
                            self.instrumentation_settings.tokens_histogram.record(
                                response.usage.output_tokens,
                                {**metric_attributes, 'gen_ai.token.type': 'output'},
                            )

                    nonlocal record_metrics
                    record_metrics = _record_metrics

                    if not span.is_recording():
                        return

                    self.instrumentation_settings.handle_messages(messages, response, system, span)
                    try:
                        cost_attributes = {'operation.cost': float(response.cost().total_price)}
                    except LookupError:
                        cost_attributes = {}
                    span.set_attributes(
                        {
                            **response.usage.opentelemetry_attributes(),
                            'gen_ai.response.model': response_model,
                            **cost_attributes,
                        }
                    )
                    span.update_name(f'{operation} {request_model}')

                yield finish
        finally:
            if record_metrics:
                # We only want to record metrics after the span is finished,
                # to prevent them from being redundantly recorded in the span itself by logfire.
                record_metrics()

    @staticmethod
    def model_attributes(model: Model):
        attributes: dict[str, AttributeValue] = {
            GEN_AI_SYSTEM_ATTRIBUTE: model.system,
            GEN_AI_REQUEST_MODEL_ATTRIBUTE: model.model_name,
        }
        if base_url := model.base_url: