core: preserve metrics registry in Context.WithValue (#7861)