You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: metrics.go
    path of file: ./repos/encore/v2/parser/infra/metrics
    
    the code of the file until where you have to start completion: package metrics

import (
	"fmt"
	"go/ast"
	"go/token"
	"strings"


    
func parseMetric(c metricConstructor, d parseutil.ReferenceInfo) {
	displayName := d.ResourceFunc.NaiveDisplayName()
	errs := d.Pass.Errs
	if len(d.Call.Args) != 2 {
		errs.Add(errInvalidArgCount(displayName, len(d.Call.Args)).AtGoNode(d.Call))
		return
	}

	// Validate the metric name.
	metricName := parseutil.ParseResourceName(errs, displayName, "metric name",
		d.Call.Args[0], parseutil.SnakeName, "e_")
	if metricName == "" {
		// we already reported the error inside ParseResourceName
		return
	}

	// Validate the metric value type.
	valueType := d.TypeArgs[0]
	if c.HasLabels {
		valueType = d.TypeArgs[1]
	}
	if valueType.Family() != schema.Builtin {
		errs.Add(errInvalidMetricType.AtGoNode(valueType.ASTExpr()))
		return
	}

	var labelType option.Option[schema.Type]
	var labelFields []Label
	if c.HasLabels {
		// Make sure it's a named struct, without pointers.
		typeArg := d.TypeArgs[0]
		declRef, ok := schemautil.ResolveNamedStruct(typeArg, false)
		if !ok {
			errs.Add(errInvalidLabelType.AtGoNode(typeArg.ASTExpr()))
			return
		} else if declRef.Pointers > 0 {
			errs.Add(errLabelNoPointer.AtGoNode(typeArg.ASTExpr()))
			return
		}

		// Make sure all the fields are builtin types.
		concrete := schemautil.ConcretizeWithTypeArgs(errs, declRef.Decl.Type, declRef.TypeArgs).(schema.StructType)
		validKinds := append([]schema.BuiltinKind{schema.Bool, schema.String}, schemautil.Integers...)
		for _, f := range concrete.Fields {
			if f.IsAnonymous() {
				errs.Add(errLabelNoAnonymous.AtGoNode(f.AST))
			} else if !schemautil.IsBuiltinKind(f.Type, validKinds...) {
				errs.Add(errLabelInvalidType.AtGoNode(f.AST.Type, errors.AsError(fmt.Sprintf("got %s", literals.PrettyPrint(f.AST.Type)))))
			} else {
				// Validate the label
				label := idents.Convert(f.Name.MustGet(), idents.SnakeCase)
				if label == "service" {
					errs.Add(errLabelReservedName.AtGoNode(f.AST.Names[0]))
				}

				labelFields = append(labelFields, Label{
					Key:  label,
					Type: f.Type.(schema.BuiltinType),
					Doc:  f.Doc,
				})
			}
		}
		labelType = option.Some(typeArg)
	}

	m := &Metric{
		AST:       d.Call,
		Name:      metricName,
		Doc:       d.Doc,
		Type:      c.Type,
		File:      d.File,
		ValueType: valueType.(schema.BuiltinType),
		LabelType: labelType,
		Labels:    labelFields,
	}

	// Parse and validate the metric configuration.
	cfgLit, ok := literals.ParseStruct(errs, d.File, "metrics.MetricConfig", d.Call.Args[1])
	if !ok {
		return // error reported by ParseStruct
	}
	c.ConfigParse(c, d, cfgLit, m)
	m.ConfigLiteral = cfgLit.Lit()

	d.Pass.RegisterResource(m)
	d.Pass.AddBind(d.File, d.Ident, m)
}